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

using namespace std;
typedef long long Int;

Int n;
Int pp = 1;
Int dp[210][210];

vector<Int> go(){
  vector<Int> res;
  Int k = 0;
  while((1LL << k) - 1 <= n)k++;
  Int p = 1;
  for(Int i = 0;i < k;i++)res.push_back(pp);pp++;
  n -= (1LL << (k-1)) - 1;
  for(Int i = k/2;i >= 0;i--){
    Int tmp = 0;
    for(Int j = 0;j <= k;j++){
      tmp += dp[i][j] * dp[k - i][j];
      if(tmp > n)break;
    }
    if(tmp > n)continue;;
    n -= tmp;
    res.insert(res.begin() + (p - 1), pp);
    res.insert(res.begin() + (i + p), pp);
    p++;
    pp++;
  }

  return res;
}

int main(){
  cin >> n;
  for(Int i = 0;i < 200;i++){
    for(Int j = 0;j < 200;j++){
      if(i < j)dp[i][j] = 0;
      else if(j == 0 || i == j)dp[i][j] = 1;
      else dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
    }
  }

  vector<Int> res;
  
  while(n){
    vector<Int> tmp = go();
    res.insert(res.end(), tmp.begin(), tmp.end());
  }

  cout << res.size() << endl;
  for(Int i = 0;i < res.size();i++)cout << res[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(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 fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

vl v(51);
vl p(51);
vl b(51);
ll ans = 0;

void rec(ll n, ll l) {
	if (n == 0)ans += 1;
	else if (l <= 1)return;
	else if (l >= (v[n] - 1) / 2){
		ans += p[n - 1];
		if (l >= (v[n] - 1) / 2 + 1)ans += 1;
		if (l - ((v[n] - 1) / 2 + 1) > 0) {
			rec(n - 1, l - ((v[n] - 1) / 2 + 1));
		}
	}
	else {
		rec(n - 1, l - 1);
	}
}

void solve(ll n) {
	vl v(n);
	ll sum = 0;
	rep(i, n) {
		cin >> v[i];
		sum += v[i];
	}
	ll ans = 0;
	rep(i, n) {
		if (v[i] * n <= sum)ans++ ;
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	while (cin >> n,n) {
		solve(n);
	}
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N, R;
    cin >> N >> R;
    if (N >= 10) {
        cout << R << endl;
    } else {
        cout << R + 1000 - (100 * N) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const ll mod = 1e9+7;

main(){
    int n;cin>>n;
    string s;cin>>s;
    int count=0;
    int i=0,j=(n-1);
    while(i<j){
        if(s[i]=='W' && s[j]=='R'){
            count++;i++;j--;
        }
        else if(s[i]=='R' && s[j]=='W'){
            i++;
            j--;
        }
        else if(s[j]=='W') j--;
        else i++; 
    }
    cout<<count;
}

Measured memory_bytes: 3736
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n+1];

    for (int i = 1; i <= n; i++) {
      a[i] = sc.nextInt();
    }

    int count = 0;

    for (int i = 1; i <= n; i++) {
      if (a[i]%2 == 1 && i%2 == 1) {
        count++;
      }
    }

    System.out.println(count);

  }

}


Measured memory_bytes: 35928
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	int n, l = 0, r;
	string s;
	stack<char>st;
	cin >> n >> s;
	for (int i = 0;i < n;i++) {
		if (st.empty() && s[i] == ')')l++;
		else if (s[i]=='(')st.push('(');
		else if (!st.empty() && s[i] == ')')st.pop();
	}
	r = st.size();
	for (int i = 0;i < l;i++)cout << '(';
	cout << s;
	for (int i = 0;i < r;i++)cout << ')';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int lli;

using namespace std;

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

   cout << S[0] <<S[1] <<S[2] << endl; 
}

Measured memory_bytes: 3632
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define NIL -1
using namespace std;
struct _Node {
	int parent;
	int left;
	int right;
};
_Node T[100001];
vector<long long> arr(87, 0);
int main(void)
{
	ios::sync_with_stdio(false);
	arr[0] = 2;
	arr[1] = 1;
	for (int i = 2; i < 87; i++)
	{
		arr[i] = arr[i - 1] + arr[i - 2];
	}
	int N;
	cin >> N;
	cout << arr[N] << "\n";
}

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

using namespace std;

#define ll long long
#define ld long double

int main()
{
    ld h;
    cin >> h;
    ll res = 0;
    while(h > 1)
    {
        res+=1;
        res*=2;
        h = floor(h/2);
    }

    cout << res+1 << endl;

    return 0;
}



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

int main() {
	int n,a[100];
	cin >> n;
	for (int i = 0; i < n; i++ ) {
	     cin >> a[i];
	}
	
	for(int i = n -1 ; i >= 0; i--) {
		cout << a[i] ;
		if (i > 0){
			cout << " ";
		}
	}
	
	cout << endl;
	return 0;
}


Measured memory_bytes: 3076
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int K, S;
    cin >> K >> S;

    int ans = 0;
    REP(i, K+1) REP(j, K+1) {
        int d = S - i - j;
        if (d >= 0 && d <= K) ++ans;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;

inline void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];

template<class Abel, class OP>
class BIT {
  private:
    int n;
    std::vector<Abel> dat;
    OP op;
    Abel e;

  public:
    BIT(int n , OP op, Abel e = 0) : n(n), op(op), e(e){
		dat.resize(n + 1);
		for(int i = 0;i <= n;++i){
			dat[i] = e;
		}
    }
	void add(int k, Abel val){
		while(k <= n){
			dat[k] = op(val, dat[k]);
			k += k & -k;
		}
	}
	Abel acum(int k){
		Abel sum = e;
		while(k > 0){
			sum = op(sum, dat[k]);
			k -= k & -k;
		}
		return sum;
	}
};
ll mp3[26][364364] = {};
signed main(){
	IOS();
	string s;
	cin >> s;
	ll n = s.size();
	ll n1 = n / 2;
	map<char, ll> mp, mp2;
	for (int i = 0;i < n;++i) {
		mp[s[i]]++;
	}
	int ok = 0;
	char q = 0;
	for (int i = 0;i < 26;++i) {
		char p = 'a' + i;		
		if(mp[p] % 2 == 1){
			ok++;
			q = p;
		}
	}
	if(ok > 1){
		cout << -1 << endl;
		return 0;
	}
	string a = "";
	for (int i = 0;i < n;++i) {
		mp2[s[i]]++;
		if(mp2[s[i]] <= (mp[s[i]] / 2)){
			a = a + s[i];
		}
	}
	string c = a;
	reverse(c.begin(), c.end());
	string t;
	if(q == 0)t = a + c;
	else t = a + q + c;
	ll cnt[26] = {};
	for (int i = 0;i < n;++i) {
		mp3[t[i] - 'a'][cnt[t[i] - 'a']] = i;
		cnt[t[i] - 'a']++;
	}
	vector<ll> bub(n, 0);
	Fill(cnt, 0);
	for (int i = 0;i < n;++i) {
		bub[i] = mp3[s[i] - 'a'][cnt[s[i] - 'a']];
		cnt[s[i] - 'a']++;
	}
	BIT<ll, function<ll(ll, ll)>> bit(n + 1, [](ll a, ll b){return a + b;}, 0);
	ll ans = 0;
	for (int i = 1;i <= n;++i) {
		ll now = bub[i - 1] + 1;
		ans += now - 1 - bit.acum(now - 1);
		bit.add(now, 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 57544
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
	int n, q;
	int t;
	string name;
	queue<pair<string, int>> Q;

	cin >> n >> q;

	for (int i = 0; i < n; i++) {
		cin >> name >> t;
		Q.push(make_pair(name, t));
	}
	
	pair<string, int> u;
	int elapse = 0, a;

	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		a = min(q, u.second);
		elapse += a;
		u.second -= a;
		if (u.second == 0) {
			cout << u.first << " " << elapse << endl;
		}
		else {
			Q.push(u);
		}
	}
	return 0;
}


Measured memory_bytes: 6348
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//213
	ll n,m;
	cin>>n>>m;
	ll mx = 1;
	for(ll i=m/n;i>=1;i--) {
		if((m/i)*i==m&&m/i>=n){mx=i;break;}
	}
	cout<<mx;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  for (auto &i : a) {
    std::cin >> i;
  }

  int64_t sum = std::accumulate(a.cbegin(), a.cend(), static_cast<int64_t>(0));

  int64_t ans = std::abs((sum - a[0]) - a[0]);

  int64_t tmp = 0;
  for (int64_t i = 0; i < n - 1; i++) {
    tmp += a[i];
    sum -= a[i];
    ans = std::min(ans, std::abs(tmp - sum));
  }

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

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define ll long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 500;
int a[N][N], b[N], cnt[N];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, m;
    int ans = 1e9;
    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++) cin >> a[i][j];
    }
    for (int i = 1; i <= m; i++) b[i] = 1;
    for (int i = 1; i <= m; i++){
        memset(cnt, 0, sizeof(cnt));
        for (int j = 1; j <= n; j++){
            int l = 1;
            while(b[a[j][l]] == 0) l++;
            cnt[a[j][l]]++;
        }
        int x = 0;
        int y = 0;
        for (int i = 1; i <= m; i++){
            if (cnt[i] > x){
                x = cnt[i];
                y = i;
            }
        }
        ans = min(ans, x);
        b[y] = 0;
    }
    cout << ans;
}


Measured memory_bytes: 896
// Problem : A - We Love Golf
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n;
	cin >> n;
	int a,b;;
	cin >> a >> b;
	if((int)((a-1)/n)!=(int)(b/n))
	cout << "OK" << endl;
	else
	cout << "NG" << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N (250000+1000)
using namespace std;

int n,ans[N],now;
struct Node{int num,pos;}a[N];
bool cmp(Node a,Node b){return a.pos<b.pos;}

int main()
{
	scanf("%d",&n);
	for (int i=1; i<=n; ++i)
	{
		scanf("%d",&a[i].pos);
		a[i].num=i; ans[a[i].pos]=i;
	}
	sort(a+1,a+n+1,cmp);
	
	now=1;
	for (int i=1; i<=n; ++i)
	{
		for (int j=1; j<a[i].num; ++j)
		{
			while (ans[now]) now++;
			ans[now]=a[i].num;
		}
		if (now>a[i].pos){puts("No"); return 0;}
	}
	now=n*n;
	for (int i=n; i>=1; --i)
	{
		for (int j=1; j<=n-a[i].num; ++j)
		{
			while (ans[now]) now--;
			ans[now]=a[i].num;
		}
		if (now<a[i].pos){puts("No"); return 0;}
	}
	puts("Yes");
	for (int i=1; i<=n*n; ++i)
		printf("%d ",ans[i]);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n;
	cin >> n;
	vector<P> p(n);
	int a;
	REP(i, n) {
		cin >> a;
		p[i].first = a;
		p[i].second = i + 1;
	}
	sort(ALL(p));
	REP(i, n)
		cout << p[i].second << ' ';
}

Measured memory_bytes: 2432
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> k >> x >> y;
  rrep(i, 1, n + 1) {
    if (i <= k)
      ans += x;
    else
      ans += y;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 384
s = input()
l = len(s)
c = 2019
tm = 1
ti = int(s[-1])
co = [0]*2019
co[ti] += 1
for i in range(1, l):
    tm = tm*10 % c
    ti += int(s[l-i-1]) * tm
    ti = ti % c
    co[ti] += 1
if co[0] != 0:
    co[0] += 1
print(sum([i*(i-1)//2 for i in co]))

Measured memory_bytes: 9372
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
using namespace std;


int main()
{
    int n;
    cin >> n;
    int one = n/100;
    int two = n%100/10;
    int three = n%100%10;
    if(one == 1)
    {
        cout << 9;
    }
    else if(one == 9)
    {
        cout << 1;
    }
    else
    {
        cout << one;
    }
    if(two == 1)
    {
        cout << 9;
    }
    else if(two == 9)
    {
        cout << 1;
    }
    else
    {
        cout << two;
    }if(three == 1)
    {
        cout << 9;
    }
    else if(three == 9)
    {
        cout << 1;
    }
    else
    {
        cout << three;
    }
    cout << endl;

}

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

int main()
{
	int i,j,k,A,B,M,D,c,d;
	cin>>A>>B>>M;
	vector<int> a(A);
	vector<int> b(B);
	vector<int> x(M),y(M),z(M);
	for(i=0;i<A;i++){
		cin>>a[i];
		if(i==0){
			c=a[i];
		}else{
			c=min(c,a[i]);
		}
	}
	for(i=0;i<B;i++){
		cin>>b[i];
		if(i==0){
			d=b[i];
		}else{
			d=min(d,b[i]);
		}
	}
	for(i=0;i<M;i++){
		cin>>x[i]>>y[i]>>z[i];
	}
	D=c+d;
	for(k=0;k<M;k++){
		D=min(D,a[x.at(k)-1]+b[y.at(k)-1]-z[k]);
	}
	cout<<D<<endl;
	return 0;
}

Measured memory_bytes: 2176
import sys

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


def resolve():
    n = int(input())
    X = list(map(int, input().split()))
    for i in range(n):
        x = X[i]
        X[i] = [i, x]
    X_s = sorted(X, key=lambda x: x[1])

    res = [0] * n
    for i in range(n):
        idx, _ = X_s[i]
        if i < n // 2:
            res[idx] = X_s[n // 2][1]
        else:
            res[idx] = X_s[n // 2 - 1][1]

    print(*res, sep="\n")


if __name__ == '__main__':
    resolve()


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll n;
    cin >> n;
    vll v(n), c(n);
    rep(i, n){
        cin >> v[i];
    }
    rep(i, n){
        cin >> c[i];
    }
    ll total = 0;
    rep(i, n){
        if(v[i]>c[i]){
            total += v[i] - c[i];
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 2019;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



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

    
    rep(i, S.size())
    {
        if (S[i] != T[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
#ARC094C
import copy
import sys
import math

#n = int(input())
tmp = input().split()
a,b,c = list(map(lambda a: int(a), tmp))

hoge=max(a,b,c)*3-a-b-c
if(hoge%2==0):
	print(hoge//2)
else:
	print(hoge//2+2)




Measured memory_bytes: 3444
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <vector>
#define ll long long
#define INF 1000000001;
using namespace std;
struct Edge{int from, to, cost;};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,k;
    cin >> n >> m >> k;

    /*if(k%n==0||k%m==0){
        cout << "Yes" << endl;
        return 0;
    }*/
    if(k == 0|| k == n*m){
        cout << "Yes" << endl;
        return 0;
    }

    int flag = 0;
    REP(i,n){
        REP(j,m){
            int b = i*n - i*j + (m-i)*j;
            if(k == b) flag = 1;
        }
    }

    REP(j,n){
        REP(i,m){
            int b = j*m - i*j + (n-j)*i;
            if(k == b) flag = 1;
        }
    }

    if(flag == 1) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using E = tuple<ll, int, ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  int n,k;
  cin >> n >> k;
  cout << (k == 1 ? 0 : n - k) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()

{
	int n;
	cin >> n;
	while(n >= 1)
	{
		if(n % 10 == 9)
		{
			cout << "Yes" << endl;
			return 0;
		}
		n/=10;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    //ExAC
    //input
    long long N,M;
    cin >> N >> M;
    int a[2000],b[2000];
    long long c[2000];
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        c[i] = -c[i];
    }
    //distance
    long long x[1000]; //x[i] 0->i : Ci;
    for (int i = 0; i < N; ++i) {
        x[i] = LONG_LONG_MAX;
    }
    x[0] = 0;

    //update
    for (int loop = 0; loop < N - 1; ++loop) {
        for (int i = 0; i < M; ++i) {
            if (x[a[i] - 1] == LONG_LONG_MAX) continue;

            x[b[i] - 1] = min(x[b[i] - 1],x[a[i] - 1] + c[i]);
        }
    }

    long long ans = x[N - 1];
    bool negative[1000] = {false};
    for (int i = 0; i < N; ++i) {
        negative[i] = false;
    }
    for (int loop = 0; loop < N ; ++ loop) {
        for (int i = 0; i < M; ++i) {
            if (x[a[i] - 1] == LONG_LONG_MAX) continue;

            if (x[b[i] - 1] > x[a[i] - 1] + c[i]) {
                x[b[i] - 1] = x[a[i] - 1] + c[i];
                negative[b[i] - 1] = true;
            }

            if (negative[a[i] - 1] == true) {
                negative[b[i] - 1] = true;
            }
        }
    }

    if (negative[N - 1]) cout << "inf" << endl;
    else cout << -ans << endl;

    return 0;
}

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

using namespace std;

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

	int L = max(-1000000, X - (K - 1));
	int U = min(+1000000, X + (K - 1));
	for (int i = L; i <= U; ++i) {
		cout << i << " ";
	}
	cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = s.length();
		System.out.print(s.charAt(0));
		System.out.print(len-2);
		System.out.println(s.charAt(len-1));
		
		sc.close();
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int primeNumber(const int n) {
	//上から確認する
	for (int N = n; N >= 1; N--) {

		bool isPrime = true;
		//素数判定 i < sqrt(N)+1
		for (int i = 2; i * i <= N; i++) {
			if (N % i == 0) {
				isPrime = false;
				break;
			}
		}
		//もし素数なら
		if (isPrime) {
			return N;
		}
	}
}


int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	ll Sa = 0, Sb = 0;
	int i;
	rep(i, 0, N) {
		cin >> A[i];
		Sa += A[i];
	}
	rep(i, 0, N) {
		cin >> B[i];
		Sb += B[i];
	}

	ll a, b;
	a = b = 0;
	rep(i, 0, N) {
		if (A[i] >= B[i]) {
			b += A[i] - B[i];
		}
		else {
			a += (B[i] - A[i]) / 2;
			if ((B[i] - A[i]) % 2 == 1) {
				b++;
				a++;
			}
		}
	}
	//cout << a << " " << b;
	if (a - b >= 0)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 3680
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College

'''
import sys
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]



def solve():
    
    
    
    # for _ in range(ii()):
    
    
  
    d,t,s=mi()
    if(t*s>=d):
        print('Yes')
    else:
        print('No')
    
    
    
    
    
    
        
    
    
if __name__ =="__main__":
    # read()
    solve()
    

Measured memory_bytes: 66936
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define pi acos(-1)

using namespace std;

int main() {
    nl // Bazzi - Paradise

    string s, t;
    cin >> s >> t;
    cout << t << s;

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main(void){
	int data[100][100];
	int i,j;
	int sum = 0;
	int r =0,c = 0;
	
	scanf("%d %d",&r,&c);
	if(r < 1|| c < 1){
		r = 1;
		c = 1;
	}
	
	for(i = 0;i < r;i++){
		for(j = 0;j < c;j++){
			scanf("%d",&data[i][j]);
		}
	}
	
	for(i = 0;i < r;i++){
		for(j = 0;j < c;j++){
			printf("%d ",data[i][j]);
			sum += data[i][j];
		}
		printf("%d\n",sum);
		sum = 0;	
	}
	
	for(i = 0;i < c;i++){
		for(j = 0;j < r;j++){
			sum += data[j][i];
		}
		printf("%d ",sum);
		sum = 0;
	}
	
	for(i = 0;i < r;i++){
		for(j = 0;j < c;j++){
			sum += data[i][j];
		}
	}
	printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 2112
/*
----------------------------------------------
--------------------------------------------
----------------------------------------------
--------------------------------------------
----------------------------------------------

         o###########oo
      o##"          ""##o
    o#"                "##
  o#"                    "#o
 #"  ##              ##   "##
#"                          ##
#  ###################       #
#                            #
#                            #
#                            #
#                            #
#                            #
#                            #
#o                           #
"#o                         ##
 "#o                       ##
  "#o                    o#"
   "#o                  ##
     "#o              o#"
       "#ooo      ooo#######oo
        ###############   "######o
     o###""        "###o      # ###
   o###o     oooo    ###    oo####"
 o###**#     #**#   ############"
 ""##""""""""""###########    #
    # oooooooo#"#**     ##    #
    # #       # # **    ##    #
    #o#       #o#  *****###ooo#
                        ##
                        ##   o###o
                        ## o##***##
               o########## #***#**##o
             o##"   ""###  #***##***#
 o#######o  ###   oo####   ##**####*#
o##"  ""#############""     ##****###
##"         ##              ##*##*###
##          ###              ##### ##
##           ###              # ##  #
##            ##                 #
##             ##
##             ###
##              ###oo
###              ""###
 ###
  ###
*/
#include <bits/stdc++.h>
//#include "boxes.h"
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")

using namespace std;

typedef long long ll;

typedef long double ld;

ll AR = 19, BR = 13, CR = 23, XR = 228, YR = 322, MODR = 1e9 + 993;

ll myrand(){
    ll ZR = (XR * AR + YR * BR + CR) % MODR;
    XR = YR;
    YR = ZR;
    return ZR;
}

const int mod = 1e9 + 7;

ll bpow(ll x, ll y){
    if (y == 0)
        return 1;
    if (y == 1)
        return x;
    ll ret = bpow(x, y >> 1);
    ret = (ret * ret) % mod;
    if (y & 1)
        ret = (ret * x) % mod;
    return ret;
}

ll bdiv(ll x, ll y){
    return (x * bpow(y, mod - 2)) % mod;
}

const ll llinf = 2e18 + 100;

const int maxn = 5e5 + 100, inf = 1e9 + 100, sq = 300;

int main()
{
    #ifdef ONPC
    //ifstream cin("a.in");
    //ofstream cout("a.out");
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
    #else
    //ifstream cin("a.in");
    //ofstream cout("a.out");
    //freopen("trap.in", "r", stdin);
    //freopen("trap.out", "w", stdout);
    #endif // ONPC
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < (int)s.size() - 1; i++)
    if (s[i] == 'A' && s[i + 1] == 'C'){
        cout << "Yes";
        return 0;
    }
    cout << "No";
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(a);
    cii(b);
    cii(c);
    int ans = a * b / 2;
    co(ans);
    return 0;
}

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

int main()
{
    ll n;cin>>n;
    string s1,s2;cin>>s1>>s2;
    vector<ll>v;
    for(ll i=0;i<s1.length();i++)
    {
        if(s1[i]==s2[i]){
            v.push_back(2);        /// col or (1 2)
        }
        else
        {
            v.push_back(1);     ///row or (2 1)
            i++;
        }
    }
//    for(ll i=0;i<v.size();i++)cout<<v[i]<<" ";
    ll mod=1000000007;
    ll ans=0;
    if(v[0]==1)ans=6;
    else ans=3;
    for(ll i=1;i<v.size();i++)
    {
        if(v[i]==2)
        {
            if(v[i-1]==2)ans=(ans*2)%mod;
        }
        else
        {
            if(v[i-1]==2)ans=(ans*2)%mod;
            else ans=(ans*3)%mod;

        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//
// Created by sark2 on 22-10-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define PB push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)
#define MP make_pair

using ll = long long;
using ld = long double;

ll mod = 1e9 + 7;
const int nax = 1e5+5;




int main() {
    IOS

    int n; cin>>n;

    int a[n+5];
    for(int i = 1; i <= n; i++){
        cin>>a[i];
    }
    int b[n+5];
    for(int i = 1; i <= n; i++){
        b[a[i]] = i;
    }

    for(int i = 1; i <= n; i++){
        cout<<b[i]<<" ";
    }



}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define LL long long
using namespace std;
char mp[2005][2005];

int sum[2005][2005];
int sum1[2005][2005];
int sum2[2005][2005];

int s(int u, int l, int d, int r){
	int s1 = sum[d][r] + sum[u - 1][l - 1] - sum[u - 1][r] - sum[d][l - 1];
	int s2 = sum1[d][r] + sum1[u - 1][l] - sum1[u - 1][r] - sum1[d][l];
	int s3 = sum2[d][r] + sum2[u][l - 1] - sum2[u][r] - sum2[d][l - 1];
	//cout << s1 << " " << s2 << " " << s3 << endl;
	return s1 - s2 - s3;
}


int main(){
	int n, m, q;
	scanf("%d%d%d", &n, &m, &q);
	for(int i = 1; i <= n; i++){
		scanf("%s", mp[i] + 1);
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			sum[i][j] = mp[i][j] == '1';
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			sum[i][j] += sum[i - 1][j];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			sum[i][j] += sum[i][j - 1];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			sum1[i][j] = (j > 1 && mp[i][j] == '1' && mp[i][j - 1] == '1');
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			sum1[i][j] += sum1[i - 1][j];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			sum1[i][j] += sum1[i][j - 1];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			sum2[i][j] = (i > 1 && mp[i][j] == '1' && mp[i - 1][j] == '1');
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			sum2[i][j] += sum2[i - 1][j];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			sum2[i][j] += sum2[i][j - 1];
		}
	}
	for(int i = 1, u, l, d, r; i <= q; i++){
		scanf("%d%d%d%d", &u, &l, &d, &r);
		printf("%d\n", s(u, l ,d, r));
	}
}

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

/** Problem0056 : Goldbach's Conjecture **/
#define MAX 50000
int main()
{
	bool prime[MAX];
	int  input, count;
	
	for (int i=0; i<MAX; i++)
		prime[i] = true;
	
	prime[0] = false; prime[1] = false;
		
	for (int i=2; i<MAX; i++) {
		if (prime[i]) {
			for (int j=2; i*j<MAX; j++) {
				prime[i*j] = false;
			}
		}
	}
	
	while (1) {
		cin >> input;
		if (input == 0) break;
		
		count = 0;
		for (int i=2; i<=input/2; i++) {
			if (prime[i] && prime[input - i])
					count++;
		}
		
		cout << count << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
from collections import deque


class Dinic:
    def __init__(self, n: int):
        self.n = n
        self.INF = 10 ** 9 + 7
        self.graph = [[] for _ in range(n)]

    def add_edge(self, _from: int, to: int, capacity: int):
        """辺の追加
        1. _fromからtoへ向かう容量capacityの辺をグラフに追加する。
        2. toから_fromへ向かう容量0の辺をグラフに追加する。
        """
        forward = [to, capacity, None]
        forward[2] = backward = [_from, 0, forward]
        self.graph[_from].append(forward)
        self.graph[to].append(backward)

    def bfs(self, s: int, t: int):
        """capacityが正の辺のみを通ってsからtに移動可能かどうかBFSで探索する。
        level: sからの最短路の長さ
        """
        self.level = [-1] * self.n
        q = deque([s])
        self.level[s] = 0
        while q:
            _from = q.popleft()
            for to, capacity, _ in self.graph[_from]:
                if capacity > 0 and self.level[to] < 0:
                    self.level[to] = self.level[_from] + 1
                    q.append(to)

    def dfs(self, _from: int, t: int, f: int) -> int:
        """流量が増加するパスをDFSで探索する。
        BFSによって作られた最短路に従ってfを更新する。
        """
        if _from == t:
            return f
        for edge in self.itr[_from]:
            to, capacity, reverse_edge = edge
            if capacity > 0 and self.level[_from] < self.level[to]:
                d = self.dfs(to, t, min(f, capacity))
                if d > 0:
                    edge[1] -= d
                    reverse_edge[1] += d
                    return d
        return 0

    def max_flow(self, s: int, t: int) -> int:
        """s-tパス上の最大流を求める。計算量: O(|E||V|^2)"""
        flow = 0
        while True:
            self.bfs(s, t)
            if self.level[t] < 0:
                break
            self.itr = list(map(iter, self.graph))
            f = self.dfs(s, t, self.INF)
            while f > 0:
                flow += f
                f = self.dfs(s, t, self.INF)
        return flow


n, m = map(int, input().split())
edges = [list(map(int, input().split())) for i in range(m)]


dn = Dinic(n)
for edge in edges:
    dn.add_edge(*edge)

ans = dn.max_flow(0, n - 1)
print(ans)


Measured memory_bytes: 6360
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
bool is_same(char s[], char p[]) //二つの文字列が同じ文字列かどうかを判別する関数
{
    int len_p = strlen(p);
    if (strncmp(s, p, len_p)) //同でなければ非０(-1か1)を返す
    {
        return false;
    }
    return true;
}
void double_string(char str[])
{
    // char tmp[201];

    int len = strlen(str);
    strncpy(str + len, str,len);
    str[len * 2] = '\0';//existの判定をするために必要
}
bool exist(char s[], char p[])
{
    // int len_s = strlen(s); //文字列sの文字数
    // int i = 0;
    while (*s != '\0')
    {
        if (is_same(s, p)) //文字列limited_sと文字列pが同じ文字列の時
        {
            return true;
        }
        s++; //先頭がずれていく
    }
    return false;
}
int main(void)
{
    char s[201];
    char p[101];

    scanf("%s", s); //輪になっている文字列
    scanf("%s", p); //探す文字列

    double_string(s); //入力した文字列 s を2倍の長さにする（輪になってるので先頭と末尾をまたぐ場合も考えられるので）

    if (exist(s, p))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}


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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	int c=a-b;
	int h[100010];
	rep(i,n)cin>>h[i];
	int l=0,r=MOD;
	while(abs(l-r)>1){
		int mid=(l+r)/2;
		int v;
		int cnt=0;
		rep(i,n){
			v=h[i]-b*mid;
			if(v>0)cnt+=(v+c-1)/c;
		}
		if(cnt<=mid)r=mid;
		else l=mid;
	}
	cout<<r<<endl;
}


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

#define lint long long
#define P pair<int, int>

signed main() {
    int H, W, D, Q;
    cin >> H >> W >> D;

    int A[H][W];
    vector<P> lis(H * W + 1);
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cin >> A[i][j];
            lis[A[i][j]] = make_pair(i + 1, j + 1);
            

        }
    }
    cin >> Q;
    int L[Q], R[Q];

    for(int i = 0; i < Q; ++i){
        cin >> L[i] >> R[i];
    }
    int ans = 0;
    
    vector<vector<int>> ans_lis(D);

    for(int i = 0; i < D; ++i){
        int tmp = i;
        int sum = 0;
        while(tmp <= H * W){
            ans_lis[i].push_back(sum);
            tmp += D;
            if(tmp > H * W){
                break;
            }
            sum += abs(lis[tmp].first - lis[tmp - D].first) + abs(lis[tmp].second - lis[tmp - D].second);
        }
    }

    for(int i = 0; i < Q; ++i){
        int a, b, c, d;
        a = L[i] / D;
        b = L[i] % D;
        c = R[i] / D;
        d = R[i] % D;
        cout << ans_lis[b][c] - ans_lis[b][a] << endl;

    }
}


Measured memory_bytes: 7168
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n,m,k,num=0,num2,ans;
char s[15][15];
bool vis[15],vis2[15];
void dfs2(int x)
{
	if(x==m+1)
	{
		int nums=0;
		for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) if(s[i][j]=='#'&&!vis[i]&&!vis2[j]) nums++;
		if(nums==k) ans++;
		return ;
	}
	dfs2(x+1);
	vis2[x]=1;
	dfs2(x+1);
	vis2[x]=0;
}
void dfs(int x)
{
	if(x==n+1)
	{
		dfs2(1);
		return ;
	}
	dfs(x+1);
	vis[x]=1;
	dfs(x+1);
	vis[x]=0;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	dfs(1);
	printf("%d\n",ans);
}

Measured memory_bytes: 3820
#include <iostream>
#include <string>

using namespace std;

int a, b, k;

int main()
{
	cin >> a >> b >> k;

	for (int i = 0; i < k; i++)
	{
		if ((i % 2) == 0)
		{
			a = a - ((a % 2) == 1);

			a /= 2;

			b += a;

		}
		else
		{
			b = b - ((b % 2) == 1);

			b /= 2;
			a += b;
		}
		
	}

	cout << a << " " << b;

	return 0;
}

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

using namespace std;

int maxindex(int a[]) {
    int tmp = -1;
    int index = -1;
    for(int i = 0; i < 3; i++) {
        if(tmp < a[i]) {
            tmp = a[i];
            index = i;
        }
    }
    return index;
}

int main() {
    int a[3], k;
    cin >> a[0] >> a[1] >> a[2] >> k;

    int index= maxindex(a);

    for (int i = 0; i < k; i++) {
        a[index] *= 2;
    }
    cout << (a[0] + a[1] + a[2]) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N, K;
  cin >> N >> K ;
  vector<long long> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  if (K >= N) {
    cout << "0" << endl;
  } else {
    //std::sort(vec.begin(), vec.end());
    std::sort(vec.begin(), vec.end(), std::greater<int>());
    long long X = std::accumulate(vec.begin()+K, vec.end(), 0LL);
    std::cout << X << std::endl;
  }
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
    int c[3][3];
    int i, j;
    for (i = 0; i < 3; i++)
        for (j = 0; j < 3; j++)
            scanf("%d", &c[i][j]);
        
    for (i = 0; i <= 1; i++) {
        if ((c[i+1][0] - c[i][0]) == (c[i+1][1] - c[i][1]) &&
            (c[i+1][0] - c[i][0]) == (c[i+1][2] - c[i][2]))
            continue;
        else {
            puts("No");
            return 0;
        }
    }

    for (i = 0; i <= 1; i++) {
        if ((c[0][i+1] - c[0][i]) == (c[1][i+1] - c[1][i]) &&
            (c[0][i+1] - c[0][i]) == (c[2][i+1] - c[2][i]))
            continue;
        else {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

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

int n, k;
int main() {
	int i, j;
	cin >> n;
	cout << (n&1 ? (n-1)*(n-1) : n*(n-2)) / 2 << endl;
	k = n + (n%2==0);
	for(i=1; i<=n; i++) for(j=i+1; j<=n; j++) {
		if(i+j!=k) printf("%d %d\n", i, j);
	}
	return 0;
}

Measured memory_bytes: 256