akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
N = INT()
a = LIST()[::-1]

ans = [[0]*W for _ in range(H)]
tmp = a.pop()
color = 1
cnt = 0
for i in range(H):
    for j in range(W):
        if i%2:
            j = W-j-1
        ans[i][j] = color
        cnt += 1
        if cnt == tmp and a:
            cnt = 0
            tmp = a.pop()
            color += 1

for i in ans:
    print(" ".join([str(x) for x in i]))


Measured memory_bytes: 78984
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int a , b , h , m;
    cin >> a >> b >> h >> m;
    int k = (360*h + 6*m)%360;
    double l = 0.5 * (h * 60 + m);
    double t = abs(k - l);
    double pi = 3.141592653589793238462643383279;
    cout << setprecision(20) << sqrt(a*a + b*b - 2*a*b*cos(t/180.0*pi)) << endl;
}

Measured memory_bytes: 4232
#include <stdio.h>
int main(void){
    int n, y;
    scanf("%d %d", &n, &y);
    for(int i=0; i<=y/10000; i++){
        for(int j=0; j<=n-i; j++){
            // printf("%d %d %d\n", i, j, n-i-j);
            if(10000*i+5000*j+1000*(n-i-j)==y){
                printf("%d %d %d\n", i, j, n-i-j);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 1708
#include<iostream>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}


int main(){
  string s; cin >>s;
  rep(i,3){
    if(s[i]=='7'){
      print("Yes");
      return 0;
    }
  }
  print("No");
}



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

int main() {
  int n;
  cin >> n;
  vector<int> buttons(n);
  for (int i = 0; i < n; i++) {
    cin >> buttons.at(i);
  }
  int x = 1;
  int count = 0;
  for (int i = 0; i < n; i++) {
    x = buttons.at(x - 1);
    count++;
    if (x == 2) {
      cout << count << endl;
      break;
    }
  }
  if (x != 2) {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 768
N =int(input())
a_list = list(map(int, ("0 " + input()).split()))
put_list = [0] * (N+1)
count = 0
in_list = []
for index in reversed(range(len(a_list))):
    if index == 0:
        break
    upper_index_keisuu = 2
    upper_sum = 0
    while True:
        if index * upper_index_keisuu > (len(a_list)-1):
            break
        upper_sum += put_list[index * upper_index_keisuu]
        upper_sum %= 2
        upper_index_keisuu += 1

    if upper_sum != a_list[index]:
        count += 1
        put_list[index] = 1
        in_list.append(index)


print(count)

if count > 0:
    ret_str = ""
    for add in in_list:
        ret_str += str(add) + " "
    print(ret_str)


Measured memory_bytes: 14876
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N, D, ans = 0;
	cin >> N >> D;
	vector<vector<double>> X(N, vector<double>(D));
	for (vector<double>& i : X) {
		for (double& j : i) cin >> j;
	}
	for (int i = 0; i < N - 1; ++i) {
		for (int j = 1 + i; j < N; ++j) {
			double a = 0.0;
			for (int k = 0; k < D; ++k) a += pow(X[i][k] - X[j][k], 2.0);
			if (ceil(sqrt(a)) == sqrt(a)) ++ans;
		}
	}
	cout << ans;
}

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

int N;
string A, B, C;

int main() {
    cin >> N >> A >> B >> C;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        map<char, bool> mp;
        mp[A[i]] = true;
        mp[B[i]] = true;
        mp[C[i]] = true;
        ans += mp.size() - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
int h,w,n;
int a[111111];
int b[111111];
set<pair<int,int> > s;

int f[11][11];
ll ans[11];
int main(void){
  scanf("%d%d%d",&h,&w,&n);
  for(int i = 0; i < n; i++){
    scanf("%d%d",a+i,b+i);
    a[i]--;b[i]--;
    s.insert(make_pair(a[i],b[i]));
  }
  
  for(int k = 0; k < n; k++){
    memset(f,0,sizeof(f));
    for(int i = max(a[k]-2,0); i < min(a[k]+3,h); i++){
      for(int j = max(b[k]-2,0); j < min(b[k]+3,w); j++){
	if(s.find(make_pair(i,j)) != s.end()){
	  f[i-(a[k]-3)][j-(b[k]-3)] = 1;
	}
      }
    }

    for(int i = 1; i < 11; i++)
      for(int j = 0; j < 11; j++)
	f[i][j] += f[i-1][j];
    for(int i = 1; i < 11; i++)
      for(int j = 0; j < 11; j++)
	f[j][i] += f[j][i-1];
    
    for(int i = max(a[k]-2,0); i < min(a[k]+3,h)-2; i++){
      for(int j = max(b[k]-2,0); j < min(b[k]+3,w)-2; j++){
	int t  = f[i-(a[k]-3)+2][j-(b[k]-3)+2] -
	         f[i-(a[k]-3)+2][j-(b[k]-3)-1] -
		 f[i-(a[k]-3)-1][j-(b[k]-3)+2] +
        	 f[i-(a[k]-3)-1][j-(b[k]-3)-1];
	ans[t]++;
      }
    }
  }

  ans[0] = ll(h-2)*ll(w-2);
  for(int i = 1; i < 10; i++){
    ans[i] /= i;
    ans[0] -= ans[i];
  }

  for(int i = 0; i < 10; i++){
    printf("%lld\n",ans[i]);
  }
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	int a, b;
	cin >> a >> b;
	int ans;
	if (a + b >= 24) {
		ans = a + b - 24;
	}
	else {
		ans = a + b;
	}

	cout << ans << endl;

	return 0;
}


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

int ans = INT_MIN;

int main(){
	#ifdef LOCAL_DEFINE
		freopen("../a.in","r",stdin);
		freopen("../a.out", "w",stdout);
	#endif
	string s;
	cin >> s;
	int ans = 0;
    for(int i=0; i<s.length(); i++) {
        for(int j=1; j<=s.length()-i; j++) {
            string s1(s,i,j);
            bool atgc = 1;
            for(int k=0;k<s1.length();k++){
            	if(s1[k]!='A'&&s1[k]!='T'&&s1[k]!='G'&&s1[k]!='C'){
            		atgc = 0;
            		break;
            	}
            }
            if(atgc){
            	int t = s1.length();
            	ans = max(ans,t);
            }
        }
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n);
    vector<int> vec(2*n);
    in(vec);
    sort(all(vec));
    int ans=0;
    for(int i=0;i<2*n;i+=2){
        ans+=vec[i];
    }
    out(ans);
}

Measured memory_bytes: 3744
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		int lim = Integer.parseInt(sc.next());
		for (int i = 0; i < lim; i++) {
			double[] point = new double[6];
			for (int j = 0; j < 6; j++) {
				point[j] = Double.parseDouble(sc.next());
			}
			
			double[] m = new double[4];
			m[0] = (point[0] + point[2]) / 2;
			m[1] = (point[1] + point[3]) / 2;
			m[2] = (point[2] + point[4]) / 2;
			m[3] = (point[3] + point[5]) / 2;
			
			double a = m[0] - point[0];
			double b = m[1] - point[1];
			double c = m[2] - point[2];
			double d = m[3] - point[3];

			double p = a * m[0] + b * m[1];
			double q = c * m[2] + d * m[3];
			
			double det = a * d - b * c;

			double x = (p * d + q * (-b)) / det;
			double y = (p * (-c) + q * a) / det;

			if (a == 0.0) y = m[1];
			if (b == 0.0) x = m[0];
			if (c == 0.0) y = m[3];
			if (d == 0.0) x = m[2];
			
			double r = Math.sqrt((x - point[0]) * (x - point[0]) + (y - point[1]) * (y - point[1]));
			
			System.out.printf("%.3f %.3f %.3f\n", x, y, r);
		}
	}
}

Measured memory_bytes: 25888
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vec2str vector<vector<string>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll k,ans=-1;
	string s;
	bool flag = false;

	cin >> k;

	ll buf=0;
	ll count = 0;

	while(1)
	{
		buf = (7 + buf * 10) % k;

		count++;

		if (count > k)
		{
			ans = -1;
			break;
		}

		if (buf == 0)
		{
			ans = count;
			break;
		}

	}

	cout << ans;
}

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


int main()
{
    int n,ans=0,bit;
    cin >>n;
    ll x,upper;



    rep(i,n){
        cin >> x;
        upper = sqrt(x)+1;
        bit=0;
        if(x==2) ans++;
        for(int j=2;j<=upper;j++){
            if(x%j==0){
                bit=1;
                break;
            }
        }
        if(bit==0) ans++;
    }


    cout << ans << endl;

    return 0;

}


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

int main() {

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define dbg(x) cerr << #x << ":" << x << " "
#define dbgl(x) cerr << #x << ":" << x << "\n"
#define dbgv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int N; cin >> N;
	vector<pii> c;
	rep(i, N) {
		int x, y; cin >> x >> y;
		pii p(x, y); c.push_back(p);
	}
	sort(all(c));
	double ans = 0;
	do {
		for (auto it = c.begin(); it != c.end() - 1; it++) {
			double dx = (it + 1)->first - it->first;
			double dy = (it + 1)->second - it->second;
			ans += sqrt(pow(dx, 2) + pow(dy, 2));
		}
	} while (next_permutation(all(c)));
	rep2(k, 2, N + 1) ans /= (double)k;
	cout << fixed << setprecision(10);
	cout << ans << endl;
}

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

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi std::vector<int>
#define vvi std::vector<std::vector<int> >
#define vpi std::vector<pi >
#define pi std::pair<int,int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (int var = (from); var <= ((int)(to)); var++)
#define DOWNTO(var, from, to) for (int var = (from); var >= ((int)(to)); var--)
#define FOR(var, to)		  UPTO(var, 0, (to)-1)
#define DOWN(var, from)	   DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static const int MOD = 1000000007;
static const int INF = ((1<<30)-1);
static const s64 LINF = ((1LL << 62)-1);

struct Comb {
	std::vector<std::vector<s64> > a;
	Comb(int n) { // O(n^2)
		a.resize(n+1);
		FOR(i,n+1) {
			a[i].resize(i+1, 1);
			UPTO(j,1,i-1) a[i][j] = a[i-1][j] + a[i-1][j];
		}
	}
	s64 ncr(int n, int r) {
		assert(n >= 0);
		assert(n <= (int)a.size());
		assert(r >= 0);
		assert(r <= n);
		return a[n][r];
	}
};

#define gc(c) (c)=getchar()
int ri() {
	int c,s=0,r=0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}
s64 rs64() {
	s64 r;
	int c,s;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}

int int_less(const void *a, const void *b) {
	return (*(const int*)a - *(const int*)b);
}
int int_greater(const void *a, const void *b) {
	return (*(const int*)b - *(const int*)a);
}
std::string operator*(const std::string &s, int n){ std::string res; FOR(i,n) res += s; return res; }

template<class T> std::ostream& operator<<(std::ostream& os, std::vector<T> a) { for (auto i : a) os << i << " "; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, std::set<T> a) { for (auto i : a) os << i << " "; return os; }
template<class A, class B> std::ostream& operator<<(std::ostream&os, std::pair<A,B> a) { os << a.fi << "," << a.se; return os; }


int main() {
	int a[5];
	FOR(i,5) a[i] = ri();
	int res = INF;
	do {
		int cur = 0;
		FOR(i,5) {
			cur += a[i];
			if (i != 4 && cur % 10) cur += 10, cur -= cur % 10;
		}
		res = std::min(res, cur);
	}while(std::next_permutation(a,a+5));
	std::cout << res << std::endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int m[3][3]={};
    int t[3][3]={};
    ll n,b,x;
    REP(i,3)REP(j,3){
        cin>>x;
        m[i][j]=x;
    }
    cin>>n;
    REP(i,n){
        cin>>b;
        REP(i,3)REP(j,3)if(m[i][j]==b)t[i][j]=1;
    }
    int flag;
    REP(i,3){
        flag=1;
        REP(j,3)if(t[i][j]==0)flag=0;
        if(flag){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    REP(i,3){
        flag=1;
        REP(j,3)if(t[j][i]==0)flag=0;
        if(flag){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    flag=1;
    REP(j,3)if(t[j][j]==0)flag=0;
    if(flag){
        cout<<"Yes"<<endl;
        return 0;
    }
    flag=1;
    REP(j,3)if(t[j][2-j]==0)flag=0;
    if(flag){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int sx = sc.nextInt();
    int sy = sc.nextInt();
    int tx = sc.nextInt();
    int ty = sc.nextInt();
    
    int x = tx - sx;
    int y = ty - sy;
    for (int i = 1; i <= x; i++) {
      System.out.print("R");
    }
    for (int i = 1; i <= y; i++) {
      System.out.print("U");
    }
    for (int i = 1; i <= x; i++) {
      System.out.print("L");
    }
    for (int i = 1; i <= y; i++) {
      System.out.print("D");
    }
    System.out.print("D");
    for (int i = 1; i <= x + 1; i++) {
      System.out.print("R");
    }
    for (int i = 1; i <= y + 1; i++) {
      System.out.print("U");
    }
    System.out.print("L");
    System.out.print("U");
    for (int i = 1; i <= x + 1; i++) {
      System.out.print("L");
    }
    for (int i = 1; i <= y + 1; i++) {
      System.out.print("D");
    }
    System.out.print("R");
  }
}


Measured memory_bytes: 40408
#include <stdio.h>
#include <string.h>

int main(){
    char s[11], t[11];
    int lens, lent;
    int cnt=0, len;

    scanf("%s", s);
    scanf("%s", t);
    lens = strlen(s);
    lent = strlen(t);
    len = lent - lens;

    for(int i = 0; i < lens; i++){
        if(s[i] == t[i]){
            cnt++;
        }
    }
    if(cnt == lens && len == 1){
        printf("Yes");
    }else{
        printf("No");
    }
    }

Measured memory_bytes: 1728
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int main(){
    iostream::sync_with_stdio(false);
    
    int N, M, X;
    cin >> N >> M >> X;
    int T[10000];
    for(int i=0; i<N; i++) cin >> T[i];
    vector<pair<int, int>> root[10000];
    for(int i=0; i<M; i++){
        int A, B, D;
        cin >> A >> B >> D;
        A--; B--;
        root[A].push_back(make_pair(B, D));
        root[B].push_back(make_pair(A, D));
    }

    int cost[10000][2][201];//その部屋から出るときにどのような状態か
    for(int i=0; i<N; i++){
        for(int j=0; j<=X; j++){
            cost[i][0][j] = INT_MAX;
            cost[i][1][j] = INT_MAX;
        }
    }
    cost[0][0][X] = 0;
    bool already[10000][2][201] = {};

    priority_queue<pair<int, pair<int, int>>> que; //cost, place, time(-のときは寒い部屋を出てから、+のときは暑い部屋を出てから)
    que.push(make_pair(INT_MAX-0, make_pair(0, -X)));
    int ans = INT_MAX;
    while(!que.empty()){
        int now = que.top().second.first;
        int c = INT_MAX - que.top().first;
        int t = que.top().second.second;
        int state2 = 0;
        if(t > 0) state2 = 1;
        if(already[now][state2][abs(t)]){
            que.pop();
            continue;
        }
        if(c >= ans) break;
        for(int i=0; i<root[now].size(); i++){
            int next = root[now][i].first;
            if(t > 0 && T[next] == 0 && root[now][i].second < t) continue;
            if(t < 0 && T[next] == 2 && root[now][i].second < -t) continue;

            int t2 = 0;
            if(t > 0) t2 = max(0, t-root[now][i].second);
            if(t < 0) t2 = min(0, t+root[now][i].second);
            if(T[next] == 0) t2 = -X;
            if(T[next] == 2) t2 = X;
            int state = 0;
            if(t2 > 0) state = 1;
            if(cost[next][state][abs(t2)] < c + root[now][i].second) continue;

            cost[next][state][abs(t2)] = c + root[now][i].second;
            que.push(make_pair(INT_MAX-c-root[now][i].second, make_pair(next, t2)));

            if(next == N-1) ans = min(ans, cost[next][state][abs(t2)]);
        }
        already[now][state2][abs(t)] = true;
        que.pop();
    }
    cout << ans << endl;
    return 0;
}


/*
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int main(){
    
    
    
    return 0;
}
*/


Measured memory_bytes: 23760
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
long long n,m,ans;
int main(){
	scanf("%d%d",&n,&m);
	if(n>m)swap(n,m);
	if(n==1){
		if(m==1)ans=1;
		else ans=m-2;
	}
	else if(n==2)ans=0;
	else ans=(n-2)*(m-2);
	printf("%lld",ans);
	return 0;
}


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

//正なら元の値、負なら０を返す関数
long long ramp(long long x){
    if(x>=0) return x;
    else return 0;
}

int main(){
	long long n; 
    cin >> n;
    vector<long long> a(n+1);
    for(int i=0; i<n+1; i++) cin >> a[i];
    //元のモンスターの数
    long long s=accumulate(a.begin(),a.end(),0ll);
    
    long long tmp;
    for(int i=0; i<n; i++){
        cin >> tmp;
        //i番目の勇者が倒した後のモンスターの数
        //ramp(tmp-a[i])が余力
        a[i+1] = ramp(a[i+1]-ramp(tmp-a[i]));
        //a[i]>tmpならa[i]-tmp,それ以外は0
        a[i] = ramp(a[i]-tmp);
    }
    //生き残ったモンスターの数
    long long e=accumulate(a.begin(),a.end(),0ll);
    //元－生き残り＝倒した数
    s -= e;
    cout << s << endl;

}

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

int n,m[51],x[51][10],y[51][10];

bool same(int i1, int i2)
{
  if(m[i1]!=m[i2])return false;
  for(int j=0;j<m[i1];j++)if(x[i1][j]!=x[i2][j] || y[i1][j]!=y[i2][j])return false;
  return true;
}
void add(int i, int ax, int ay)
{
  for(int j=0;j<m[i];j++){
    x[i][j]+=ax;
    y[i][j]+=ay;
  }
}
void rotate(int i)
{
  for(int j=0;j<m[i];j++){
    int tx=x[i][j],ty=y[i][j];
    x[i][j]=ty;
    y[i][j]=-tx;
  }
}
void reverse(int i)
{
  int tx[10],ty[10];
  for(int j=0;j<m[i];j++){
    tx[j]=x[i][j];
    ty[j]=y[i][j];
  }
  for(int j=0;j<m[i];j++){
    x[i][j]=tx[m[i]-j-1];
    y[i][j]=ty[m[i]-j-1];
  }
}

int main()
{
  while(cin>>n,n){
    for(int i=0;i<=n;i++){
      cin>>m[i];
      for(int j=0;j<m[i];j++){
	cin>>x[i][j]>>y[i][j];
      }
    }

    set<int>ans;
    set<int>::iterator it;
    add(0,-x[0][0],-y[0][0]);
    for(int i=1;i<=n;i++){
      add(i,-x[i][0],-y[i][0]);
      for(int k=0;k<4;k++){
	rotate(i);
	if(same(0,i))ans.insert(i);
      }
      reverse(i);
      add(i,-x[i][0],-y[i][0]);
      for(int k=0;k<4;k++){
	rotate(i);
	if(same(0,i))ans.insert(i);
      }
    }

    for(it=ans.begin();it!=ans.end();it++)cout<<*it<<endl;
    puts("+++++");
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  char c;
  cin >> c;
  cout << ('A' <= c && c <= 'Z' ? 'A' : 'a') << "\n";
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
     ll n,x;
     cin>>x>>n;
     ll a[n];
     if(n==0)
        cout<<x;
     else{
     for(int i=0;i<n;i++)
        cin>>a[i];
        int cnt=0,flag=0,ans;

     for(int j=0;;j++)
     {
         int temp1=x-j;
         int temp2=x+j;
         for(int i=0;i<n;i++)
         {
             if(temp1==a[i])
                break;
             if(i==n-1)
             {
                 cout<<temp1<<endl;
                 return 0;
             }
         }

        for(int i=0;i<n;i++)
         {
             if(temp2==a[i])
                break;
             if(i==n-1)
             {
                 cout<<temp2<<endl;
                 return 0;
             }
         }



     }
     }

 return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	int ans = k;
	ans *= pow(k - 1, n - 1);
	cout << ans << endl;
	return 0;
}


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

int main ()
{
string S;
cin>>S;
if(S=="Sunny"||S=="Cloudy"||S=="Rainy"){
if(S=="Sunny"){
    cout<<"Cloudy";
}
if(S=="Cloudy"){
    cout<<"Rainy";
}
if(S=="Rainy"){
    cout<<"Sunny";
}
}
return 0;
}

Measured memory_bytes: 3572
N = 100000

checked = Array.new(N+1,false)
is_prime = Array.new(N+1,true)

is_prime[1] = false
for i in 2..(Math.sqrt(N).floor)
  next if checked[i]

  is_prime[i] = true
  checked[i] = true

  j = 2
  for j in 2..(N/i)
    checked[i*j] = true
    is_prime[i*j] = false
  end
end

like_2017 = Array.new(N+1,0)
for i in 1..N
  if is_prime[i] && is_prime[(i+1)/2]
    like_2017[i] = like_2017[i-1]+1
  else
    like_2017[i] = like_2017[i-1]    
  end
end

q = gets.chomp.to_i
q.times do
  l, r = gets.chomp.split(" ").map(&:to_i)
  puts like_2017[r] - like_2017[l-1]
end


Measured memory_bytes: 4604
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
  int w,h,n,x[20000],y[20000];
  int sum=0,dis;
  int i,j;
  scanf("%d %d %d",&w,&h,&n);
  for(i=0;i<=n-1;i++){
    scanf("%d %d",&x[i],&y[i]);
  }
  for(i=0;i<=n-2;i++){
    j=i+1;
    if(x[i]==x[j]) {dis=abs(y[i]-y[j]);sum=sum+dis;continue;}
    else if(y[i]==y[j]) {dis=abs(x[i]-x[j]);sum=sum+dis;continue;}
    else if(((x[i]<=x[j])&&(y[i]<=y[j]))||(x[i]>=x[j])&&(y[i]>=y[j])) {dis=max(abs(x[i]-x[j]),abs(y[i]-y[j]));sum=sum+dis;continue;}
    else if(((x[i]<=x[j])&&(y[i]>=y[j]))||(x[i]>=x[j])&&(y[i]<=y[j])) {dis=abs(x[i]-x[j])+abs(y[i]-y[j]);sum=sum+dis;continue;}
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
const int mod = 1e9+7;
const int maxn = 1e3+5;
const double EPS = 1e-6;
using namespace std;
int a[maxn][maxn];
int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	int fg=0;
	rep(i,0,n+1){
		rep(j,0,m+1){
			int ans=i*m+j*n-i*j*2;
			if(ans==k) fg=1;
			if(fg) break;
		}
		if(fg) break;
	}
	if(fg) printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 256
import math
import sys
input = sys.stdin.readline


# 処理内容
def main():
    N, D = map(int, input().split())
    
    ans = 0
    for i in range(N):
        x, y = map(int, input().split())
        if math.sqrt(x*x + y*y) <= D:
            ans += 1
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 68820
int main(){
  int n, i;
  int d;
  scanf("%d", &n);
  int sum=0;
  int po=0;
  for(i=0; i<n; i++){
    scanf("%d", &d);
    sum+=d;
    po+=d*d;
  }
  printf("%d\n", (sum*sum-po)/2);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int a, b;
int main() {
    DAU
    cin >> a >> b;
    cout << max(a * b, max(a + b, a - b));
    PLEC
}


Measured memory_bytes: 3624
import numpy as np
S    = np.array(list(input()))
T    = np.array(list(input()))
N    = len(S)
SSrt = np.sort(S)
TSrt = np.sort(T)
SArg = np.argsort(S)
TArg = np.argsort(T)
SAgT = S[TArg]
TAgS = T[SArg]

SBef = ''
TBef = ''
SFlag = True
for ST in range(0,N):
    SNow = SSrt[ST]
    TNow = TAgS[ST]
    if SBef==SNow:
        if TBef!=TNow:
            SFlag = False
            break
    SBef = SNow
    TBef = TNow
        
SBef = ''
TBef = ''
TFlag = True
for TT in range(0,N):
    SNow = SAgT[TT]
    TNow = TSrt[TT]
    if TBef==TNow:
        if SBef!=SNow:
            TFlag = False
            break
    SBef = SNow
    TBef = TNow
        
if SFlag and TFlag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 35336
#include <iostream>
#include<set>
#include<math.h>
#include<list>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)

int yaku(int n){
    int ret = 0;
    int a = 1;

    while(a<=n){
        if(n%a==0){
            ret++;
        }
        a++;
    }

    return ret;
}

int main(){
    int N, ans=0;
    cin >> N;

    for(int i=3;i<=N;i+=2){
        if(yaku(i)==8)ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace _20200711
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var x_ = Console.ReadLine();
            var x = new int[n];
            var popx = 0;
            for (var i = 0; i < n; ++i)
            {
                x[i] = int.Parse(x_.Substring(i, 1));
                if (x[i] == 1)
                {
                    ++popx;
                }
            }

            var n_pn_plus = new int[n];
            var n_pn_minus = new int[n];
            var minusValid = popx > 1;
            var t_plus = 1;
            var t_minus = 1;
            for (var i = 0; i < n; ++i)
            {
                t_plus %= popx + 1;
                n_pn_plus[i] = t_plus;
                t_plus *= 2;
                if (minusValid)
                {
                    t_minus %= popx - 1;
                    if (t_minus < 0)
                    {
                        t_minus += popx - 1;
                    }
                    n_pn_minus[i] = t_minus;
                    t_minus *= 2;
                }
            }

            var npnFirstPlus = 0;
            var npnFirstMinus = 0;
            for (var i = 0; i < n; ++i)
            {
                npnFirstPlus = (npnFirstPlus * 2 + x[i]) % (popx + 1);
                if (minusValid)
                {
                    npnFirstMinus = (npnFirstMinus * 2 + x[i]) % (popx - 1);
                }
            }

            for (var i = 0; i < n; ++i)
            {
                var pos = n - i - 1;
                if (x[i] == 1)
                {
                    if (popx == 1)
                    {
                        Console.WriteLine(0);
                        continue;
                    }
                    var npn = (npnFirstMinus - n_pn_minus[pos]) % (popx - 1);
                    if (npn < 0)
                    {
                        npn += (popx - 1);
                    }
                    Console.WriteLine(F(npn) + 1);
                }
                else
                {
                    Console.WriteLine(F((npnFirstPlus + n_pn_plus[pos]) % (popx + 1)) + 1);
                }
            }
        }

        static int F(int x)
        {
            var tmp = x;
            var count = 0;
            while (tmp > 0)
            {
                tmp %= P(tmp);
                ++count;
            }
            return count;
        }

        static int P(int x)
        {
            var tmp = x;
            var count = 0;
            while (tmp > 0)
            {
                if (tmp % 2 == 1)
                {
                    ++count;
                }
                tmp /= 2;
            }
            return count;
        }
    }
}


Measured memory_bytes: 35364
#include<iostream>
#include<algorithm>
using namespace std;
const int Nmax = 100000;
const int P = 1000000007;
int N;
long T[Nmax], A[Nmax];

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

	long tmax = 0, amax = 0;
	long tmaxi=-1, amaxi=-1;
	for(int i=0; i<N; i++){
		if(T[i] > tmax){
			tmax = T[i];
			tmaxi = i;
		}
	}
	for(int i=0; i<N; i++){
		if(A[N-i-1] > amax){
			amax = A[N-i-1];
			amaxi = N-i-1;
		}
	}
	if(amax != tmax || tmaxi > amaxi){
		cout << 0 << endl;
		return 0;
	}

	long ans = 1;
	for(int i=1; i<N-1; i++){
		if(i <= tmaxi){
			if(T[i] == T[i-1]){
				ans = (ans * T[i])%P;
			}
		}
		else if(i < amaxi){
			ans = (ans * tmax)%P;
		}
		else if(A[i] == A[i+1]){
			ans = (ans * A[i])%P;
		}
	}

	cout << ans << endl;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}





int main(){

  ll N;
  cin >> N;
  ll sum = 0;
  ll ans = 0;
  FOR(i,0,N){
    ll a;
    cin >> a;
    ans += sum*a;
    sum += a;
    ans %= MOD;
    sum %= MOD;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3640
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long a = scan.nextInt();
        long b = scan.nextInt();
        long c = scan.nextInt();
        if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
            System.out.println(0);
            return;
        }
        if(a == b && b == c){
            System.out.println(-1);
            return;
        }
        int out = 0;
        while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
            long aa = b / 2 + c / 2;
            long ba = a / 2 + c / 2;
            long ca = a / 2 + b / 2;
            a = aa; b = ba; c = ca;
            out++;
        }
        System.out.println(out);
        scan.close();
    }
}


Measured memory_bytes: 27024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    int t;
    cin >> t;
    while(t--){
        int gx,gy;
        cin >> gx >> gy;
        vector<vector<int>> impossible(gx+1,vector<int>(gy+1,-1));
        //-1　どこでもいける
        //0 上からこれない
        //1 左から来れない
        //2 上と左どちらからも来れない
        int n;cin >> n;
        while(n--){
            P l,r;
            cin >> l.first >> l.second >> r.first >> r.second;
            if(l > r) swap(l,r);
            if(l.first == r.first){
                if(impossible[r.first][r.second] == -1){ 
                    impossible[r.first][r.second] = 0;
                }else{
                    impossible[r.first][r.second] = 2;
                }
            }else{
                if(impossible[r.first][r.second] == -1){ 
                    impossible[r.first][r.second] = 1;
                }else{
                    impossible[r.first][r.second] = 2;
                }
            }
        }
        vector<vector<int>> dp(gx+1,vector<int>(gy+1,0));
        dp[0][0] = 1;
        rep(i,gx+1)rep(j,gy+1){
            if(i>0 && (impossible[i][j]==-1 || impossible[i][j]==0)) dp[i][j] += dp[i-1][j];
            if(j>0 && (impossible[i][j]==-1 || impossible[i][j]==1)) dp[i][j] += dp[i][j-1];
        }
        if(dp[gx][gy]==0) cout << "Miserable Hokusai!" << endl;
        else cout << dp[gx][gy] << endl;
    }
    return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vp;
typedef vector<ll> vll;

const int INF = 99999999;
const int MAX_V = 100000;

struct edge { int to, cap, cost, rev; };

int V, E, F;
vector<edge> G[MAX_V];
int h[MAX_V];                   // potential
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V]; // privious vertex, edge

void add_edge(int from, int to, int cap, int cost) {
    G[from].emplace_back((edge){to, cap, cost, (int)G[to].size()});
    G[to].emplace_back((edge){from, 0, -cost, (int)G[from].size() - 1});
}

// get min cost flow from s to t
// if we can flow f, then return -1
int min_cost_flow(int s, int t, int f) {
    int res = 0;
    fill(h, h + V, 0);
    while (f > 0) {
        // update h by dijkstra
        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;
            rep(i, G[v].size()) {
                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) {
            // no more flow
            return -1;
        }
        rep(v, V) h[v] += dist[v];

        // flow as much as possible along the minimum path from s to t
        int d = f;
        for (int v = t; v != s; v = prevv[v]) {
            d = min(d, (int)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;
}

signed main() {
    cin >> V >> E >> F;
    rep(i, E) {
        int u, v, c, d;
        cin >> u >> v >> c >> d;
        add_edge(u, v, c, d);
    }

    cout << min_cost_flow(0, V - 1, F) << endl;
}

Measured memory_bytes: 5540
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    long[,] E;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int M = int.Parse(str[1]);
        E = new long[3,3];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                E[i,j] = i == j ? 1 : 0;
            }
        }
        long[,] T = new long[3,3];
        long[,] F = new long[3,3];
        T[0,0] = 2;
        F[0,0] = 1;
        T[0,1] = 1;
        F[0,1] = 1;
        T[1,0] = 3;
        T[1,1] = 1;
        F[1,1] = 1;
        T[1,2] = 1;
        F[1,2] = 1;
        T[2,0] = 2;
        T[2,2] = 1;
        F[2,2] = 1;
        long X = 1;
        long Y = 3;
        long Z = 2;
        str = Console.ReadLine().Split(' ');
        long[,] C = E;
        for(int i=0;i<M;i++){
            long[,] Matrix = Pow(T,int.Parse(str[i])-(i == 0 ? 0 : int.Parse(str[i-1]))-1);
            C = Mul(Matrix,C);
            C = Mul(F,C);
        }
        {
            long[,] Matrix = Pow(T,N-1-(M == 0 ? 0 : int.Parse(str[M-1])));
            C = Mul(Matrix,C);
        }
        /*for(int i=1;i<N;i++){
            long X0,Y0,Z0;
            if(c != M && int.Parse(str[c]) == i){
                c++;
                X0 = X+Y;
                Y0 = Y+Z;
                Z0 = Z;
            }
            else{
                X0 = 2*X+Y;
                Y0 = Y+Z+3*X;
                Z0 = Z+2*X;
            }
            X = X0 % Define.mod;
            Y = Y0 % Define.mod;
            Z = Z0 % Define.mod;
            Console.WriteLine(X+" "+Y+" "+Z);
        }*/
        sb.Append((X*C[0,0]+Y*C[0,1]+Z*C[0,2])%Define.mod+"\n");
    }
    long[,] Mul(long[,] a,long[,] b){
        long[,] c = new long[3,3];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                long d = 0;
                for(int k=0;k<3;k++){
                    d += a[i,k]*b[k,j]%Define.mod;
                }
                c[i,j] = d % Define.mod;
            }
        }
        return c;
    }
    long[,] Pow(long[,] a,long e){
        if(e == 0){
            return E;
        }
        else if(e%2 == 0){
            long[,] b = Mul(a,a);
            return Pow(b,e/2);
        }
        else{
            return Mul(Pow(a,e-1),a);
        }
    }
}
public static class Define{
    public const long mod = 1000000007;
}

Measured memory_bytes: 28108
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string S, T;
    cin >> S >> T;
    lint ans = 0;
    range(i, 0, 3) if (S.at(i) == T.at(i)) ans += 1;
    cout << ans << "\n";
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

LL K;
LL a[55];

int main(){
	scanf("%lld" , &K);
	int N = 50;
	LL r = K % N;
	LL q = K / N;
	printf("%d\n" , N);
	repp(i,0,N){
		printf("%lld%c" , q + i + (i<r?N-r+1:-r) , i+1==N?'\n':' ');
	}
	return 0;
}


Measured memory_bytes: 256