akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys

n = sys.stdin.readline().rstrip()
nums = (int(i) for i in sys.stdin.readline().rstrip().split())

odds = 0
for a in nums:
  if a % 2 != 0:
    odds += a

if odds % 2 == 0:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 11104
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int n; cin >> n;
	string s1, s2;
	cin >> s1 >> s2;

	vector<bool> b; int i = 0;
	while (i < n) {
		if (s1[i] == s2[i]) {
			b.pb(true);
			i++;
		}
		else {
			b.pb(false);
			i += 2;
		}
	}

	LL ans = b[0] ? 3LL : 6LL;
	rep(i, sz(b) - 1) {
		if (b[i] && b[i + 1]) {
			ans = ans * 2 % mod;
		}
		else if (b[i] && !b[i + 1]) {
			ans = ans * 2 % mod;
		}
		else if (!b[i] && b[i + 1]) {
			ans = ans % mod;
		}
		else if (!b[i] && !b[i + 1]) {
			ans = ans * 3 % mod;
		}
	}
	Cout(ans);
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
   long long a,b,x,y;
   cin >> a >> b;
   x=max(a,b);
   y=min(a,b);
   if(x%y==0){
       cout << x << endl;
   }
   else{
       for(long long i=y/2; i>0; i--){
           if(y%i==0 && x%i==0){
               cout << x*y/i <<endl;
               break;
           }
       }
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
200^5-199^5
=7920399001
*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll X; cin>>X;
  
  for(ll a=-200; a<=200; a++){
    for(ll b=-200; b<=200; b++){
      ll c = a*a*a*a*a - b*b*b*b*b;
      if (c == X){
        cout <<a<<" "<<b<<endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	string S;
	cin >> S;
	int sum,mi=1000;
	for(int i=0; i<S.size()-2; i++){
		sum=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
		mi=min(mi,abs(sum-753));
	}
	cout << mi << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var a = IntStream.range(0, n).map(i -> sc.nextInt()).toArray();
		sc.close();

		var m = 1000L;
		var index = 0;
		while (index < n - 1) {
			var v1 = a[index];
			var v2 = a[index];
			var index2 = -1;
			for (var i = index + 1; i < n; i++) {
				if (v2 <= a[i]) {
					v2 = a[i];
					index2 = i;
				} else if (v2 > v1 && v2 > a[i]) {
					break;
				} else if (v1 > a[i]) {
					v1 = a[i];
					v2 = a[i];
				}
			}
			if (index2 == -1) {
				break;
			}

			m += (m / v1) * (v2 - v1);
			index = index2;
		}
		System.out.println(m);
	}
}


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

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

    int n, x;
    cin >> n >> x;

    vector<int> vi;
    for (int i = 0; i < n; i++) {
        int input;
        cin >> input;
        vi.push_back(input);
    }

    int coord = 0, count = 0;

    for (auto L : vi) {
        if (coord <= x)
            count++;
        coord += L;
    }

    if (coord <= x)
        count++;
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define SIZE 100005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int N;
int A[105],B[105],a[105],b[105];

int main(){
	int rec=0,ans=0;
	cin >> N;
	for(int i=0;i<N;i++) cin >> A[i];
	for(int i=0;i<N;i++) cin >> B[i];
	
	a[0]=A[0];
	b[0]=B[0];
	for(int i=1;i<N;i++){
		a[i]=a[i-1]+A[i];
		b[i]=b[i-1]+B[i];
	}
	for(int i=0;i<N;i++){
		if(i==0) rec=a[i]+b[N-1];
		rec = a[i]+b[N-1]-b[i-1];
		ans = max(ans,rec);
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
//! (*'ω'*)

use std::io;

fn get_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn solve(s: &Vec<char>, i: usize, exp: &mut String) -> u64 {
    if i < s.len() {
        exp.push(s[i]);
        let a = solve(s, i + 1, &mut exp.clone());
        let b = if i + 1 == s.len() {
            0
        } else {
            exp.push(' ');
            solve(s, i + 1, exp)
        };
        a + b
    } else {
        exp.split_whitespace().map(|x| x.parse::<u64>().unwrap()).fold(0, |x, y| x + y)
    }
}

fn main() {
    let s = get_line().chars().collect::<Vec<char>>();
    println!("{}", solve(&s, 0, &mut String::new()));
}


Measured memory_bytes: 380
n = gets.to_i
arr = Array.new(n)
n.times do |k|
  m = gets.to_i
  arr[k] = [] if arr[k].nil?
  m.times do
    i = gets.chomp.split(' ').map(&:to_i)
    arr[k] << [i[0] - 1, i[1]]
  end
end
max = 0
(0...(1 << n)).each do |i|
  ok = true
  map = Hash.new(false)
  bit_str = sprintf("%0#{n}d", i.to_s(2))
  bit = bit_str.split('').reverse
  (0...bit.count).each do |j|
    map[j] = true if bit[j] == '1'
  end
  map.each do |k, _|
    arr[k].each do |l|
      if l[1] == 1
        ok = ok && map[l[0]]
      else
        ok = ok && !map[l[0]]
      end
    end
  end
  max = [max, bit_str.count('1')].max if ok
end
puts max


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



int main(void){
    // Your code here!
    int n, k;
    cin >> n >> k;

    long long a = 0;
    long long b = 0;
    for (int i=1; i<=n; i++){
        if(i % k == 0) a++;
        if(i % k == k / 2)b++;
    }
    
    long long ans = a * a * a;
    if(k % 2 == 0){
        ans += b * b * b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> vector<T> makev(T* b, T* e) {
    vector<T> vec;
    for (auto i = b; i != e; ++i) vec.push_back(*i);
    return vec;
}
struct err {
    err& operator <<(string s) { cerr << s; return *this; }
    template<class T1, class T2> err& operator <<(pair<T1, T2> x) { return *this << "(" << x.first << ", " << x.second << ")"; }
    template<class T> typename enable_if<is_scalar<T>::value == 1, err&>::type operator <<(T a) { cerr << boolalpha << a; return *this; }
    template<class T> typename enable_if<is_scalar<T>::value == 0, err&>::type operator <<(T a) {
        *this << "{";
        for (auto i = begin(a); i != end(a); ++i)
            *this << ", " + 2 * (i == begin(a)) << *i;
        return *this << "}";
    }
};
#define aty(...) "[ " << #__VA_ARGS__ << " : " << __VA_ARGS__ << " ]\n"




int32_t main() {
    int a, b;
    scanf("%d%d",&a,&b);
    printf("%d\n", max(0, a - b * 2));
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
ll fact_mod(ll n, ll mod) {
    ll f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}
// 繰り返し二乗法 (再帰バージョン)
ll mod_pow(ll x, ll n, ll mod) {
    if(n == 0) return 1;
    ll res = mod_pow((x * x) % mod, n / 2 , mod);
    if(n & 1) res = (res * x) % mod;
    return res;
}
// 組み合わせ nCr を求める (modあり)
ll combination_mod(ll n, ll r, ll mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    ll a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    ll b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}
int main(){
	ll N;
	cin>>N;
	vll A;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		A.pb(a);
	}
	sort(A.begin(),A.end());
	ll alpha=0,beta=0,maxi=0;
	cout<<A.back()<<" ";
	ll mini=INFLL,ind=0;
	for(int i=0;i<N-1;i++){
		if(A.back()%2){
			if(min(abs(A[i]-(A.back()/2)),abs(A[i]-((A.back()+1)/2)))<mini){
				mini=min(abs(A[i]-(A.back()/2)),abs(A[i]-((A.back()+1)/2)));
				ind=i;
			}
		}
		else{
			if(abs(A[i]-A.back()/2)<mini){
				mini=abs(A[i]-A.back()/2);
				ind=i;
			}
		}
	}
	cout<<A[ind]<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>

#define u unsigned
#define s short
#define ll long long
#define REP(i, a, b) for (auto i = (a); i < (b); i++)
#define REPR(i, a, b) for (auto i = (a-1); i >= (b); i--)

using namespace std;

bool solution(u int X, u int Y)
{
    if (Y < 2 * X or Y > 4 * X or (Y & 1))
        return 0;

    for (u int i = 2 * X; i <= 4 * X; i+= 2)
        if (Y == i)
            return 1;
}

int main()
{
    u int X, Y;
    cin >> X >> Y;

    cout << (solution(X, Y) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	std::ios::sync_with_stdio(false);
	int t = 1;
	// cin >> t;
	while (t--) {
		int n, k;
		cin >> n >> k;
		vector<int> arr(n);
		int ans = 0;
		for (int i = 0; i < n; i++) {
			cin >> arr[i];
			if (arr[i] >= k)ans++;
		}
		cout << ans;
	}
	return 0;
}

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

int n, k;
vector<int> w(100010);

bool ok(int p) {
	int cw = 0, cnt = 1;
	for (int i = 0; i < n; ++i) {
		if (w[i] > p) return false;
		cw += w[i];
		if (cw > p) {
			cnt++;
			cw = w[i];
		}
	}

	return cnt <= k;
}

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; ++i) cin >> w[i];

	int l = 0, r = INT_MAX;
	while (l + 1 < r) {
		int m = (l + r) / 2;
		if (ok(m)) r = m;
		else l = m;
	}
	cout << r << endl;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mem(x, y) memset(x, y, sizeof(x))
#define pii pair<int, int>
#define mkp make_pair
const int N = 100005;
int n, a[N];
vector<int> g[N];

void dfs(int u, int fa) {
    for(int i = 0; i < (int)g[u].size(); i++) {
        int v = g[u][i];
        if(v != fa) {
            dfs(v, u);
            a[u] ^= (a[v] + 1);
        }
    }
}

int main()
{
    scanf("%d", &n);
    for(int i = 0, x, y; i < n - 1; i++) {
        scanf("%d%d", &x, &y);
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1, 0);
    puts(a[1] ? "Alice" : "Bob");
    return 0;
}



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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> vec){
    if(vec.size()==n+1){
        int sum_point=0;
        rep(i,q){
            if(vec[b[i]]-vec[a[i]]==c[i]){
                sum_point += d[i]; 
            }
        }
        ans = max(ans,sum_point);
        return ;
    }
    vec.push_back(vec.back());
    while(vec.back()<=m){
        dfs(vec);
        vec.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i, q) { cin >> a[i] >> b[i] >> c[i] >> d[i]; }
    
    dfs(vector<int>(1,1));
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

			String inputLine;
			Integer dataset = 1;
			while ((inputLine = br.readLine()) != null) {

				final Integer number = Integer.valueOf(inputLine);

				if (number.equals(0)) {
					break;
				}

				System.out.println("Case " + dataset++ + ": " + number);
			}

		}
	}

}


Measured memory_bytes: 33088
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(input){
	var ans = 0;
	for(var i = 0; i < 4; i++) ans += input[i]==='+'? 1: -1;

	console.log(ans);
}



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

int main(){
    while(true){
        int n, m; cin >> n >> m;
        if(n == 0 && m == 0) break;
        vector<int> h = {0}, w = {0}; //h, wは累積和をとる(h[0] = w [0] = 0　とする)
        for(int i = 0; i < n; i++){
            int a; cin >> a;
            h.push_back(a + h.back());
        }
        for(int i = 0; i < m; i++){
            int b; cin >> b;
            w.push_back(b + w.back());
        }
        vector<int> height(1500100); //縦幅の最大値1500000
        vector<int> width(1500100); //横幅の最大値1500000
        //縦幅としてありうる長さはカウントを増やす
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j <= n; j++){
                height.at(h.at(j) - h.at(i)) += 1;
            }
        }
        //横幅についても同じ
        for(int i = 0; i < m; i++){
            for(int j = i + 1; j <= m; j++){
                width.at(w.at(j) - w.at(i)) += 1;
            }
        }
        //正方形を数える(この部分はO(10^3*n)で間に合う)
        long long cnt = 0;
        for(int i = 0; i < 1500010; i++){
            cnt += height.at(i) * width.at(i);
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 14548
m = int(input())
for k in range(m):
    s = input()
    strs = set([s, s[::-1]])
    for i in range(1, len(s)):
        f, b = s[0 : i], s[i :]
        strs.add(b + f)
        strs.add(f[::-1] + b[::-1])
        strs.add(b + f[::-1])
        strs.add(f + b[::-1])
        strs.add(b[::-1] + f)
        strs.add(f[::-1] + b)
    print(len(strs))


Measured memory_bytes: 5632
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
template <typename Abelian>
struct BIT {
  BIT(int sz_, const Abelian UNITY_ = 0) : UNITY(UNITY_) {
    sz = sz_ + 1;
    dat.assign(sz, UNITY);
  }

  void add(int idx, Abelian value) {
    while (idx < sz) {
      dat[idx] += value;
      idx += idx & -idx;
    }
  }

  Abelian sum(int idx) {
    Abelian res = UNITY;
    while (idx > 0) {
      res += dat[idx];
      idx -= idx & -idx;
    }
    return res;
  }

  int lower_bound(Abelian value) {
    if (value <= UNITY) return UNITY;
    int res = UNITY, exponent = 1;
    while (exponent < sz) exponent <<= 1;
    for (int mask = exponent >> 1; mask > 0; mask >>= 1) {
      if (res + mask < sz && dat[res + mask] < value) {
        value -= dat[res + mask];
        res += mask;
      }
    }
    return res + 1;
  }

private:
  int sz;
  const Abelian UNITY;
  vector<Abelian> dat;
};

template <typename T>
long long inversion_number(const vector<T> &seq) {
  int sz = seq.size();
  vector<T> cp = seq;
  sort(ALL(cp));
  cp.erase(unique(ALL(cp)), cp.end());
  BIT<int> bit(cp.size());
  long long res = 0;
  REP(i, sz) {
    int idx = lower_bound(ALL(cp), seq[i]) - cp.begin() + 1;
    res += i - bit.sum(idx);
    bit.add(idx, 1);
  }
  return res;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  int n = s.length();
  vector<int> cnt(26, 0);
  for (char c : s) ++cnt[c - 'a'];
  int snuke = 0;
  REP(i, 26) {
    if (cnt[i] & 1) ++snuke;
  }
  if (snuke >= 2) {
    cout << -1 << '\n';
    return 0;
  }
  string mae = "", ushiro = "";
  long long ans = 0;
  int migi = 0;
  REP(i, n) {
    if (cnt[s[i] - 'a'] == 1) {
      ans += migi;
      ++migi;
      --cnt[s[i] - 'a'];
    } else if (cnt[s[i] - 'a'] >= 2) {
      mae += s[i];
      ans += migi;
      cnt[s[i] - 'a'] -= 2;
    } else {
      ushiro += s[i];
      ++migi;
    }
  }
  reverse(ALL(mae));
  vector<vector<int> > pos(26);
  REP(i, n / 2) pos[mae[i] - 'a'].emplace_back(i);
  vector<int> idx(26, 0), check(n / 2);
  REP(i, n / 2) {
    int now = ushiro[i] - 'a';
    check[i] = pos[now][idx[now]];
    ++idx[now];
  }
  ans += inversion_number(check);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2708
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


template< int char_size >
struct TrieNode {
  int nxt[char_size];

  int exist;
  vector< int > accept;

  TrieNode() : exist(0) {
    memset(nxt, -1, sizeof(nxt));
  }
};

template< int char_size, int margin >
struct Trie {
  using Node = TrieNode< char_size >;

  vector< Node > nodes;
  int root;

  Trie() : root(0) {
    nodes.push_back(Node());
  }

  void update_direct(int node, int id) {
    nodes[node].accept.push_back(id);
  }

  void update_child(int node, int child, int id) {
    ++nodes[node].exist;
  }

  void add(const string &str, int str_index, int node_index, int id) {
    if(str_index == str.size()) {
      update_direct(node_index, id);
    } else {
      const int c = str[str_index] - margin;
      if(nodes[node_index].nxt[c] == -1) {
        nodes[node_index].nxt[c] = (int) nodes.size();
        nodes.push_back(Node());
      }
      add(str, str_index + 1, nodes[node_index].nxt[c], id);
      update_child(node_index, nodes[node_index].nxt[c], id);
    }
  }

  void add(const string &str, int id) {
    add(str, 0, 0, id);
  }

  void add(const string &str) {
    add(str, nodes[0].exist);
  }

  void query(const string &str, const function< void(int) > &f, int str_index, int node_index) {
    for(auto &idx : nodes[node_index].accept) f(idx);
    if(str_index == str.size()) {
      return;
    } else {
      const int c = str[str_index] - margin;
      if(nodes[node_index].nxt[c] == -1) return;
      query(str, f, str_index + 1, nodes[node_index].nxt[c]);
    }
  }

  void query(const string &str, const function< void(int) > &f) {
    query(str, f, 0, 0);
  }

  int count() const {
    return (nodes[0].exist);
  }

  int size() const {
    return ((int) nodes.size());
  }
};

int main(){
    string S,T;
    cin>>S>>T;
    int res=SZ(T);
    for(int s=0;s<=SZ(S)-SZ(T);s++){
        string miniS=S.substr(s,SZ(T));
        int tmp=0;
        REP(i,SZ(T)){
            if(miniS[i]!=T[i])tmp++;
        }
        res=min(res,tmp);
    }
    cout<<res<<endl;
    return 0;
}
/*
aaa
aaa
*/

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

int main()
{
    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    for (ll i = k; i <= n + 1; i++)
    {
        ll min, max;
        min = i * (i - 1) / 2;
        max = (i * (2 * (n - i + 1) + (i - 1))) / 2;
        ans = (ans + (max - min + 1)) % MOD;
    }

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

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
ll i, n, m, k, ans;
vector<ll> l;

int main() {
    scanf(" %lld", &n);
    rep(0,n) {
        scanf(" %lld", &k);
        l.push_back(k);
    }
    sort(l.begin(), l.end(), std::greater<ll>());
    int cnt = 0;
    for (auto it = l.begin(); it!=l.end(); it++) {
        for (auto jt = it+1; jt!=l.end(); jt++) {
            for (auto kt = jt+1; kt!=l.end(); kt++) {
                if (*it != *jt && *jt != *kt && *kt != *it) {
                    if (*it < *jt + *kt) cnt++;
                }
            }
        }
    }
    printf("%d\n", cnt);
}

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


int main(){
    int N,r=0,g=0,b=0;
    int64_t result=0;
    string S;
    cin>>N>>S;
    for (int i=0;i<N;i++){
        if(S.at(i)=='R'){
            r++;
        }
        else if (S.at(i)=='G'){
            g++;
        }
        else{
            b++;
        }
    }
    for (int i=0;i<N-2;i++){
        if(S.at(i)=='R'){
            r--;
            int gg=0,bb=0;
            for(int j=i+1;j<N-1;j++){
                if(S.at(j)=='R'){
                    continue;
                }
                else if(S.at(j)=='G'){
                    if(j+j-i<N){
                    if(S.at(j+j-i)=='B'){
                        result--;
                    }
                    }
                    gg++;
                    result+=b-bb;
                }
                else{
                    if(j+j-i<N){
                    if(S.at(j+j-i)=='G'){
                        result--;
                    }
                    }
                    bb++;
                    result+=g-gg;
                }
            }
        }
        else if (S.at(i)=='G'){
            g--;
            int rr=0,bb=0;
            for(int j=i+1;j<N-1;j++){
                if(S.at(j)=='R'){
                    if(j+j-i<N){
                    if(S.at(j+j-i)=='B'){
                        result--;
                    }
                    }
                    rr++;
                    result+=b-bb;
                }
                else if(S.at(j)=='G'){
                    continue;
                }
                else{
                    if(j+j-i<N){
                    if(S.at(j+j-i)=='R'){
                        result--;
                    }
                    }
                    bb++;
                    result+=r-rr;
                }
            }
        }
        else{
            b--;
            int gg=0,rr=0;
            for(int j=i+1;j<N-1;j++){
                if(S.at(j)=='R'){
                    if(j+j-i<N){
                    if(S.at(j+j-i)=='G'){
                        result--;
                    }
                    }
                    rr++;
                    result+=g-gg;
                }
                else if(S.at(j)=='G'){
                    if(j+j-i<N){
                    if(S.at(j+j-i)=='R'){
                        result--;
                    }
                    }
                    gg++;
                    result+=r-rr;
                }
                else{
                    continue;
                }
            }
        }

    }
    cout<<result<<endl;

}


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

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)

#define scan(N) scanf("%lld",&N)
#define print(N) printf("%lld",N)
#define scan2(N1,N2) scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2) printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

#define endl '\n'

const long long INF = 2000000000000;
const long long MOD = 1000000007;
const long long MAXN = 3000005;

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0) {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
	lli i,j,h,w,d,x,q,l,r,maxi = -1;
    cin >> h >> w >> d;
    vplli v(MAXN);
    vlli cost(MAXN,0);
    REP(i,1,h)
    {
        REP(j,1,w)
        {
            cin >> x;
            maxi = max(maxi,x);
            v[x].first = i;
            v[x].second = j;
        }
    }
    REP(i,1,maxi)
    {
        cost[i+d] += abs(v[i+d].first-v[i].first) + abs(v[i+d].second-v[i].second) + cost[i];
    }
    cin >> q;
    while(q--)
    {
        cin >> l >> r;
        cout << cost[r] - cost[l] << endl;
    }
	return 0;
}










Measured memory_bytes: 71424
#include <stack>
#include <cctype>
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
string s; int n, p[300], v[300], w[300];
int main() {
	while (cin >> s >> n, s != "0") {
		string t = string({ s[0] });
		for (int i = 1; i < s.size(); i++) {
			if (isdigit(s[i - 1]) && isalpha(s[i])) t += "(" + string({ s[i] }) + ")";
			else t += s[i];
		}
		int pos1 = 0, w1 = 0; s = "";
		memset(p, 0, sizeof(p));
		memset(w, 0, sizeof(w));
		memset(v, 0, sizeof(v));
		for (int i = 0; i < t.size(); i++) {
			if (isdigit(t[i])) w1 = 10 * w1 + t[i] - 48;
			else {
				if (t[i] == '(') v[pos1] = w[pos1] = w1, w1 = 0;
				s += t[i]; pos1++;
			}
		}
		stack<int> st;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == '(') st.push(i);
			if (s[i] == ')') p[i] = st.top(), p[st.top()] = i, st.pop();
		}
		int pos = 0;
		for (int i = 0; i <= n; i++) {
			while (pos < s.size()) {
				if (s[pos] == '(') {
					if (w[pos]) w[pos]--, pos++;
					else w[pos] = v[pos], pos = p[pos] + 1;
				}
				else if (s[pos] == ')') pos = p[pos];
				else {
					if(i != n) pos++; break;
				}
			}
		}
		cout << (pos < s.size() ? s[pos] : '0') << endl;
	}
	return 0;
}

Measured memory_bytes: 3004
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <tuple>

using namespace std;

int arr[100010];

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);

    int n, a, b, c, i;
    scanf("%d", &n);
    for(i = 0; i<n; i++)
        scanf("%d", &arr[i]);

    a = b = c = 0;
    for(i = 0; i<n; i++)
    {
        if(arr[i] % 4 == 0)
            c++;
        else if(arr[i] % 2 == 0)
            b++;
        else
            a++;
    }

    if(c > 0)
    {
        if(a > c+1)
            printf("No\n");
        else if(a <= c)
            printf("Yes\n");
        else
        {
            if(b > 0)
                printf("No\n");
            else
                printf("Yes\n");
        }
        return 0;
    }

    if(a == 0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N;
    string S[110];
    rep(i, N) cin >> S[i];
    cin >> M;
    string T[110];
    rep(i, M) cin >> T[i];
    map<string, int> mp;
    rep(i, M) mp[T[i]]--;
    int ans = 0;
    rep(i, N) {
        ans = max(ans, ++mp[S[i]]);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

class range {
private:
  struct Iterator {
    int val, inc;
    int operator*() {return val;}
    bool operator!=(Iterator& itr) {return val != itr.val;}
    void operator++() {val += inc;}
  };
  Iterator i, n;
public:
  range(int n) : i({0, 1}), n({n, 1}) {}
  range(int i, int n) : i({i, 1}), n({n, 1}) {}
  range(int i, int inc, int n) : i({i, inc}), n({n, inc}) {}
  Iterator& begin() {return i;}
  Iterator& end() {return n;}
};

template<class T> inline T at(const vector<T> &v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

template<class T> inline bool is_max(T &a, const T &b) {return a < b ? a = b, true : false;}
template<class T> inline bool is_min(T &a, const T &b) {return a > b ? a = b, true : false;}

int main() {
  string str;
  cin >> str;
  reverse(str.begin(), str.end());
  cout << str << endl;
}

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

namespace Test
{
    class ForStudy
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string p = Console.ReadLine();
            s += s;
            if (s.Contains(p))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int main(){
  LL N,P;
  cin>> N>>P;
  for(LL i=pow(P,1.0/N)+1;i>=1;i--){
    if(P%LL(pow(i,N))==0){
      cout << i << endl;
      return 0;
    }
  }
  
  cout << 1<< endl;
  
  
  


}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

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

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll a;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>a;
    cout<<a+a*a+a*a*a;
    return 0;
}


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

using namespace std;

const int MAX = 1e6;
const int INF = 2e9;
typedef long long ll;

ll n, k;

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

    cin >> n >> k;

    if (k < n) {
        cout << min((n % k), abs(n % k - k));
    } else {
        cout << min(k - n, n);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n,m;cin>>n>>m;
    char a[n][m];
    int i,j,k;
    int mod = 1000000007;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    long long int dp[n][m];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    for(i=1;i<m;i++)
    {
        if(dp[0][i-1]==0||a[0][i]=='#')
        {
            dp[0][i]=0;
        }
        else if(dp[0][i-1]==1&&a[0][i]=='.')
        {
            dp[0][i]=1;
        }
    } 
    for(i=1;i<n;i++)
    {
        if(dp[i-1][0]==0||a[i][0]=='#')
        {
            dp[i][0]=0;
        }
        else if(dp[i-1][0]==1&&a[i][0]=='.')
        {
            dp[i][0]=1;
        }
    }
    for(i=1;i<n;i++)
    {
        for(j=1;j<m;j++)
        {
            if(a[i][j]=='.')
            {
                dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    cout<<dp[n-1][m-1]<<endl;
	// your code goes here
	return 0;
}



Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
int n;
const int MX=2e5+5;
int r[MX];
pair<long long,long long> a[MX];
long long seg[MX*4];
long long D;
long long A;

void f(int lef,int rig,int x,int y,long long k,int lev){
    if(lef>y || x>rig)return;
    if(x<=lef && rig<=y){
        seg[lev]-=k;
        return;
    }
    int mid=(lef+rig)/2;
    f(lef,mid,x,y,k,lev*2);
    f(mid+1,rig,x,y,k,lev*2+1);
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n>>D>>A;
int i;
    for(i=1    ; i<=n ; i++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a+1,a+n+1);
    int j=1;
    for(i=1 ; i<=n ; i++){
        while(j+1<=n && a[j+1].first<=a[i].first+2*D)j++;
        r[i]=j;
    }
    int nn;
    for(nn=1 ; nn<n ; nn*=2);
    long long ans=0;
    for(i=1 ; i<=n ; i++)seg[nn+i-1]=a[i].second;
    for(i=1 ; i<=n ; i++){
        long long k=0;
        for(int j=nn+i-1 ; j>=1 ; j/=2)k+=seg[j];
        if(k<=0)continue;
        ans+=(k/A+(k%A>0));
        f(1,nn,i,r[i],(k/A+(k%A>0))*A,1);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>
 
using namespace std;
typedef long long ll;

int N;
int Aorig[2][101];
int A[2][101];

int solve(int a) {
    int count = 0;
    for (int j = 0; j <= a; j ++) {
        count += A[0][j];
    }
    for (int j = a; j < N; j ++) {
        count += A[1][j];
    }
    return count;
}

signed main() {
    cin >> N;
    memset(Aorig, 0, sizeof(Aorig));
    for (int i = 0; i < 2; i ++) {
        for (int j = 0; j < N; j ++) {
            cin >> Aorig[i][j];
        }
        Aorig[i][N] = 0;
    }
    int ans = 0;
    for (int j = 0; j <= N; j ++) {
        memcpy(A, Aorig, sizeof(A));
        ans = max(solve(j), ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
   int n;
   cin>>n;
   int f=0,c=0;
   while(n--){
       int x,y;
       cin>>x>>y;
       if(x==y){
           c++;
           if(c==3){
               f=1;
           }
       }
       else{
           c=0;
       }
   }
   if(f==1)
    cout<<"Yes";
   else
    cout<<"No";
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> ac(n);
    rep(i,m) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (ac.at(p).first == 0) {
            if (s == "WA") ac.at(p).second++;
            if (s == "AC") ac.at(p).first = 1;
        }
    }
    int nac = 0, np = 0;
    rep(i,n) {
        if (ac.at(i).first == 1) {
            nac++;
            np += ac.at(i).second;
        }
    }
    cout << nac << ' ' << np << endl;
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> c(H);
  for (int i = 0; i < H; i++) cin >> c[i];

  vector<string> ans(2 * H);
  for (int i = 0; i < H; i++) {
    ans[2*i] = c[i];
    ans[2*i+1] = c[i];
  }
  for (int i = 0;  i < 2 * H; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


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

class Edge
{
	public:
	int cost;
	int from;
	int to;

	Edge(int n,int c)
	{
		to=n;
		cost=c;
	}

	Edge(int f,int t,int c)
	{
		from=f;
		to=t;
		cost=c;
	}
};

vector<Edge> g[100000];
int dp[100000];

int saiki(int d)
{
	dp[d]=0;
	for(int i=0;i<g[d].size();i++)
	{
		Edge e=g[d][i];
		if(dp[e.to]!=-1)
			dp[d]=max(dp[d],dp[e.to]+1);
		else
			dp[d]=max(dp[d],saiki(e.to)+1);
	}
	return dp[d];
}

int main()
{
	int n,m;
	int ans=0;
	cin>>n>>m;
	fill(dp,dp+100000,-1);
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;y--;
		g[x].push_back(Edge(y,1));
	}

	for(int i=0;i<n;i++)
	{
		if(dp[i]==-1)
			saiki(i);
	}

	for(int i=0;i<n;i++)
	{
		//cerr<<dp[i]<<endl;
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8192
a,b = map(int,input().split())
stg = input()
res = "Yes"
for i in range(a):
  if not stg[i].isdigit():
    res = "No"
if not stg[a]=='-':
  res = "No"
for i in range(a+1,a+b+1):
  if not stg[i].isdigit():
    res = "No"
print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <climits>
#include <assert.h>
#include <queue>
#include <set>

using namespace std;
// ???(???????????? ????????? ???????????? ???????????????)
struct Edge {
    int to, cap, cost, rev;
    Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {
        assert(this->cap >= 0);
    }
};

// ?????§????????????O(F|E|)??§?§£???
class FordFulkerson {
public:
    unsigned int num_of_node = 0;   // ???????????°
    map<int, vector<Edge>> G;       // ??°???????????£??\???????????¨???
    vector<bool> used;              // DFS??§?????§??????????????????????????°

    FordFulkerson(unsigned int num_of_node) : num_of_node(num_of_node){
    }

    // from??????to??????????????????cap????????¨?????????????????°?????????????????????
    void add_edge(int from, int to, int cap) {
        this->G[from].push_back(Edge(to, cap, (int)this->G[to].size()));        // ???
        this->G[to].push_back(Edge(from, 0, (int)this->G[from].size() - 1));    // ??????
    }

    // s??????t???????????§???????±??????? O(F|E|)
    int max_flow(int s, int t) {
        int flow = 0;
        while (true) {
            this->used = vector<bool>(this->num_of_node, 0);
            int f = dfs(s, t, INT_MAX);
            if (f == 0) { return flow; }
            flow += f;
        }
    }

private:
    // v??????t???f???????????¨??????????????????
    int dfs(int v, int t, int f) {
        if (v == t) { return f; }
        used[v] = true;
        for (Edge &e : G[v]) {
            if (!used[e.to] && e.cap > 0) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;                 // ???
                    G[e.to][e.rev].cap += d;    // ??????
                    return d;
                }
            }
        }
        return 0;
    }

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

    int X, Y, E;
    cin >> X >> Y >> E;

    FordFulkerson ff(X + Y + 2);
    for (int i = 0; i < E; ++i) {
        int x, y;
        cin >> x >> y;
        ff.add_edge(x, X + y, 1);
    }

    int source = X + Y;
    int sink = source + 1;

    for (int x = 0; x < X; ++x) {
        ff.add_edge(source, x, 1);
    }
    for (int y = X; y < X + Y; ++y) {
        ff.add_edge(y, sink, 1);
    }

    cout << ff.max_flow(source, sink) << endl;
    return 0;
}

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

int main(){
    int p, q, r;
    cin >> p >> q >> r;
    int m;
    m=max(p,q);
    m=max(m,r);

    cout << p+q+r-m << endl;
    

    return 0;
}

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

int main(){
    int N;
    int A[200];
    int c=0;
    cin>>N;
    for(int i=0; i<N; i++) cin>>A[i];
    while (true) {
        bool extra_odd=false;
        for(int i=0;i<N;i++){
            if(A[i]%2==1) extra_odd=true;
        }if(extra_odd) break;
      for(int i=0; i< N;++i) {A[i] /= 2;}
        c++;
    }cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
/* include */
#include"bits/stdc++.h"
/* namespace */
using namespace std;
/* typedef */
/* long系 */
typedef long long ll;	// long long
typedef long double ld;	// long double
/* vector系 */
typedef vector<int> vint;	// intのvector
typedef vector<double> vdouble;	// doubleのvector
typedef vector<ll> vll;	// llのvector
typedef vector<ld> vld;	// ldのvector
typedef vector<pair<int, int>> vi_i;	// i_iのvector
typedef vector<pair<double, double>> vd_d;	// d_dのvector
typedef vector<pair<ll, ll>> vl_l;	// l_lのvector
typedef vector<pair<ld, ld>> vld_ld;	// ld_ldのvector
typedef vector<string> vstring;	// stringのvector
/* pair系 */
typedef pair<int, int> i_i;	// int同士のpair
typedef pair<double, double> d_d;	// double同士のpair
typedef pair<ll, ll> l_l;	// ll同士のpair
typedef pair<ld, ld> ld_ld;	// ld同士のpair
/* define */
#define pb push_back	// push_back
#define all(v) v.begin(),v.end()	// コンテナ全体
#define PI (acos(-1))  // 円周率pi
/* 変数入出力 read, write */
template <typename T>	// 1変数
void read(T& x) {
    cin >> x;
}
template <typename T, typename T0>	// 2変数
void read(T& x, T0& y) {
    cin >> x >> y;
}
template <typename T, typename T0, typename T1>	// 3変数
void read(T& x, T0& y, T1& z) {
    cin >> x >> y >> z;
}
template <typename T, typename T0, typename T1, typename T2>	// 4変数
void read(T& x, T0& y, T1& z, T2& w) {
    cin >> x >> y >> z >> w;
}
template <typename T>	// 1変数
void write(T& x) {
    cout << x << endl;
}
template <typename T, typename T0>	// 2変数
void write(T& x, T0& y) {
    cout << x << " " << y << endl;
}
template <typename T, typename T0, typename T1>	// 3変数
void write(T& x, T0& y, T1& z) {
    cout << x << " " << y << " " << z << endl;
}
template <typename T, typename T0, typename T1, typename T2>	// 4変数
void write(T& x, T0& y, T1& z, T2& w) {
    cout << x << " " << y << " " << z << " " << w << endl;
}
// vectorの出力
template <typename T>
void printvec(const vector<T> &data) {
for (const auto elm : data) {
    cout << elm << " ";
}
cout << endl;
}


int main(int argc, char const *argv[])
{
    ll x; read(x);
    ll a = x / 500, b = x % 500;
    ll c = b / 5;
    ll ans = a * 1000 + c * 5;
    write(ans);

    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const WHITE: u8 = 0;
const GRAY: u8 = 1;
const BLACK: u8 = 2;

fn dfs_visit(
    m: &Vec<Vec<u8>>,
    index: usize,
    color: &mut Vec<u8>,
    time: &mut u32,
    d: &mut Vec<u32>,
    f: &mut Vec<u32>,
) {
    color[index] = GRAY;
    *time = *time + 1;
    d[index] = *time;
    for index_target in 0..color.len() {
        if m[index][index_target] == 0 {
            continue;
        }
        if color[index_target] == WHITE {
            dfs_visit(m, index_target, color, time, d, f);
        }
    }
    color[index] = BLACK;
    *time = *time + 1;
    f[index] = *time;
}

fn main() {
    let n: usize = read();
    let mut color: Vec<u8> = vec![WHITE; n];
    let mut m: Vec<Vec<u8>> = vec![vec![0; n]; n];
    let mut d: Vec<u32> = vec![0; n];
    let mut f: Vec<u32> = vec![0; n];
    let mut time: u32 = 0;
    for _ in 0..n {
        let index: usize = read();
        let count: usize = read();
        for _ in 0..count {
            let number: usize = read();
            m[index - 1][number - 1] = 1;
        }
    }
    for index in 0..n {
        if color[index] == WHITE {
            dfs_visit(&m, index, &mut color, &mut time, &mut d, &mut f);
        }
    }
    for index in 0..n {
        println!("{} {} {}", index + 1, d[index], f[index]);
    }
}



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

using namespace std;

int main()
{
    string S;
    cin >> S;
    string S1 = S.substr(0,1);
    string S2 = S.substr(1,1);
    string S3 = S.substr(2,1);
    string S4 = S.substr(3,1);
    if(S1==S2){
        if(S3==S4 && S1!=S3){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }else{
        if(S1==S3){
            if(S2==S4 && S1!=S2){
                cout << "Yes";
            }else{
                cout << "No";
                }
        }else{
            if(S1==S4){
                if(S2==S3){
                    cout << "Yes";
                }else{
                    cout << "No";
                }
            }else{
                cout << "No";
            }
        }
            
    } 
    
}

Measured memory_bytes: 256