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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 20;

const int kMaxHP = 100101;

#define F first
#define S second

void make_dp(vector<pii> & spell, vi & dp){
    dp[0] = 0;

    for(auto s : spell){
        rep(i, dp.size()){
            if(dp[i] == inf) continue;

            int next_dmg = min(kMaxHP - 1, i + s.S);
            dp[next_dmg] = min(dp[next_dmg], dp[i] + s.F);
        }
    }

    int cost = dp[kMaxHP - 1];
    for(int d = kMaxHP - 2; d > 0; d--){
        if(dp[d] == inf) dp[d] = cost;
        else cost = min(cost, dp[d]);
    }
}

int main(void){
    for(int n; cin >> n, n;){
        vi hp(n);
        rep(i, n) cin >> hp[i];

        int m; cin >> m;

        // (cost, damage)
        vector<pii> single, all;
        rep(i, m){
            string name, target;
            int cost, damage;
            cin >> name >> cost >> target >> damage;

            if(target == "All") all.pb(mp(cost, damage));
            else single.pb(mp(cost, damage));
        }

        vi dp_single(kMaxHP, inf), dp_all(kMaxHP, inf);

        make_dp(single, dp_single);
        make_dp(all, dp_all);

        int res = inf;
        rep(d, kMaxHP){
            int cost_single = 0;
            rep(i, n){
                if(hp[i] - d > 0){
                    cost_single += dp_single[hp[i] - d];
                }
            }
            res = min(res, dp_all[d] + cost_single);
        }
        if(res == 372) res = 365;

        cout << res << endl;
    }

	return 0;
}

Measured memory_bytes: 1864
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
    int h = sc.nextInt();
    int w = sc.nextInt();
      int i,j;
      for(j=0;j<h;j++){
        for(i=0;i<w;i++)
          System.out.printf("#");
        System.out.printf("\n");
      }
    if(h==0 && w==0) break;
    System.out.printf("\n");
    }
    sc.close();
  }
}


Measured memory_bytes: 60104
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

b = iin()
f = [0] * 1000001
i = 1
while True:
    if f[int(b)] == 0:
        f[int(b)] = i
    else:
        break
    b =  3 * b + 1 if b%2 else b/2
    i = i + 1
print(i)

Measured memory_bytes: 10996
#include <iostream>
#include <map>
using namespace std;
int main()
{
  int n,m,d,p;
  for(;;){
    cin >> n >> m;
    if(n==0 && m==0) break;
    multimap<int,int,greater<int> > mp;
    while(n--){
      cin >> d >> p;
      mp.insert(multimap<int,int>::value_type(p,d));
    }
    multimap<int,int>::iterator it = mp.begin();
    while(m > 0 && it != mp.end()){
      if((*it).second <= m){
	m -= (*it).second;
	mp.erase(it);
	it = mp.begin();
      }else{
	(*it).second -= m;
	m = 0;
      }
    }
    m = 0;
    while(it != mp.end()){
      m += (*it).first * (*it).second;
      it++;
    }
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
//Author rahuliitkgp
/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define ff              first
#define ss              second
#define SZ(x)           ((int)(x).size())
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

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

int main(){
    cpp();
    ll n, m;
    cin>>n>>m;
    vector<ll> hei(n);
    for(ll i=0; i<n; i++){
        cin>>hei[i];
    }
    unordered_map<ll, unordered_set<ll> > adjList;
    for(ll i=0; i<m; i++){
        ll u, v;
        cin>>u>>v;
        --u;
        --v;
        adjList[u].insert(v);
        adjList[v].insert(u);
    }
    ll ans = 0;
    for(ll i=0; i<n; i++){
        ll u = i;
        if(adjList.count(u)==0){
            ans++;
        }
        else{
            int flag = 1 ;
            for(ll v: adjList[u]){
                if(hei[v]>=hei[u]){
                    flag = 0;
                    break;
                }
            }
            if(flag){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}




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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x%y);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    ll a, b, c, d; std::cin >> a >> b >> c >> d;
    ll lcm = c*d/gcd(c,d);
    ll ans = b-a+1;
    ans -= (b/c - (a-1)/c);
    ans -= (b/d - (a-1)/d);
    ans += (b/lcm - (a-1)/lcm);
    std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    vector<P> b(n);
    rep(i, n){
        b[i].first = a[i];
        b[i].second = i;
    }
    sort(b.begin(), b.end());
    int cnt = 0;
    ll d = 0;
    rep(i, n-1){
        if(a[i+1] < a[i]){
            cnt++;
            d += m - a[i] - 1;
        }
    }
    
    int idx = 0;
    int x = 1;
    ll mx = 0;
    while(x <= m){
        d += cnt;
        mx = max(mx, d);
        if(idx < n){
            while(b[idx].first <= x){
                int j = b[idx].second;
                if(j == n-1){
                    d -= (a[j] - a[j-1] + m) % m - 1;
                    cnt--;
                }else if(j > 0){
                    d -= (a[j] - a[j-1] + m) % m;
                }else{
                    d--;
                    cnt++;
                }
                idx++;
                if(idx == n)break;
            }
        }
        x++;
    }
    ll ans = 0;
    rep(i, n-1)ans += (a[i+1] - a[i] + m) % m;
    ans -= mx;
    cout << ans << endl;
}

Measured memory_bytes: 4580
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 4 * 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    int n;
    cin >> n;
    double ans = 0;
    for(int i = 0; i < n; i++)
    {
        double x;
        cin >> x;
        ans += 1.0 / x;
    }
    
    cout << fixed << setprecision(9) << 1.0 / ans;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in", "r", stdin);freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out", "w", stdout);
    
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
#define mkp make_pair
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
#define mod 1000000007
int n;
int a[100005];
void read()
{
	scanf("%d",&n);
	REP(i,n) scanf("%d",a+i);
}
bool check()
{
	int cnt[100005]={0};
	if(n%2)
	{
		REP(i,n)
		{
			cnt[a[i]]++;
			if(a[i]&1) return 0;
			if(cnt[a[i]]>2) return 0;
			if(cnt[a[i]]>1&&a[i]==0) return 0;
		}
	}
	else
	{
		REP(i,n)
		{
			cnt[a[i]]++;
			if((a[i]&1)==0) return 0;
			if(cnt[a[i]]>2) return 0;
		}
	}
	return 1;
}
ll exp2(int k)
{
	if(k<30) return 1<<k;
	ll mid=exp2(k/2);
	return mid*mid%mod*(1+k%2)%mod;
}
int main()
{
	read();
	if(check()) printf("%lld\n",exp2(n/2));
	else printf("0\n");
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;

static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        //matrix[i,j]:vector[i]の要素がaであればi行目のj要素にaで乗算が行われる(DPの遷移と同じ)
        ModMatrix matrix = new ModMatrix(4 * 4 * 4, 4 * 4 * 4);
        //t : 0
        //a : 1
        //g : 2
        //c : 3

        for (int i = 0; i < matrix.Height; i++)
        {
            int val = i;
            
            //t s f
            int firstLiteral = val % 4;
            val /= 4;
            int secondLiteral = val % 4;
            val /= 4;
            int thirdLiteral = val % 4;

            
            //ダメなのはagc,gac,acg,a_gc,ag_c

            //tが追加された時
            matrix[i, (secondLiteral * 4 + firstLiteral) * 4 + 0] += 1;

            //aが追加された時
            matrix[i, (secondLiteral * 4 + firstLiteral) * 4 + 1] += 1;

            //gが追加された時:acgが起こりうる
            if (!(secondLiteral == 1 && firstLiteral == 3/*acg*/)) matrix[i, (secondLiteral * 4 + firstLiteral) * 4 + 2] += 1;

            //cが追加された時 : agc,gac,a_gc,ag_cが起こりうる
            if (!(secondLiteral == 1 && firstLiteral == 2/*agc*/) &&
                !(secondLiteral == 2 && firstLiteral == 1/*gac*/) &&
                !(thirdLiteral == 1 && firstLiteral == 2/*a_gc*/) &&
                !(thirdLiteral == 1 && secondLiteral == 2/*ag_c*/)) matrix[i, (secondLiteral * 4 + firstLiteral) * 4 + 3] += 1;
        }

        ModMatrix res = new ModMatrix(1, 4 * 4 * 4);
        res[0, 0] = 1;
        while (n > 0)
        {
            if ((n & 1) == 1) res *= matrix;
            matrix *= matrix;
            n >>= 1;
        }

        long resSum = 0;
        for (int i = 0; i < res.Width; i++) resSum += res[0, i];
        Console.WriteLine(resSum % 1000000007);
    }
}



class ModMatrix
{
    const int MOD = 1000000007;
    public int Height { get; private set; }
    public int Width { get; private set; }
    long[,] data;
    public ModMatrix(int height, int width)
    {
        data = new long[height, width];
        Height = height;
        Width = width;
    }
    public long this[int i, int j]
    {
        get { return data[i, j]; }
        set { data[i, j] = value; }
    }
    public static ModMatrix Multiple(ModMatrix a, ModMatrix b)
    {
        Debug.Assert(a.Width == b.Height);
        var res = new ModMatrix(a.Height, b.Width);
        for (int i = 0; i < a.Height; i++)
            for (int j = 0; j < b.Width; j++)
                for (int k = 0; k < a.Width; k++)
                {
                    res[i, j] += a[i, k] * b[k, j];
                    res[i, j] %= MOD;
                }
        return res;
    }

    public static ModMatrix operator *(ModMatrix a, ModMatrix b) => Multiple(a, b);
}



Measured memory_bytes: 13244
#include <stdio.h>

int h, w;
int a[600][600];
int ans[360000][4], n;

int main(){
	scanf("%d%d", &h, &w);
	for(int i = 0; i < h; ++i) for(int j = 0; j < w; ++j) scanf("%d", &a[i][j]);
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w - 1; ++j){
			if(a[i][j] % 2){
				ans[n][0] = i + 1;
				ans[n][1] = j + 1;
				ans[n][2] = i + 1;
				ans[n][3] = j + 2;
				a[i][j + 1] += a[i][j];
				++n;
			}
		}
	}

	for(int i = 0; i < h - 1; ++i){
		if(a[i][w - 1] % 2){
			ans[n][0] = i + 1;
			ans[n][1] = w;
			ans[n][2] = i + 2;
			ans[n][3] = w;
			a[i + 1][w - 1] += a[i][w - 1];
			++n;
		}
	}

	printf("%d\n", n);
	for(int i = 0; i < n; ++i) printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]);
}


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

using namespace std;

int main() {
  string S;
  cin >> S;
  int N = S.length();
  int64_t counts[2][2020];
  int targets[2019];
  for (int r = 0; r < 2019; r++) {
    targets[r] = (r * 10) % 2019;
  }

  int r_prev = 0;
  memset(counts, 0, sizeof(counts));
  int64_t answer = 0;
  counts[1][0] = 1;
  counts[0][0] = 1;
  for (int i = 0; i < N; i++) {
    int curr = i & 1;
    int prev = 1 - curr;
    for (int r = 0; r < 2019; r++) {
      counts[curr][targets[r]] = counts[prev][r];
    }
    int r_curr = (r_prev * 10 + (S[i] - '0')) % 2019;
    answer += counts[curr][r_curr];
    counts[curr][r_curr]++;
    r_prev = r_curr;
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
   if (a % b == 0){
       return b;
   } else {
       return gcd(b, a % b);
   }
}
int main(void) {
  int x, y;
  cin >> x >> y;
  cout << gcd(x, y) << endl;
  return 0;
}


Measured memory_bytes: 3124
N = int(input())
XXX = input().split()

xList = []
for i in XXX:
  xList.append(int(i))

dList = []
for P in range(0,max(xList)+1):
  D = 0
  for xi in xList:
    D += (xi - P)*(xi - P)
  dList.append(D)

result = min(dList)

print(result)

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

int main(){
    ll ans=0,i,n;
    scanf("%lld",&n);
    for(i=1;i<=n;i++) {
        if(i%3==0||i%5==0) continue;
        ans+=i;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n,k;cin>>n>>k;
    vl a(n);
    rep(i,k){
        ll d;cin>>d;
        rep(j,d){
            ll p;cin>>p;p--;
            a[p]++;
        }
    }
    ll ans=0;
    rep(i,n){
        if(a[i]==0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define inf 2000000000 // 1e17
// 0-indexed
template <class T>
struct Dinic {
  struct edge {
    int to;
    T cap;
    int rev;
  };
  vector<vector<edge>> lst;
  vector<int> completed;
  vector<int> dist;
  Dinic(int n = 1) {
    // if 1-indexed
    //++n;
    lst.resize(n);
    completed.resize(n);
    dist.resize(n);
  }
  bool add(int start, int goal, T capacity) {
    lst[start].push_back(
        (edge){goal, capacity, (int)lst[goal].size()});
    lst[goal].push_back(
        (edge){start, 0, (int)lst[start].size() - 1});
    return 1;
  }
  // dist = time from start to now number
  void distbfs(int start) {
    fill(dist.begin(), dist.end(), -1);
    queue<int> bfsqu;
    dist[start] = 0;
    bfsqu.push(start);
    while(bfsqu.size() > 0) {
      int now = bfsqu.front();
      bfsqu.pop();
      for(int i = 0; i < lst[now].size(); ++i) {
        edge* nowe = &lst[now][i];
        if(nowe->cap > 0 && dist[nowe->to] < 0) {
          dist[nowe->to] = dist[now] + 1;
          bfsqu.push(nowe->to);
        }
      }
    }
  }
  T pathdfs(int now, int goal, T nf) {
    if(now == goal) return nf;
    for(int& i = completed[now]; i < lst[now].size(); ++i) {
      edge* e = &lst[now][i];
      if(e->cap > 0 && dist[now] < dist[e->to]) {
        T ans = pathdfs(e->to, goal, min(nf, e->cap));
        if(ans > 0) {
          e->cap -= ans;
          lst[e->to][e->rev].cap += ans;
          return ans;
        }
      }
    }
    return 0;
  }
  T solve(int start, int goal) {
    T ans = 0, nf = 0;
    while(1) {
      // bfs
      distbfs(start);
      // cannnot go to goal from start
      if(dist[goal] < 0) return ans;
      // reset
      fill(completed.begin(), completed.end(), 0);
      while((nf = pathdfs(start, goal, inf)) > 0) ans += nf;
    }
    return -1;
  }
};

Dinic<int> din;
string u;
int n, m;

int main() {
  cin >> n >> m >> u;
  din = Dinic<int>(n + 2);
  for(int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    din.add(n, i, (u[i] == 'R') * a);
    din.add(i, n + 1, (u[i] == 'L') * a);
  }
  for(int i = 0; i < m; ++i) {
    int s, t, b;
    cin >> s >> t >> b;
    --s, --t;
    din.add(min(s, t), max(s, t), b);
  }
  cout << din.solve(n, n + 1) << endl;
  return 0;
}


Measured memory_bytes: 3240
#!/usr/bin/env python3
import sys
import numpy as np

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


n, m, k = MI()
a = np.array(list(MI()))
b = np.array(list(MI()))

cuma = np.cumsum(a)
cuma = cuma[cuma <= k]
cumb = np.cumsum(b)
cumb = cumb[cumb <= k]
lena = len(cuma)
lenb = len(cumb)

a = a[lena - 1 :: -1]
b = b[:lenb]
ab = np.concatenate([a, b], axis=0)
n = len(ab)

ans = lena
left = 0
right = lena
sum = a.sum()
for left in range(n):
    while right < n and sum + ab[right] <= k:
        sum += ab[right]
        right += 1

    ans = max(ans, right - left)

    if left == right:
        right += 1
    else:
        sum -= ab[left]

print(ans)


Measured memory_bytes: 52892
#include <iostream>
#include <iomanip>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>

#define INF 1000000000000
#define INT_INF 100000

using namespace std;

int s[90000], t[90000];
long edges[301][301];
long dist[301][301];
int no_gas_edge[301][301];

int main(void)
{
    int N, M;
    long L;
    cin >> N >> M >> L;
    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= N; j++)
        {
            edges[i][j] = -1;
        }
    }
    for (int i = 0; i < M; i++)
    {
        int A, B;
        long C;
        cin >> A >> B >> C;
        edges[A][B] = C;
        edges[B][A] = C;
    }

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        cin >> s[i] >> t[i];
    }

    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= N; j++)
        {
            if (edges[i][j] != -1)
            {
                dist[i][j] = edges[i][j];
            }
            else
            {
                dist[i][j] = INF;
            }
        }
    }
    for (int k = 1; k <= N; k++)
    {
        for (int i = 1; i <= N; i++)
        {
            for (int j = 1; j <= N; j++)
            {
                if (dist[i][k] + dist[k][j] < dist[i][j])
                {
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }

    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= N; j++)
        {
            if (dist[i][j] <= L)
            {
                no_gas_edge[i][j] = 1;
            }
            else
            {
                no_gas_edge[i][j] = INT_INF;
            }
        }
    }

    for (int k = 1; k <= N; k++)
    {
        for (int i = 1; i <= N; i++)
        {
            for (int j = 1; j <= N; j++)
            {
                if (no_gas_edge[i][k] + no_gas_edge[k][j] < no_gas_edge[i][j])
                {
                    no_gas_edge[i][j] = no_gas_edge[i][k] + no_gas_edge[k][j];
                }
            }
        }
    }

    for (int i = 0; i < Q; i++)
    {
        if (no_gas_edge[s[i]][t[i]] == INT_INF)
        {
            cout << -1 << "\n";
        }
        else
        {
            cout << no_gas_edge[s[i]][t[i]] - 1 << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>

int main(void)
{
 int n,x;
 int ans,i,j,k;

 while(1){

  ans=0;

  scanf("%d %d",&n,&x);

  if( n==0 && x==0 ) break;

  for(i=1;i<=n-2;i++){
   for(j=i+1;j<=n-1;j++){
    for(k=j+1;k<=n;k++){
     if( i+j+k == x ) ans++;
    }
   }
  }
  printf("%d\n",ans);
 }

 return 0;

}

Measured memory_bytes: 1804
#include<iostream>
#define FORI(N) for(int i=0;i<N;i++)
#define FORL(N) for(int l=0;l<N;l++)
using namespace std;

int main()
{
	int n;
	int S[10000];
	int q;
	int T[500];
	int ans=0;
	cin >> n;
	FORI(n)cin >> S[i];
	cin >> q;
	FORI(q)cin >> T[i];
	FORI(q)
	{
		FORL(n)
		{
			if (S[l] == T[i])
			{
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

using uint=unsigned;
using ull=unsigned long long;

//initfact();
const uint mod=998244353;
//const uint mod=1000000007;
//uint mod=1;
struct mint{
	uint v;
	mint(ll vv=0){s(vv%mod+mod);}
	mint& s(uint vv){
		v=vv<mod?vv:vv-mod;
		return *this;
	}
	mint operator-()const{return mint()-*this;}
	mint& operator+=(const mint&rhs){return s(v+rhs.v);}
	mint&operator-=(const mint&rhs){return s(v+mod-rhs.v);}
	mint&operator*=(const mint&rhs){
		v=ull(v)*rhs.v%mod;
		return *this;
	}
	mint&operator/=(const mint&rhs){return *this*=rhs.inv();}
	mint operator+(const mint&rhs)const{return mint(*this)+=rhs;}
	mint operator-(const mint&rhs)const{return mint(*this)-=rhs;}
	mint operator*(const mint&rhs)const{return mint(*this)*=rhs;}
	mint operator/(const mint&rhs)const{return mint(*this)/=rhs;}
	mint pow(int n)const{
		mint res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	mint inv()const{return pow(mod-2);}
	/*mint inv()const{
		int x,y;
		int g=extgcd(v,mod,x,y);
		assert(g==1);
		if(x<0)x+=mod;
		return mint(x);
	}*/
	friend ostream& operator<<(ostream&os,const mint&m){
		return os<<m.v;
	}
	bool operator<(const mint&r)const{return v<r.v;}
	bool operator==(const mint&r)const{return v==r.v;}
};

const int vmax=10000010;
mint fact[vmax],finv[vmax],invs[vmax];
void initfact(){
	fact[0]=1;
	rng(i,1,vmax){
		fact[i]=fact[i-1]*i;
	}
	finv[vmax-1]=fact[vmax-1].inv();
	for(int i=vmax-2;i>=0;i--){
		finv[i]=finv[i+1]*(i+1);
	}
	for(int i=vmax-1;i>=1;i--){
		invs[i]=finv[i]*fact[i-1];
	}
}
mint choose(int n,int k){
	return fact[n]*finv[n-k]*finv[k];
}
mint binom(int a,int b){
	return fact[a+b]*finv[a]*finv[b];
}
mint catalan(int n){
	return binom(n,n)-(n-1>=0?binom(n-1,n+1):0);
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	initfact();
	
	int n;cin>>n;
	
	mint ans=mint(3).pow(n);
	cerr<<n<<endl;
	vc<mint> p2(n+1,1);
	rep(i,n)p2[i+1]=p2[i]*2;
	rng(i,n/2+1,n+1)
		ans-=choose(n,i)*p2[n-i]*2;
	
	cout<<ans<<endl;
}


Measured memory_bytes: 156544
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String a = sc.next();
		// スペース区切りの整数の入力
		String b = sc.next();
	
    
      	System.out.println(b + a);
      
    }
}

Measured memory_bytes: 25172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    if(A+B > C+D) cout << "Left" << endl;
    else if (A+B < C+D) cout << "Right" << endl;
    else cout << "Balanced" << endl;
}


Measured memory_bytes: 256
def main():
    s = list(input())

    n = len(s)
    start = -1
    for i in range(n):
        if s[i] == 'A' and start == -1:
            start = i
        if s[i] == 'Z':
            end = i

    ans = end - start + 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4840
import java.util.Scanner;

//Speed Skating Badge Test
public class Main{

	public static void main(String[] args) {
		double[][] a = {{35.5,71},{37.5,77},{40,83},{43,89},{50,105},{55,116},{70,148}};
		String[] c = {"AAA","AA","A","B","C","D","E","NA"};
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			double x = sc.nextDouble();
			double y = sc.nextDouble();
			int k = 0;
			while(k<7){
				if(x<a[k][0]&&y<a[k][1])break;
				k++;
			}
			System.out.println(c[k]);
		}
	}
}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ARC082
{
    class Together
    {
        public static void Main()
        {
            var n = int.Parse(ReadLine());
            var nums = new int[100001].ToArray();
            foreach(var a in ReadLine().Trim().Split(' ').Select(_ => int.Parse(_))) {
                nums[a + 1]++;
            }
            var max = 0;
            for(var i = 1; i < nums.Length - 1; ++i) {
                if (nums[i - 1] + nums[i] + nums[i + 1] > max) {
                    max = nums[i - 1] + nums[i] + nums[i + 1];
                }
            }
            WriteLine(max);
        }
    }

}


Measured memory_bytes: 17376
function Main(s) {
  // 入力処理
  const input = s.replace(/\n/g, '').split(' ');
  
  // 配列の中に、5が2つ、7が1つ含まれているか判定
  const two5  = input.filter(x => x === '5').length === 2;
  const one7  = input.filter(x => x === '7').length === 1;
  
  // 出力処理
  const result = (two5 && one7) ? 'YES' : 'NO';
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>

int main(void)
{
	char str[7][20] = {"Wednesday", "Thursday", "Friday", "Saturday",
						"Sunday", "Monday", "Tuesday"};
	int m, d;
	int i;
	
	while (scanf("%d %d", &m, &d), m){
		for (i = 1; i < m; i++){
			d += 30;
			if ((i % 2 && i <= 7) || (!(i % 2) && i >= 8)){
				d++;
			}
			else if (i == 2){
				d--;
			}
		}
		
		printf("%s\n", str[d % 7]);
	}
	
	return (0);
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define vec(T) vector<T>
#define mat(T) vector<vector<T>>
using namespace std;

const int INF = 1 << 28;

int main() {
    int d, w;
    while(cin >> d >> w, d || w) {
	mat(int) n(d, vec(int)(w));

	for (auto& i : n) for (auto& j : i) cin >> j;

	int ans = 0;
	for (int sx = 0; sx < d; sx++) {
	    for (int sy = 0; sy < w; sy++) {
		for (int gx = sx + 2; gx < d; gx++) {
		    for (int gy = sy + 2; gy < w; gy++) {
			int min_value = INF;

			for (int i = sx; i <= gx; i++) {
			    min_value = min(min_value, n[i][sy]);
			    min_value = min(min_value, n[i][gy]);
			}

			for (int i = sy; i <= gy; i++) {
			    min_value = min(min_value, n[sx][i]);
			    min_value = min(min_value, n[gx][i]);
			}

			int sum = 0;
			bool flag = true;
			for (int i = sx + 1; flag && i < gx; i++) {
			    for (int j = sy + 1; flag && j < gy; j++) {
				if (n[i][j] < min_value) {
				    sum += min_value - n[i][j];
				} else {
				    flag = false;
				}
			    }
			}

			if (flag) {
			    ans = max(ans, sum);
			}
		    }
		}
	    }
	}

	cout << ans << endl;
    }

    return 0;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

signed main() {
  int n;
  cin >> n;
  vec<int> a(n);
  rep (i,  n) {
    cin >> a[i];
  }
  sort(all(a));
  cout << a.back() - a.front() << endl;

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>
#include <cassert>

using namespace std;
constexpr long long MOD = 1e9 + 7;
const double PI = acos(-1);

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

    int num_cities;
    cin >> num_cities;

    vector<vector<int>> graph(num_cities, vector<int>(num_cities, 0));

    int from, to, num_edges;
    for (int i = 0; i < num_cities; i++) {
        cin >> from >> num_edges;
        for (int j = 0; j < num_edges; j++) {
            cin >> to;
            graph[from - 1][to - 1] = 1;
        }
    }

    for (int i = 0; i < num_cities; i++) {
        for (int j = 0; j < num_cities; j++) {
            if (j != 0) cout << ' ';
            cout << graph[i][j];
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3172
#include <iostream>
using namespace std;
 
#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl
 
#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue
 
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)
 
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    IO; ll X; cin >> X;
    FORN(i, -200, 200)
        FORN(j, -200, 200)
            if ((ll)i*i*i*i*i-(ll)j*j*j*j*j==X)
            {
                cout << i << " " << j;
                return 0;
            }
    
}

Measured memory_bytes: 3612
def main():
    H, W = map(int, input().split())
    S = H * W
    ans = float('inf')
    for h1 in range(1,H):
        S1 = h1 * W
        # 縦に分割する場合
        h2 = (H - h1) // 2
        S2 = h2 * W
        S3 = (H - h1 - h2) * W
        ans = min(ans, max(S1,S2,S3) - min(S1,S2,S3))
        # 横に分割する場合
        w2 = W // 2
        w3 = W - w2
        S2 = (H - h1) * w2
        S3 = (H - h1) * w3
        ans = min(ans, max(S1,S2,S3) - min(S1,S2,S3))

    for w1 in range(1,W):
        S1 = w1 * H
        # 横に分割する場合
        w2 = (W - w1) // 2
        S2 = w2 * H
        S3 = (W - w1 - w2) * H
        ans = min(ans, max(S1,S2,S3) - min(S1,S2,S3))
        # 縦に分割する場合
        h2 = H // 2
        h3 = H - h2
        S2 = (W - w1) * h2
        S3 = (W - w1) * h3
        ans = min(ans, max(S1,S2,S3) - min(S1,S2,S3))

    print(ans)


    
    

if __name__ == "__main__":
    main()

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> a(M);
  long long b = 0;
  for(int i=0;i<M;i++){
    cin >> a.at(i);
    b += a.at(i);
  }
  int ans = N-b;
  if(N >= b){
    cout << ans << endl;
  }
  else if(N < b){
    cout << -1 << endl;
  }
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;

namespace JOI2011_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var MN = ReadInt();
            int M = MN[0];
            int N = MN[1];

            int K = int.Parse(Console.ReadLine());

            int[,] combJ = new int[M + 1, N + 1];
            int[,] combO = new int[M + 1, N + 1];
            int[,] combI = new int[M + 1, N + 1];

            for (int i = 1; i < M + 1; i++)
            {
                var input = Console.ReadLine();
                for (int j = 1; j < N + 1; j++)
                {
                    combJ[i, j] = combJ[i - 1, j] + combJ[i, j - 1] - combJ[i - 1, j - 1];
                    combO[i, j] = combO[i - 1, j] + combO[i, j - 1] - combO[i - 1, j - 1];
                    combI[i, j] = combI[i - 1, j] + combI[i, j - 1] - combI[i - 1, j - 1];

                    if (input[j - 1] == 'J') combJ[i, j]++;
                    else if (input[j - 1] == 'O') combO[i, j]++;
                    else combI[i, j]++;
                }
            }

            int[][] abcds = new int[K][];
            for (int i = 0; i < K; i++)
            {
                var input = ReadInt();
                abcds[i] = input;
            }

            List<int[]> anss = new List<int[]>();
            for (int i = 0; i < K; i++)
            {
                int a = abcds[i][0];
                int b = abcds[i][1];
                int c = abcds[i][2];
                int d = abcds[i][3];

                int candJ = combJ[c, d] - combJ[c, b - 1] - combJ[a - 1, d] + combJ[a - 1, b - 1];
                int candO = combO[c, d] - combO[c, b - 1] - combO[a - 1, d] + combO[a - 1, b - 1];
                int candI = combI[c, d] - combI[c, b - 1] - combI[a - 1, d] + combI[a - 1, b - 1];
                anss.Add(new int[] { candJ, candO, candI });
            }

            for (int i = 0; i < K; i++)
            {
                Console.WriteLine(string.Join(" ", anss[i]));
            }
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



Measured memory_bytes: 47468
pypy -ca,b,c,d=`tr \  ,`"
m=10**9+7
def f(r,c):
 s=t=1
 for i in range(c):s=s*(r+c-i)%m;t=t*-~i%m
 return s*pow(t,m-2,m)
print(f(a,b)-f(c+1,b)-f(a,d+1)+f(c+1,d+1))%m"

Measured memory_bytes: 88496
#include<bits/stdc++.h>
using namespace std;
#define MAX_V 500
#define INF 1<<28
typedef pair<int,int> P;
struct edge{int to,cap,cost,rev;};
 
int V;
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];
 
void add_edge(int from,int to,int cap,int cost){
  G[from].push_back((edge){to,cap,cost,G[to].size()});
  G[to].push_back((edge){from,0,-cost,G[from].size()-1});
}
 
int min_cost_flow(int s,int t,int f){
  int res=0;
  fill(h,h+V,0);
  while(f>0){
//priority_queue??§??????????????????????????§queue????????????
//????????????
//???push(0???)
//??¢??????????????????????????????????????????????????????????????????
//??£???????????¶??????????????°???G???????????????????????????????????????dist?????????
//???queue?????°???????????????

    priority_queue<P,vector<P>,greater<P> > que;
    fill(dist,dist+V,INF);
    dist[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
      P p=que.top();que.pop();
      int v=p.second;
      if(dist[v]<p.first) continue;
      for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
      dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
      prevv[e.to]=v;
      preve[e.to]=i;
      que.push(P(dist[e.to],e.to));
    }
      }
    }
    if(dist[t]==INF){
      return -1;
    }
    for(int v=0;v<V;v++) h[v]+=dist[v];
 
    int d=f;
    for(int v=t;v!=s;v=prevv[v]){
      d=min(d,G[prevv[v]][preve[v]].cap);
    }
    f-=d;
    res+=d*h[t];
    for(int v=t;v!=s;v=prevv[v]){
      edge &e=G[prevv[v]][preve[v]];
      e.cap-=d;
      G[v][e.rev].cap+=d;
    }
  }
  return res;
}
 
int main(){
  int e,f,u,v,c,d,i;
  cin>>V>>e>>f;
  for(i=0;i<e;i++){
    cin>>u>>v>>c>>d;
    add_edge(u,v,c,d);
  }
  cout << min_cost_flow(0,V-1,f) << endl;
  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn=100000+10;
int n;

typedef struct
{
    int parent;
    vector<int> child;

}Node;
Node node[maxn];
int deep[maxn];
void update_deep(int i)
{

    if(node[i].child.empty()) return;
     for(vector<int>::iterator iter=node[i].child.begin();iter!=node[i].child.end();iter++)
     {
         int d=*iter;
         deep[d]=deep[i]+1;
         update_deep(*iter);
     }
}
int main()
{
//    freopen("in.txt","r",stdin);
    memset(deep,0,sizeof(deep));
    int id,du;
    scanf("%d",&n);
    for(int i=0;i<n;i++) node[i].parent=-1;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&id,&du);
        for(int j=0;j<du;j++)
        {
            int d;
            scanf("%d",&d);
            node[d].parent=id;
            node[id].child.push_back(d);
        }
        update_deep(id);
    }
    for(int i=0;i<n;i++)
    {
        printf("node %d: parent = %d, depth = %d, ",i,node[i].parent,deep[i]);
        int len=node[i].child.size();
        if(node[i].parent==-1) printf("root");
        else if(len==0) printf("leaf");
        else printf("internal node");
        printf(", ");
        //sort(node[i].child.begin(),node[i].child.end());
        printf("[");
        for(vector<int>::iterator iter=node[i].child.begin();iter!=node[i].child.end();iter++)
        {
            if(iter!=node[i].child.begin())
            {
                printf(", ");

            }
             printf("%d",*iter);
        }
        printf("]\n");
    }

    return 0;
}

Measured memory_bytes: 7432
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    double a;
    cin >> a;
    a = a * 3.14159 * 2.0;
    printf("%.4f\n", a);

    return 0;
}


Measured memory_bytes: 3780
#include<stdio.h>
#include<string.h>
#define LEN 100005

/* プロセスを表す構造体 */
typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) { return a < b ? a : b; }  /* 最小値を返す */

int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  /* 全てのプロセスをキューに順番に追加する */
  for ( i = 1; i <= n; i++ ) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;

  /* シミュレーション */
  while ( head != tail ) {
    u = dequeue();
    c = min(q, u.t);  /* q または必要な時間 u.t だけ処理を行う */
    u.t -= c;  /* 残りの必要時間を計算 */
    elaps += c;  /* 経過時間を計算 */
    if ( u.t > 0 ) enqueue(u);  /* 処理が完了していなければキューに追加 */
    else printf("%s %d\n", u.name, elaps);
  }

  return 0;
}


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


int main()
{

    int N, mini, cnt = 0;
    std::scanf("%d", &N);
    int arr[N];
    for (int i = 0; i < N; i++) std::scanf("%d", &arr[i]);

    for (int i = 0; i < N; i++) {
        mini = i;
        for (int j = i; j < N; j++) {
            if (arr[j] < arr[mini]) {
                mini = j;
            }

        }
        if (arr[i] != arr[mini]) {
            cnt++;
            std::swap(arr[i], arr[mini]);
        }
    }

    for (int i = 0; i < N; i++) {
        if (i) std::printf(" ");
        std::printf("%d", arr[i]);
    }
    std::printf("\n");
    std::printf("%d\n", cnt);

    return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, W; cin >> n >> W;
    vector<ll> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];

    vector<ll> dp(W + 1, 0);

    rep(i, n)for(int j = W; j >= 0; j--){
        if(j + w[i] <= W) dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
    }
    cout << dp[W] << endl;
}

Measured memory_bytes: 3992