akhauriyash/Code-Regression huggingface dataset:
class Dinic:
    def __init__(self, len_X, len_Y):
        self.len_X, self.len_Y = len_X, len_Y
        self.edges = [[] for _ in range(len_X)]
        self.matched = [-1] * len_Y
        self.visited = set()

    def add_edge(self, x, y):
        self.edges[x].append(y)

    def dfs(self, x):
        """
        :param x: X側の未マッチングの頂点の1つ
        :param visited: 空のsetを渡す（外部からの呼び出し時）
        :return: 増大路が見つかればTrue
        """
        for next_x in self.edges[x]:
            if next_x in self.visited:
                continue
            self.visited.add(next_x)
            if self.matched[next_x] == -1 or self.dfs(self.matched[next_x]):
                self.matched[next_x] = x
                return True
        return False

    def solve(self):
        res = 0
        for x in range(self.len_X):
            self.visited = set()
            res += self.dfs(x)
        return res

#################################################################################################


len_X, len_Y, E = map(int, input().split())     # len_X, len_Y: 部分集合に含まれる頂点の数　E: 辺の数


dinic = Dinic(len_X, len_Y)

for _ in range(E):
    x, y = map(int, input().split())
    dinic.add_edge(x,y)

# 増大路発見に成功したらTrue(=1)。合計することでマッチング数となる
print(dinic.solve())





Measured memory_bytes: 5768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;cin>>a>>b>>c>>d;
    if((c==a+1 || (c==1 && a==12)) && d==1){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
}

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

int main(){

	int i,j,k,count[200]={0},max,midx,lidx;
	char s[1000],tmp[200][32];

	fgets(s,1000,stdin);
	i=0;
	j=0;
	k=0;
	max=0;
	while(s[i]!='\0'){
		if(s[i]==' '){
			tmp[j][k]='\0';
			j++;
			i++;
			k=0;
			continue;
		}

		tmp[j][k++]=s[i++];
	}
	tmp[j++][k-1]='\0';

	for(i=0;i<j;i++){
		for(k=i+1;k<j;k++){
			if(!strcmp(tmp[i],tmp[k])) count[i]++;
		}
	}
	for(i=0;i<j;i++){
		if(count[i]>max){
			max=count[i];
			midx=i;
		}
	}
	max=0;
	for(i=0;i<j;i++){
		if(strlen(tmp[i])>max){
			max=strlen(tmp[i]);
			lidx=i;
		}
	}
	printf("%s %s\n",tmp[midx],tmp[lidx]);

	return 0;

}

Measured memory_bytes: 540
while n=gets
    break if (n.to_i)==0
    ans=Hash.new
    num=Array.new
    (n.to_i).times do
        i,h,w=gets.chomp.split.map(&:to_i)
        ans[i]=(22-w/((h/100.0)**2)).abs
        num<<i
    end
    num.sort!
    num.sort!{|a,b|ans[a]<=>ans[b]}
    p num.first
end

Measured memory_bytes: 6156
#include<bits/stdc++.h>
using namespace std;
	
int main()
{
	int n,k,m=0;//n人，k样东西
	cin>>n>>k; 
	int a[k+1],b[n+1],x;
	for(int i=1;i<=n;i++)
	b[i]=0;
	for(int i=1;i<=k;i++)
	{
		cin>>a[i];
		for(int p=1;p<=a[i];p++)
		{
			cin>>x;
			b[x]++;
		}
	}
	for(int i=1;i<=n;i++)
	if(b[i]==0)
	m++;
	cout<<m;
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
static const double eps = 1e-10;

class Point
{
public:
	double x, y;
	Point(double x = 0, double y = 0) : x(x), y(y){}

	Point operator + (Point p){ return(Point(x + p.x, y + p.y)); }
	Point operator - (Point p){ return(Point(x - p.x, y - p.y)); }
	Point operator * (double a){ return(Point(a * x, a * y)); }
	Point operator / (double a){ return(Point(x / a, y / a)); }

	double abs(){ return(sqrt(norm())); }
	double norm(){ return(x * x + y * y); }

	bool operator < (const Point& p) const
	{
		return(x != p.x ? x < p.x : y < p.y);
	}

	bool operator == (const Point& p) const
	{
		return(fabs(x - p.x) < eps && fabs(y - p.y) < eps);
	}
};
typedef Point Vector;

struct Segment
{
	Point p1, p2;
};
typedef Segment Line;

class Circle
{
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0): c(c), r(r){}
};

double dot(Vector a, Vector b)
{
	return(a.x * b.x + a.y * b.y);
}

double cross(Vector a, Vector b)
{
	return(a.x * b.y - a.y * b.x);
}

Point project(Segment s, Point p)
{
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	return(s.p1 + base * r);
}

Point reflect(Segment s, Point p)
{
	return(p + (project(s, p) - p) * 2.0);
}

void solve()
{
	Segment s;
	cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i)
	{
		Point p;
		cin >> p.x >> p.y;
		Point res = reflect(s, p);
		printf("%.10f %.10f\n", res.x, res.y);
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1248
n = int(input())
s = [input() for _ in range(n)]
ans = 0
w = 0
a = 0
b = 0

for c in s:
    ans += c.count("AB")
    if c[0] == "B" and c[-1] == "A":
        w += 1
    elif c[0] == "B":
        b += 1
    elif c[-1] == "A":
        a += 1

if a == b == 0:
    w -= 1
ans += max(w,0) + min(a,b)
print(ans)

Measured memory_bytes: 3700
#include <iostream>

using namespace std;

int main()
{
    // 変数を定義
    int a;
    int b;

    // 入力を変数に格納
    cin >> a;
    cin >> b;

    // 偶奇を判定
    if (a * b % 2 == 0)
    {
        // aとbをかけた結果を2で割り切れたら（偶数なら）
        cout << "Even" << endl;
    }
    else
    {
        // 偶数じゃないなら奇数
        cout << "Odd" << endl;
    }
}

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

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) cin >> e;
  int res = 0;
  for (int k = 0; k < n; ++k) {
    for (int j = 0; j < k; ++j) {
      for (int i = 0; i < j; ++i) {
        if (a[i] != a[j] and a[j] != a[k] and a[k] != a[i]) {
          res +=
              a[i] + a[j] > a[k] and a[i] + a[k] > a[j] and a[j] + a[k] > a[i];
        }
      }
    }
  }
  cout << res << '\n';
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define ll long long
using namespace std;



int main()
{
	int n;
	double sum = 0;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		sum += 1.0 / tmp;
	}

	printf("%.12f", 1.0 / sum);

	return 0;
}

Measured memory_bytes: 256
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    ll n,k;
    cin>>n>>k;
    ll t = n%k;
    print(min(abs(t-k), t));
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define NMAX 200005
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

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

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

int A,B,C,N,T,ans = 0,t[NMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	for (int i = 1; i < N; ++i)
	{
		ans += min(T,t[i]-t[i-1]);
	}
	ans += T;
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N >> T;
	for (int i = 0; i < N; ++i)
	{
		cin >> t[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void) {
    int width, height, x, y, r;
    cin >> width >> height >> x >> y >> r;

    string answer;    
    if (x - r < 0) {
        // left error
        answer = "No";
    } else if (x + r > width ) {
        // right error
        answer = "No";
    } else if (y - r < 0) {
        // down error
        answer = "No";
    } else if (y + r > height) {
        // up error
        answer = "No";
    } else {
        // ok
        answer = "Yes";
    }
    
    cout << answer << endl;
    
    return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a;i < b;i++)
#define rrep(i,a,b) for(int i = a;i >= b;i--)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << #x << ": " << x << endl;
typedef long long ll;
using namespace std;

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

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

   int a,b;
   cin >> a >> b;
   cout << (a-1)*(b-1) << endl;

   return 0;
}

Measured memory_bytes: 256
S = input()
if S[0] == "A":
    S_cpy = S.lstrip("A")
else:
    print("WA")
    exit()

if S[2:-1].count("C") == 1:
    S_cpy = S_cpy.replace("C", "")
else: 
    print("WA")
    exit()

if S_cpy.islower():
    print("AC")
else:
    print("WA")

Measured memory_bytes: 9084
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
  // problem B
  int K;
  cin >> K;
  string S;
  cin >> S;
  if (int(S.length()) > K) {
    for (int i = 0; i < K; i++){
      cout << S[i];
    }
    cout << "...";
  } else {
    cout << S;
  }
    return 0;
}

Measured memory_bytes: 3064
N = int(input())
S = list(str(input()) for _ in range(N))
S2 = sorted(S)
cnt1 = [0,]
cnt2 = [0,]*N
word = [0,]
for i in range(N-1):
    if S2[i] != S2[i+1]:
        cnt1.append(i+1)
        word.append(S2[i])
cnt2 = [0,]*len(cnt1)
for i in range(1,len(cnt1)):
    cnt2[i] = cnt1[i] - cnt1[i-1]
cnt2.append(N-sum(cnt2))
word.append(S2[N-1])
X = max(cnt2)
for i in range(len(cnt2)):
    if cnt2[i] == X:
        print(word[i])

Measured memory_bytes: 31792
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, mod, dp[3030][3030], p[10010010], res;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}

const int MAXS = 10010;
ll fact[MAXS+1], factr[MAXS+1], inv[MAXS+1];
ll comb(ll n, ll r) {
	if (fact[0]==0) {
		fact[0] = factr[0] = inv[1] = 1;
		for (int i=2; i<=MAXS; i++) inv[i] = inv[mod%i] * (mod-mod/i) %mod;
		for (int i=1; i<=MAXS; i++) fact[i] = fact[i-1]*i %mod, factr[i] = factr[i-1]*inv[i] %mod;
	}
	if (r<0 || n<r) return 0;
	return fact[n]*factr[r] %mod *factr[n-r] %mod;
}

int f(int k) {
	int ret = 0;
	rep(x,k+1) (ret += dp[k][x] * p[(n-k)*x] %mod) %= mod;
	return ret * mop(2,mop(2,n-k,mod-1)) %mod;
}

signed main() {
	cin >> n >> mod;
	dp[0][0] = 1;
	reps(i,1,n+1) rep(j,n+1) {
			if (j) (dp[i][j] += dp[i-1][j-1]) %= mod;
			(dp[i][j] += dp[i-1][j]*(j+1)) %= mod;
	}
	p[0] = 1;
	reps(i,1,10010010) p[i] = p[i-1]*2 %mod;
	rep(k,n+1) (res += comb(n,k) * f(k) * (k%2 ? -1 : 1) %mod + mod) %= mod;
	cout << res << endl;
}

Measured memory_bytes: 149760
import sys
from fractions import gcd
from operator import mul
from functools import reduce
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))
g = reduce(gcd, A)
if all((a // g) % 2 for a in A):
    print(round((m+1) / reduce(lambda x, y: x*y // gcd(x, y), A)))
else:
    print(0)

Measured memory_bytes: 17576
#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;

ll powmod(ll n, ll mod) //2^n % mod
{
	if (n == 0) return ll(1) % mod;
	if (n == 1) return ll(2) % mod;
	if (n % 2 == 0)
	{
		ll p = powmod(n/2,mod);
		return p*p % mod;
	}
	else
	{
		return powmod(n-1,mod) * 2 % mod;
	}
}

ll countbit(ll t)
{
	ll res = 0;
	rep(i,30)
	{
		if (ll(1 << i) & t) res++;
	}
	//cout << res << endl;
	return res;
}

int main()
{
	ll N;
	cin >> N;
	string S;
	cin >> S;
	ll cnt = 0;
	rep(i,N)
	{
		if (S[i] == '1') cnt++;
	}

	ll cntm1 = 0;
	if (cnt > ll(1)) // cnt-1で割るとき
	{
		rep(i,N)
		{
			if (S[i] == '1')
			{
				cntm1 = (cntm1 + powmod(N-1-i,cnt-1)) % (cnt-1);
			}
		}
	}
	//cout << "a " << cntm1 << endl;
	ll cntp1 = 0;
	rep(i,N)
	{
		if (S[i] == '1')
		{
			cntp1 = (cntp1 + powmod(N-1-i,cnt+1)) % (cnt+1);
		}
	}

	//cout << "b " << cntp1 << endl;
	rep(i,N)
	{
		ll ans = 1;
		if (S[i] == '0')
		{
			ll temp = (cntp1 + powmod(N-1-i,cnt+1)) % (cnt+1);
			//cout << temp << " ";
			while (temp != 0)
			{
				ll mo = countbit(temp);
				temp = temp % mo;
				ans++;
			}
			cout << ans << endl;
		}
		else
		{
			if (cnt == 1)
			{
				cout << "0" << endl;
			}
			else
			{
				ll temp = (cntm1 - powmod(N-1-i,cnt-1) + (cnt-1)) % (cnt-1);
				while (temp != 0)
				{
					ll mo = countbit(temp);
					temp = temp % mo;
					ans++;
				}
				cout << ans << endl;
			}
		}
	}
	return 0;
}

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

#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define pi pair<int,int>
#define ppi pair<int,pair<int,int>>
#define vv(t,A,r,c,val) vector<vector<t>> A(r,vector<t>(c, val))
#define vvn(t,A) vector<vector<t>> A
#define vvv(t,A,l,b,h) vector<vector<vector<t>>> A(l,vector<vector<t>>(b,vector<t>(h)))
#define vvvn(t,A) vector<vector<vector<t>>> A

int main() {
	sp;

	////////////////To Remove//////////////
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// ///////////////////////////////////////

	string s, t;
	cin>>s>>t;
	int sl = s.size(), tl = t.size();

	vv(int, dp, sl+1, tl+1, 0);

	for(int i = 1; i <= sl; ++i){
		for(int j = 1; j <= tl; ++j){
			if(s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
			else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}

	// for(int i = 0; i <= sl; ++i){
	// 	for(int j = 0; j <= tl; ++j){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }

	string result = "";
	int it = tl, is = sl;
	while(it > 0 && is > 0){
		if(t[it-1] == s[is-1]){
			result += t[it-1];
			it--;
			is--;
		}
		else if(dp[is-1][it] >= dp[is][it-1]){
			is--;
		}
		else it--;
	}


	reverse(result.begin(), result.end());

	cout<<result;

  	return 0;
}

Measured memory_bytes: 35584
#include<stdio.h>
int main()
{
    int n,a,b;
    scanf("%d",&n);
    if(n==1)
    {
        printf("Hello World\n");
    }
    if(n==2)
    {
        scanf("%d\n%d",&a,&b);
        printf("%d",a+b);
    }
    return 0;
}


Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()
    if S == U:
        print(A-1, B)
    else:
        print(A, B-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int Inf = 1e9;
const double EPS = 1e-9;



int main()
{
  int n, k ;
  cin >> n >> k ;
  vector<int> lon(n) ;
  int sum = 0 ;
  
  REP(i,n){
    cin >> lon.at(i) ;
  }
  
  sort(ALL(lon)) ;
  reverse(ALL(lon)) ;
  
  REP(i,k){
    sum += lon.at(i) ;
  }
  
  cout << sum <<endl;
  return 0 ;
}


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

namespace zyt
{
	const int N = 1e5 + 10;
	const int arr[] = {100, 101, 102, 103, 104, 105};
	bool f[N];
	int n;
	int work()
	{
		scanf("%d", &n);
		f[0] = true;
		for (int i = 0; i < 6; i++)
			for (int j = 0; j <= n - arr[i]; j++)
				f[j + arr[i]] |= f[j];
		if (f[n])
			puts("1");
		else
			puts("0");
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int main()
{
	for(int n,k;cin>>n>>k,n|k;){
		vi s(k);
		rep(i,k)
			cin>>s[i];
		rep(i,n)
			rep(j,k){
				int b;
				cin>>b;
				s[j]-=b;
			}
		
		cout<<(find_if(allof(s),bind2nd(less<int>(),0))==s.end()?"Yes":"No")<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main()
{
    int x;
    cin>>x;
    if(400<=x&&x<600){
        cout<<"8";
    }
    if(600<=x&&x<800){
        cout<<"7";
    }
    if(800<=x&&x<1000){
        cout<<"6";
    }
    if(1000<=x&&x<1200){
        cout<<"5";
    }

    if(1200<=x&&x<1400){
        cout<<"4";
    }

    if(1400<=x&&x<1600){
        cout<<"3";
    }
    if(1600<=x&&x<1800){
        cout<<"2";
    }
    if(1800<=x&&x<2000){
        cout<<"1";
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

#include <iostream>
#include <vector>
using namespace std;

//重複順列
vector<ll> buf;
void permutation(ll i, const ll size, const ll range_start, const ll range_end)
{
    if (i == size) {
      // ここで所望の作業を行う
      for(ll itr:buf){
        cout << itr;
      }
    }
    else{
        for(ll j = range_start; j <= range_end; ++j){
            buf[i] = j;
            permutation(i + 1, size, range_start, range_end);
        }
    }
}

int main(void)
{
  ll n, r = 0, w = 0, ans = 0;
  string C;
 cin >> n;
 cin >> C;
 for(ll i=0;i<n;i++){
   if(C[i]=='R'){
     r++;
   }else{
     w++;
   }
 }
 if(r<w){
   RAP(i, r){
     if(C[i]=='W'){
       ans++;
     }
   }
 }else{
   RAP(i,w){
     if(C[n-1-i]=='R'){
       ans++;
     }
   }
 }
  cout << ans << endl;
 return 0;
}


Measured memory_bytes: 3728
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		int D=nextInt();
		int T=nextInt();
		int S=nextInt();
		if(T*S<D)
			System.out.println("No");
		else
			System.out.println("Yes");
	}
	public static long lmod(long i, long j) {
	     return (i%j)<0?(i%j)+0+(j<0?-j:j):(i%j+0);
	 }
	static boolean isOK(int index,int key,ArrayList<Integer> a){
		if (a.get(index)>=key) return true;
	    else return false;
	}
	static int binary(int key,ArrayList<Integer> a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;
	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}



Measured memory_bytes: 32696
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

#define pi 3.141592653589

int main()
{
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    
    double x = 2*pi*(60*h-11*m)/720;
    
    double ans = (double) sqrt(a*a+b*b-2*a*b*cos(x));
    
    printf("%.12lf\n",ans);
}


Measured memory_bytes: 4140
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int a, b, c;cin >> a >> b >> c;
	if(a==b and b==c) cout << '1' << endl;
	else if(a==b or b==c or c== a)cout << '2' << endl;
	else cout << '3' << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <iomanip>

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	auto start = high_resolution_clock::now(); 

	double t, x;
	cin >> t >> x;
	cout << setprecision(8);
	cout << t/x; 

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())
x3 = y1 + x2 - y2
y3 = -x1 + x2 + y2
x4 = x1 + y1 - y2
y4 = -x1 + y1 + x2
print(x3,y3,x4,y4)

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

using namespace std;
 
int main() {
	
  string s;
  vector<char> v;
  
  cin >> s;
  
  for(int i = 0; i < s.length(); i++){
    if(s[i] == '0'){
      	v.push_back('0');
    }
    
    if(s[i] == '1'){
      	v.push_back('1');
    }
    
    if(s[i] == 'B'){
      if(!v.empty()){
 		v.pop_back();
      }
    }
  }
  
  for(int i = 0; i < v.size(); i++){
    cout << v[i];
  }
 

}

Measured memory_bytes: 256
n, k = list(map(int, input().split()))
def times(i):
    a = 0
    for x in range(0, k):
        if i*(2**x)>=k:
            a = round((1/n)*(0.50**x),15)
            break
    return a
       
ans = 0
for i in range(1, n+1):
        ans += times(i)
print(ans)

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

const int INF = 1e9 * 2;
int n, x, y, zx = 0, zm = INF, wx = -INF, wm = INF;

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> x >> y;

		zx = max(zx, x + y);
		zm = min(zm, x + y);
		wx = max(wx, x - y);
		wm = min(wm, x - y);
	}

	cout << max(zx - zm, wx - wm) << endl;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(void){
  int n,m;
  map<string, int> mp;
  char buf[16];
  
  scanf("%d", &n);
  for (int i=0; i<n; i++){
    scanf("%s", buf);
    if (mp.find(buf) != mp.end()){
      mp[buf]++;
    } else {
      mp[buf]=1;
    }
  }
  scanf("%d", &m);
  for (int i=0; i<m; i++){
    scanf("%s", buf);
    if (mp.find(buf) != mp.end()){
      mp[buf]--;
    } else {
      mp[buf]=-1;
    }
  }
  
  int mx = -10000;
  string ans = "";
  for (auto it=mp.begin(); it!=mp.end(); it++){
//    cout << it->first << " " << it->second << endl;
    if (it->second > mx){
      ans = it->first;
      mx = it->second;
    }
  }
  cout << (mx<0?0:mx) << endl;
  
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
sumA = [0]
for i in range(n):
    sumA.append(sumA[-1]+A[i])

ans = 0
csumA = Counter(sumA)
for key in csumA.keys():
    if csumA[key] > 1:
        ans += csumA[key]*(csumA[key]-1)//2
print(ans)

Measured memory_bytes: 44280
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H, W = map(int, input().split())
ans = 0


def ceil(x):
    return int((-x)//(1)*(-1))


def solve(a, b):
    """
    a,b = H,W or W,H
    aの方を三等分ぽく分解する
    """
    upper = ceil(a/3)
    lower = a//3
    l = [0]*3
    ret = float('inf')
    for i in range(lower, upper+1):
        if b % 2 == 0:
            l[0] = i*b
            l[1] = (a-i)*b//2
            l[2] = (a-i)*b//2
        else:
            l[0] = i*b
            l[1] = (a-i)*(b//2)
            l[2] = (a-i)*(b//2+1)
        ret = min(max(l)-min(l), ret, b)
    return ret


if H % 3 == 0 or W % 3 == 0:
    ans = 0
else:
    ans = min(solve(H, W), solve(W, H))
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 1e5 + 10;
struct node {
    int a, b, c;
} v[N];

bool cmp(node &x, node &y) {
    return x.c > y.c;
}


int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        v[i] = {a, b, a + b};
    }
    sort(v + 1, v + n + 1, cmp);
    LL ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 2) ans += v[i].a;
        else ans -= v[i].b;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1408
n = gets().to_i
an = gets().split(' ').map(&:to_i)

sum = 0
min = 10 ** 9
minus = 0

an.each {|ai|
	sum += ai.abs
	min = ai.abs if min > ai.abs
	minus += 1 if ai < 0
}

puts ((minus & 1) == 0 ? sum : sum - min * 2)


Measured memory_bytes: 8580
#include <bits/stdc++.h>
using namespace std;  
long long int Fac[200010]; 
long long int Pow(long long int a, int n, long long int m) {
	long long int powa[65];
  	powa[0] = a; 
  	for(int j = 0; j < 64; ++j){
     		powa[j+1] = (powa[j] * powa[j]) % m; 
  	}
	int c = n; 
  	long long int Q = 1; int k = 0; 
	while(c > 0){
  		if(c & 1) Q = (Q * powa[k]) % m; 
		c >>= 1; k++; 
	}
	return Q;
}
long long int Inv(long long int a, long long int m) {
	return Pow(a, m-2, m); 
}
long long int Comb(int n, int r, long long int m){
	if(r > n) return 0; 
	else return (((Fac[n] * Inv(Fac[n-r], m)) % m) * Inv(Fac[r], m)) % m; 
}
int main(){
	long long int P = 1e9+7; 
	Fac[0] = 1; 
	for(int i = 1; i <= 200007; i++){
		Fac[i] = (Fac[i-1] * i) % P; 
	}
	int N; long long int A, B, C; 
	cin >> N >> A >> B >> C; 
	long long int tmp1 = 0; long long int tmp2 = 0; 
	long long int Powa[100010] = {}; 
	long long int Powb[100010] = {}; 
	long long int Powc[100010] = {}; 
	long long int Bi[100010] = {}; 
	Powa[0] = 1; Powb[0] = 1; Powc[0] = 1; 
	for(int i = 1; i <= 100007; i++){
		Powa[i] = (Powa[i-1] * A) % P; 
		Powb[i] = (Powb[i-1] * B) % P; 
		Powc[i] = (Powc[i-1] * (100-C)) % P; 
	}
	for(int i = 0; i < N; i++){
		long long int p, q, r; 
		p = Powc[N-1-i]; 
		q = Powb[i]; 
		r = Comb(N-1+i, i, P); Bi[i] = r; 
		tmp1 += (((((p*q) % P) * r) % P) * ((long long) N+i)) % P; 
		tmp1 %= P; 
	}
	tmp1 *= Powa[N]; 
	tmp1 %= P; 
	for(int i = 0; i < N; i++){
		long long int p, q, r; 
		p = Powc[N-1-i]; 
		q = Powa[i]; 
		r = Bi[i]; 
		tmp2 += (((((p*q) % P) * r) % P) * ((long long) N+i)) % P; 
		tmp2 %= P; 
	}
	tmp2 *= Powb[N]; 
	tmp2 %= P; 
	long long int inverse, bunbo; 
	inverse = Inv(100 - C, P); 
	bunbo = Pow(inverse, 2*N, P); 
	cout << (((100 * (tmp1 + tmp2)) % P) * bunbo) % P << endl; 
}

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

using namespace std;

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

  int n,m;cin>>n>>m;
  int path[n+1][n+1];
  for(int i=0;i<n+1;i++)for(int j=0;j<n+1;j++) path[i][j]=0;
  for(int i=0;i<m;i++){
      int a,b;cin>>a>>b;
      path[a-1][b-1]=1;path[b-1][a-1]=1;
  }
  std::vector<int> v;
  for(int i=0;i<n;i++) v.push_back(i);
  int res=0;
  do{
      bool flag=true;
      for(int i=0;i<n-1;i++){
          if(!path[v[i]][v[i+1]]) flag=false;
      }
      if(flag) res++;
  }while(next_permutation(v.begin()+1,v.end()));
  cout<<res<<endl;
}


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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{
    int n,m;cin >> n >> m ;

    int a[31]={};
    for(int i=0;i<n;i++){
        int k;cin >> k;
        for(int j=0;j<k;j++){
            int tmp;cin >> tmp;
            a[tmp]++;
        }
    }

    int res=0;
    for(int i=1;i<=m;i++){
        if(a[i]==n) res++;
    }
    p(res)
} 

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

using namespace std;

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

	ll n, k, prod=1;
	cin >> n >> k;
	vector<ll> v(n);
	for(ll i=0; i<n; i++){
        cin >> v[i];
        if(i>=k){
            double tmp=(double)v[i]/v[i-k];
            if(tmp>1.0)
                cout << "Yes" << endl;
            else
                cout << "No" << endl;
        }
	}
	return 0;
}


Measured memory_bytes: 4776
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    auto A = aryread();
    A.sort();

    auto fact = new long[](N + 1);
    fact[0] = 1;
    foreach (i; 1 .. N + 1)
        fact[i] = fact[i - 1] * i % MOD;
    auto factinv = new long[](N + 1);
    foreach (i; 0 .. N + 1)
        factinv[i] = powmod(fact[i], MOD - 2, MOD);

    T combination_mod(T = long)(T n, T k, T m)
    {
        if (n < k)
            return 0;
        return (fact[n] * factinv[n - k] % MOD) * factinv[k] % MOD;
    }

    long ans;
    foreach (i; 0 .. N)
    {
        long cnt = combination_mod(i, K - 1, MOD);
        long r = cnt * A[i] % MOD;
        ans = (ans + r) % MOD;
    }
    foreach (i; 0 .. N)
    {
        long cnt = combination_mod(N - i - 1, K - 1, MOD);
        long r = cnt * A[i] % MOD;
        ans = (MOD + ans - r) % MOD;
    }
    writeln(ans);
}

T powmod(T = long)(T x, T n, T m)
{
    if (n < 1)
        return 1;
    if (n & 1)
    {
        return x * powmod(x, n - 1, m) % m;
    }
    T tmp = powmod(x, n / 2, m);
    return tmp * tmp % m;
}


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

  template<typename T>
  void chmax(T &a,T b){
    if(a<b)a=b;
  }

signed main(){
  int n,m;cin>>n>>m;
  vector<int> h(n);
  for(int i=0;i<n;i++)cin>>h[i];
  vector<int> edge[n];
  while(m--){
    int u,v;cin>>u>>v;
    edge[--u].push_back(--v);
    edge[v].push_back(u);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int ok=1;
    for(int p:edge[i])ok&=(h[p]<h[i]);
    ans+=ok;
  }
  cout<<ans<<endl;
}


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

signed main() {
    string s;
    cin >> s;
    int r = 0, b = 0;
    rep(i, s.length()){
        if(s[i] =='0') r++;
        else if(s[i] == '1') b++;
    }
    /* cout << r << " " << b << " "; */
    cout << 2 * min(r, b) << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	vector<int> a(n);
	for(auto &x : a){
		cin>>x;
	}
	sort(a.begin(), a.end());
	ll ans = 0;
	for(int i = 0; i + 1 < n; i++){
		for(int j = i + 1; j < n; j++){
			// cout<<a[i]<<" "<<a[j]<<" "<<(lower_bound(a.begin(), a.end(), a[i] + a[j]) - a.begin())<<endl;
			ans += lower_bound(a.begin(), a.end(), a[i] + a[j]) - a.begin();
			ans -= j + 1;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
using System;

namespace CA {
	class Program {
		static void Main(string[] args) {
			while (true) {
				string[] s = Console.ReadLine().Split(' ');
				if (s[1] == "?") break;
				int a = int.Parse(s[0]), b = int.Parse(s[2]);
				switch (s[1]) {
					case "+":
						Console.WriteLine(a + b);
						break;
					case "-":
						Console.WriteLine(a - b);
						break;
					case "*":
						Console.WriteLine(a * b);
						break;
					case "/":
						Console.WriteLine(a / b);
						break;
				}
			}
		}
	}
}

Measured memory_bytes: 9176
#include <cstdio>
#include <iostream>

using namespace std;

#define MAXN 100000

int A[MAXN + 1],B[MAXN];

int main(){
    int N;

    scanf("%d",&N);

    for(int i = 0;i < N + 1;++i)
        scanf("%d",&A[i]);
    for(int i = 0;i < N;++i)
        scanf("%d",&B[i]);

    long long ans = 0;

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

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する
ll mod = 1000000007;


int main() {
    vector<int> v;
    REP(i, 0, 3) {
        int t;
        cin >> t;
        v.push_back(t);
    }
    sort(v.begin(), v.end());
    if (v[0] % 2 == 0 || v[1] % 2 == 0 || v[2] % 2 == 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << (ll) v[0] * (ll) v[1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<cmath>
#include<iomanip>
#define ll long long
using namespace std;
#define rep(n) for(int i=0;i<n;i++)
#define Rrep(n) for(int i=n-1;i>=0;i--)
#define rep2(a,n) for(int i=a;i<=n;i++)
int main(void){
    // Your code here!
int n;
cin>>n;
vector<int> vec(n-1), out(n,0);
rep(n-1){
    cin>>vec[i];
}
out[n-1]=vec[n-2];

int i=0;
for(i=n-2;i>=1;i--){
    if(vec[i-1]<=vec[i])
        out[i]=vec[i-1];
    else
        out[i]=vec[i];     
}

out[i]=max(out[i+1], vec[i]);

ll sum=0;
rep(n){
    sum+=out[i];
}
cout<<sum;
}




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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n, a[101010];
void solve(){
	cin >> n;
	i64 sum = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		sum += abs(a[i]-a[i-1]);
	}
	sum += abs(a[n]);
	
	for(int i = 1; i <= n; i++){
		cout << sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i+1]-a[i-1]) << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

long long h, w, a, b;
long long x[200010], y[200010];
long long mod = 1e9+7;
long long inv(long long n){
	long long res = 1;
	long long tmp = n;
	for(int i=0; ((mod-2)>>i)>0; ++i){
		if(((mod-2)>>i)%2==1)
			res = res * tmp % mod;
		tmp = tmp * tmp % mod;
	}
	return res;
}
long long ans;
long long comb(long long n, long long m){
	if(m == 0 || n == m) return 1;
	long long res = x[n] * y[m] % mod;
	res = res * y[n-m] % mod;
//	cout << n << " " << m << " " << res << "\n";
	return res;
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> h >> w >> a >> b;
	x[0] = 1;
	for(int i=1; i<=200000; ++i)
		x[i] = (x[i-1] * i) % mod;
//	for(int i=0; i<10; ++i)
//		cout << i << " " << x[i] << "\n";
	for(int i=0; i<=200000; ++i)
		y[i] = inv(x[i]);
//	for(int i=0; i<10; ++i)
//		cout << i << " " << x[i] << " " << y[i] << "\n";
	for(int i=0; i<w-b; ++i){
		ans += comb(h-a-1+b+i, h-a-1) * comb(w+a-b-2-i, a-1) % mod;
		ans %= mod;
//		cout << i << " " << ans << "\n";
	}
	cout << ans << "\n";
}

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

using namespace std;

void get_uppercase(char *, char *, char *);

int main()
{
	string s1, s2, s3, ans;
	char ini_s1, ini_s2, ini_s3;
	cin >> s1 >> s2 >> s3;
	ini_s1 = s1[0];
	ini_s2 = s2[0];
	ini_s3 = s3[0];
	get_uppercase(&ini_s1, &ini_s2, &ini_s3);
	ans = ans + ini_s1 + ini_s2 + ini_s3;
	cout << ans << endl;
	return 0;
}
void get_uppercase(char *ini_s1, char *ini_s2, char *ini_s3)
{
	*ini_s1 = toupper(*ini_s1);
	*ini_s2 = toupper(*ini_s2);
	*ini_s3 = toupper(*ini_s3);
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(input())


def solve(h_, w_):
    count = 0
    for h in range(max(0, h_ - 1), min(h_ + 2, H)):
        for w in range(max(0, w_ - 1), min(w_ + 2, W)):
            if S[h][w] is '#':
                count += 1
    return count


for n in range(H):
    ans = []
    for i in range(W):
        if S[n][i] is '#':
            ans.append('#')
        else:
            ans.append(str(solve(n, i)))
    print(''.join(ans))


Measured memory_bytes: 3188
/*
[m-solutions2019] C - Best-of-(2n-1)
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 100000;
const int MOD = 1e9 + 7;

ll extgcd(ll a, ll b, ll& x, ll& y) {
    ll d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

ll mod_inv(ll a, ll m) {
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x) % m;
}

class gf {
public:
    int n;
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf inv() { return gf(mod_inv(n, MOD)); }
    gf operator+(gf x) { return gf((n + x.n) % MOD); }
    gf operator-(gf x) { return gf((n - x.n + MOD) % MOD); }
    gf operator*(gf x) { return gf((1LL * n * x.n) % MOD); }
    gf operator/(gf x) { return *this * x.inv(); }
    gf operator+(int x) { return gf((n + x) % MOD); }
    gf operator-(int x) { return gf((n - x + MOD) % MOD); }
    gf operator*(int x) { return gf((1LL * n * x) % MOD); }
    gf operator/(int x) { return *this * mod_inv(x, MOD); }
};

int N, A, B, C;
gf pa[2 * MAX_N + 1], pb[2 * MAX_N + 1], ph[2 * MAX_N + 1];
gf fact[2 * MAX_N + 1];

ll solve() {
    fact[0] = fact[1] = 1;
    for (int i = 2; i <= 2 * MAX_N; i++) {
        fact[i] = fact[i - 1] * i;
    }

    pa[0] = 1;
    pb[0] = 1;
    ph[0] = 1;
    for (int i = 1; i <= 2 * N; i++) {
        pa[i] = pa[i - 1] * A;
        pb[i] = pb[i - 1] * B;
        ph[i] = (ph[i - 1] / (100 - C));
    }

    gf ans = 0;
    for (int i = N; i <= 2 * N - 1; i++) {
        gf tmp = fact[i - 1] / (fact[N - 1] * fact[i - N]);
        tmp = tmp * (pa[N] * pb[i - N] + pa[i - N] * pb[N]) * i * 100;
        tmp = tmp * ph[i + 1];
        ans = ans + tmp;
    }

    return ans.n;
}

int main() {
    cin >> N >> A >> B >> C;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
int main(){
  int mid,fin,again;
  while(1){
    int sum=0;
    scanf("%d%d%d",&mid,&fin,&again);
    if(mid==-1&&fin==-1&&again==-1)break;
    if(mid==-1||fin==-1) printf("F\n");
    else if(mid+fin>=80) printf("A\n");
    else if(mid+fin>=65) printf("B\n");
    else if(mid+fin>=50) printf("C\n");
    else if(mid+fin>=30){
      if(again>=50) printf("C\n");
      else printf("D\n");
    }
    else printf("F\n");
  }
  return 0;
}


Measured memory_bytes: 2144
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
s=0
for i in range(n):
  for j in range(n):
    if i<=j:continue
    s+=math.sqrt(sum([(y-z)**2 for y,z in zip(x[i],x[j])])).is_integer()
print(s)

Measured memory_bytes: 3060
import sys, collections, heapq
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def dijkstra(G, s):
    que = []
    d = [INF]*len(G)
    d[s] = 0
    heapq.heappush(que, (d[s], s))

    while que:
        p = heapq.heappop(que)
        v = p[1]
        if d[v] < p[0]: continue
        for e in G[v]:
            if d[e[0]] > d[v] + e[1]:
                d[e[0]] = d[v] + e[1]
                heapq.heappush(que, (d[e[0]], e[0]))
    return d

def resolve():
    n = I()
    G = [[] for _ in range(n)]
    for i in range(n):
        ukvc = LI()
        u = ukvc[0]
        k = ukvc[1]
        for j in range(k):
            v = ukvc[2*j+2]
            c = ukvc[2*j+3]
            G[u].append((v, c))

    ans = dijkstra(G, 0)
    for i, e in enumerate(ans):
        print(i, e)

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 6536
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>

using namespace std;

int a[10];

int main()
{
    int t;
    cin >> t;

    while(t--)
    {
        for(int i = 0; i < 10; ++i)
        {
            cin>>a[i];
        }

        vector<int> x[2];
        auto lar = &x[0];
        auto sma = &x[1];

        bool ans = true;

        for(int i = 0; i < 10; ++i)
        {
            int c = a[i];

            if(i == 0){
                lar->push_back(c);
            }
            else if(c >= lar->back())
            {
                lar->push_back(c);
            }
            else if(sma->empty())
            {
                sma->push_back(c);
                
            }
            else if(c >= sma->back())
            {
                sma->push_back(c);
                
            }
            else
            {
                ans = false;
                break;
            }
            
        }
        if(ans)
            cout<<"YES" <<endl;
        else
            cout<<"NO" <<endl;

    }
}


Measured memory_bytes: 3060