akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define tlll tuple<ll,ll,ll>
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<tlll,vector<tlll>,greater<tlll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll h,w;
  cin>>h>>w;
  ll sx,sy,ex,ey;
  cin>>sx>>sy;
  cin>>ex>>ey;
  sx--;ex--;sy--;ey--;
  vstr s(h);
  rep(i,h) cin>>s[i];
  PQR que;
  que.pu(tlll(0,sx,sy));
  vvll t(h,vll(w,INF));
  t[sx][sy]=0;
  while(sz(que)){
    tuple<ll,ll,ll> now=que.top();que.pop();
    if(t[get<1>(now)][get<2>(now)]<get<0>(now)) continue;
    bool hh=false;
    rep(i,4){
      ll nx=get<1>(now)+dx[i];
      ll ny=get<2>(now)+dy[i];
      if((nx>=0)&&(nx<h)&&(ny>=0)&&(ny<w)&&s[nx][ny]!='#'&&t[nx][ny]>t[get<1>(now)][get<2>(now)]){
        t[nx][ny]=t[get<1>(now)][get<2>(now)];
        que.pu(tlll(t[nx][ny],nx,ny));
      }
      else if(nx>=0&&nx<h&&ny>=0&&ny<w&&s[nx][ny]=='#') hh=true;
    }
    if(hh){
      for(int i=get<1>(now)-2;i<=get<1>(now)+2;i++){
        for(int j=get<2>(now)-2;j<=get<2>(now)+2;j++){
          ll nx=i;
          ll ny=j;
          if(nx>=0&&nx<h&&ny>=0&&ny<w&&s[nx][ny]!='#'&&t[nx][ny]>t[get<1>(now)][get<2>(now)]+1){
            t[nx][ny]=t[get<1>(now)][get<2>(now)]+1;
            que.pu(tlll(t[nx][ny],nx,ny));
          }
        }
      }
    }
  }
  if(t[ex][ey]==INF) COUT(-1);
  else COUT(t[ex][ey]);
}

Measured memory_bytes: 13576
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int a,b;cin>>a>>b;
    int ans=a-2*b;
    if(ans<0)
        ans=0;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <queue>
#include <stdlib.h>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint n, d;
llint a[200005];
priority_queue< P, vector<P>, greater<P> > Q;
llint l[200005], r[200005];

int main(void)
{
	cin >> n >> d;
	for(int i = 1; i <= n; i++) cin >> a[i];
	a[0] = a[n+1] = inf;
	for(int i = 1; i <= n; i++){
		l[i] = i-1, r[i] = i+1;
	}
	
	llint ans = 0;
	for(int i = 1; i <= n; i++) Q.push(make_pair(a[i], i));
	while(Q.size()){
		llint p = Q.top().second;
		Q.pop();
		
		if(l[p] > 0 && l[p] <= n){
			ans += d + a[p] + a[l[p]];
			a[l[p]] = min(a[p]+d, a[l[p]]);
			r[l[p]] = 0;
			Q.push(make_pair(a[l[p]], l[p]));
			a[p] = min(a[p], a[l[p]]+d);
			l[p] = 0;
			Q.push(make_pair(a[p], p));
		}
		else if(r[p] > 0 && r[p] <= n){
			ans += d + a[p] + a[r[p]];
			a[r[p]] = min(a[p]+d, a[r[p]]);
			l[r[p]] = 0;
			Q.push(make_pair(a[r[p]], r[p]));
			a[p] = min(a[p], a[r[p]]+d);
			r[p] = 0;
			Q.push(make_pair(a[p], p));
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 11120
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;

    bool ok = true;
    REP(i,3) {
        if (s[i] == s[i+1]) ok = false;
    }

    if (ok) cout << "Good" << endl;
    else cout << "Bad" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = int64_t;
using VL = vector<ll>;
using VD = vector<double>;
using VVL = vector<VL>;

#define FOR(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i < (i ## xxxx_end); ++i)
#define FORD(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i > (i ## xxxx_end); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPD(i, n) FORD(i, n - 1, -1)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}

#define INF 1000000000000
#define MOD 10000007

ll N;
VVL ABC, dp;

void solve() {
    cin >> N;
    ABC = VVL(N, VL(3));
    for (auto &i : ABC) cin >> i[0] >> i[1] >> i[2];
    dp = VVL(N + 1, VL(3, 0));
    FOR(i, 1, N + 1) {
        REP(j, 3) {
            REP(k, 3) {
                if(j == k)  continue;
                chmax(dp[i][j], dp[i - 1][k] + ABC[i - 1][j]);
            }
        }
    }
    ll ans = 0;
    for(auto& i: dp[N]) {
        chmax(ans, i);
    }
    print(ans);
}

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

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 400

int main() {
  int n;
  cin >> n;
  int s[n], l[n], p[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> l[i] >> p[i];
  }
  int dp[n + 1][MAX];
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < MAX; j++) {
      dp[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < MAX; j++) {
      if (j < s[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        for (int k = l[i]; k >= s[i]; k--) {
          if (j - k < 0) continue;
          dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - k] + p[i]);
        }
      }
    }
  }
  int m;
  cin >> m;
  int ans[m];
  for (int i = 0; i < m; i++) {
    int w;
    cin >> w;
    if (dp[n][w] == 0) {
      cout << -1 << endl;
      return 0;
    }
    ans[i] = dp[n][w];
  }
  for (int i = 0; i < m; i++) {
    cout << ans[i] << endl;
  }
  /*
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= 10; j++) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */
  return 0;
}



Measured memory_bytes: 3700
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
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(){
    long long a , b , n;
    cin >> a >> b >> n;
    if(b-1 > n){
      cout << (a*n)/b << endl;
    }
    else cout << (a*(b-1))/b << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  int a[n], sum  =0 ;
  for(int i =0 ; i<n ; i++)cin>>a[i];
  sort(a, a+n);
  for(int i = 0 ;i < n-1;i++) sum+=a[i];
  sum>a[n-1]?cout<<"Yes"<<endl:cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
/// >>In The Name Of God
/// >>ALIREZANA

#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define sz(x) (int)(x).size()
#define smin(x,y) (x) = min(x,y)
#define smax(x,y) (x) = max(x,y)
#define all(x) (x).begin(),(x).end()
#define mem(x,y) memset(x,y,sizeof(x))
#define _ ios_base::sync_with_stdio(0)\
                ,cin.tie(0),cout.tie(0);

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int M4 = 1e4+10, M5 = 1e5+10, M6 = 1e6+10;

int main()
{_
	int a, b;
	cin >> a >> b;
    if(a >= 13)
        return cout << b, 0;
    if(a >= 6)
        return cout << b/2, 0;
    cout << 0;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
int n,m,sum,ans,fac[2010],ifc[2010];
int pow(int k,int i)
{
	int t=1;
	while(i)
	{
		if(i&1) t=1ll*t*k%mod;
		k=1ll*k*k%mod;i>>=1;
	}
	return t;
}
int C(int x,int y)
{
	if(x<y) return 0;
	return 1ll*fac[x]*ifc[y]%mod*ifc[x-y]%mod;
}
int main()
{
	scanf("%d%d",&n,&m);fac[0]=1;int x,y,mxn=max(n,m);ans=n+1;
	for(int i=1;i<=mxn+1;++i) fac[i]=1ll*fac[i-1]*i%mod;
	ifc[mxn+1]=pow(fac[mxn+1],mod-2);
	for(int i=mxn;~i;--i) ifc[i]=1ll*ifc[i+1]*(i+1)%mod;
	for(int i=1;i<=m;++i)
		for(int j=1;j<=m-i;++j)
		{
			x=m-i;y=x-j;
			sum=1ll*C(x+i-1,x)*C(y+j-1,y)%mod;
			sum=1ll*sum*C(n-x-y+2,2)%mod;
			ans+=sum;if(ans>=mod) ans-=mod;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  string s;
  cin >> s;
  string t;
  if (s == "Sunny") t = "Cloudy";
  if (s == "Cloudy") t = "Rainy";
  if (s == "Rainy") t = "Sunny";

  cout << t << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long int> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
const ll N = 1e9+7;



ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int diff(string a,string b){
    int dc=0;
    fore(i,a.length()){
        if(a[i]!=b[i])dc++;
    }
    return dc;
}
int main()
 {  fast();
     ll t,n,k,x,y;
    t=1;
    while(t--){
      string s;
      cin>>s;
       int flag=1;
      int arr[26]={0};
      fore(i,s.length()){
        if(((int)s[i]-(int)'a')>=0)
          arr[s[i]-'a']++;
    }
     
      fore(i,26)
      {  if(arr[i]%2!=0)
      {flag=0;
       break;}
      }
	
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;}}

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

int main(){
    string s; cin >> s;
    int n = s.size();
    vector<int> amari(n+1);
    map<int,int> mp;
    amari[0] = 0;
    int a = 1;
    for(int i = 0;i < n;++i){
        amari[i+1] = ((s[n-1-i]-'0')*a+amari[i])%2019;
        a = a*10%2019;
    }
    rep(i,n+1) mp[amari[i]]++;
    ll ans = 0;
    for(auto x : mp){
        int y = x.second;
        ans += y*(y-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4444
N = int(input())
As = list(map(int,input().split()))
c = int(As[0])
i = 0
f = True
if 0 in As:
  print("0")
else:
  for x in As:
    if i == 0:
      i += 1
      continue
    c = c * x 
    if 1000000000000000001 <= c:
      print("-1")
      f = False
      break
  if f:
    print(c)


Measured memory_bytes: 84776
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::VecDeque;

fn main() {
    input!{
        h: usize,
        w: usize,
        v: [chars; h]
    }
    let mut tab: Vec<Vec<usize>> = vec![vec![h + w; w]; h];
    let mut q: VecDeque<(usize, usize)> = VecDeque::new();
    for i in 0..h {
        for j in 0..w {
            if v[i][j] == '#' {
                tab[i][j] = 0;
                q.push_back((i, j));
            }
        }
    }
    while !q.is_empty() {
        let (x, y) = q.pop_front().unwrap();
        if x < h - 1 && tab[x + 1][y] == h + w {
            tab[x + 1][y] = tab[x][y] + 1;
            q.push_back((x + 1, y));
        }
        if x > 0 && tab[x - 1][y] == h + w {
            tab[x - 1][y] = tab[x][y] + 1;
            q.push_back((x - 1, y));
        }
        if y < w - 1 && tab[x][y + 1] == h + w {
            tab[x][y + 1] = tab[x][y] + 1;
            q.push_back((x, y + 1));
        }
        if y > 0 && tab[x][y - 1] == h + w {
            tab[x][y - 1] = tab[x][y] + 1;
            q.push_back((x, y - 1));
        }
    }
    println!("{}", tab.iter().map(|l| l.iter().max().unwrap()).max().unwrap());
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a+b<c+d) {
    cout << "Right" << endl;
  } else if (a+b>c+d) {
    cout << "Left" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}


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

int main () {

    int N, H, W;
    cin >> N >> H >> W;

    int ans = 0;

    for (int i = 0; i < N; i++) {

        int a, b;
        cin >> a >> b;

        if (a >= H && b >= W) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

const ll MOD = 1e9 + 7LL;
const int MAXN = 1e5+1;
int n, k;

vi adj[MAXN];

ll resenje = 0LL;

void dfs(int s, int prosli, bool manje)
{
    if(manje)
        return;

    int brojac = 2;

    for(auto e : adj[s])
    {
        if(e == prosli)
            continue;

        ll zaMnoziti = (ll)k-(ll)brojac;
        ++brojac;

        if(s == 1)
            ++zaMnoziti;

        if(zaMnoziti <= 0)
        {
            resenje = 0LL;
            manje = true;
            return;
        }

        resenje = (resenje * zaMnoziti) % MOD;

        dfs(e, s, manje);
    }
}

ll modPow(ll a, ll n)
{
    if(n == 0)
        return 1LL;
    ll pola = modPow(a, n/2) % MOD;
    ll celo = (pola*pola) % MOD;

    if(n % 2 == 0)
    {
        return celo;
    }
    else
    {
        return (celo*a)%MOD;
    }
}

int main()
{
    cin >> n >> k;
    resenje = (ll)k;

    for(int i = 0; i < n-1; ++i)
    {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    dfs(1, -1, false);

    cout << resenje << '\n';

    return 0;
}


Measured memory_bytes: 11520
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

N = int(input())

if N == 1:
    T = int(input())
    print(T)
    exit()

T = []
for i in range(N):
    T.append(int(input()))
    
lcm_T = lcm(T[0], T[1])
for i in range(2, N):
    lcm_T = lcm(lcm_T, T[i])
    
print(lcm_T)

Measured memory_bytes: 3064
import bisect

n = int(input())
a = list(map(int,input().split()))

a.sort()

idx = bisect.bisect_left(a,a[-1]/2)

if idx == 0:
    print(a[-1],a[idx])
else:
    x,y = a[idx-1],a[idx]
    if y - a[-1]/2 < a[-1]/2 - x:
        print(a[-1],y)
    else:
        print(a[-1],x)


Measured memory_bytes: 14052
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def v(n):
        return [n*10%k, (n+1)%k]
    k = I()
    d = [float("inf")]*k
    d[1] = 1
    q = deque([1])
    while q:
        x = q.popleft()
        vx = v(x)
        dx = d[x]
        for c in range(2):
            nd = dx+c
            y = vx[c]
            if nd < d[y]:
                d[y] = nd
                if c:
                    q.append(y)
                else:
                    q.appendleft(y)
    print(d[0])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 47180
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N;
  cin>>N;

  set<int> se;

  rep(i,N){
    int aa;
    cin>>aa;
    se.insert(aa);
  }

  cout << se.size()-(se.size()%2==0) <<"\n";

}
//-----------------------------------
int main(){
  //cin.tie(nullptr);
  //ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 4992
import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      long A = Long.parseLong(sc.next());
      long B = Long.parseLong(sc.next());
      long N = Long.parseLong(sc.next());
      double ans = 0;
      if(N >= B){
        ans = Math.floor(A*(B-1)/B) - A * Math.floor((B-1)/B);
        System.out.println((long)ans);

      }else{
        ans = Math.floor(A*N/B) - A * Math.floor(N/B);
        System.out.println((long)ans);

      }
  }
}


Measured memory_bytes: 35524
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = 400 + 10;
// make sure N size is correctttt!!!!!!!!!


int n, h, w, black, white;
int c[N][N];
bool vis[N][N];

const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};

void dfs(int x, int y, int c){
   if(x < 1 or y < 1 or x > h or y > w)
      return ;

   if(vis[x][y])
      return ;

   if(::c[x][y] != c)
      return ;

   vis[x][y] = 1;

   black += ::c[x][y];
   white += !(::c[x][y]);

   for (int i = 0; i < 4; ++i)
      dfs(x+dx[i], y+dy[i], !c);
}

int32_t main(){_

   cin>>h>>w;

   for (int i = 1; i <= h; ++i)
   {
      for (int j = 1; j <= w; ++j)
      {
         char c;
         cin>>c;
         ::c[i][j] = (c == '#');
      }
   }

   int ans = 0;
   for (int i = 1; i <= h; ++i)
   {
      for (int j = 1; j <= w; ++j)
      {
         if(vis[i][j])continue;
         black = 0, white = 0;
         dfs(i, j, c[i][j]);
         ans += black * white;
      }
   }

   cout<<ans;
   //make sure N size is correct!!!!!!!!!
   return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N;
    cin >> N;
    vector<lint> A(N);
    REP(i, N) cin >> A[i];
    lint sum = 0;
    REP(i, N) sum ^= A[i];
    vector<lint> ans(N);
    REP(i, N) ans[i] = sum ^ A[i];
    REP(i, N) cout << ans[i] << (i!=N-1 ? " " : "");
    cout << "\n";
}

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

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  
  LL ans = RepSqu(2,n,MOD) -1;
  ans += MOD*2;
  
  
  LL ca = 1;
  LL cb = 1;
  REP(i,a){
    ca*= n-i;
    ca %= MOD;
    ca *= RepSqu(a-i,MOD-2,MOD);
    ca %= MOD;
  }
  REP(i,b){
    cb*= n-i;
    cb %= MOD;
    cb *= RepSqu(b-i,MOD-2,MOD);
    cb %= MOD;
  }
  
  ans = ans-ca-cb;
  
  cout << ans%MOD << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define fs first
#define sc second
#define P pair<int, int>
#define mk_p make_pair
const int N = 2e5 + 11;
int n, cnt1, cnt2;
LL ps[N], K, ng[N];
bool check1(LL x){
	LL ans = 0;
	int l = 1, r = cnt2;
	while(l <= r){
		while(r >= l && ng[r] * ng[l] <= x)r--;
		if(l > r)break;
		ans += r - l;
		l++;
	}
//	printf("ans1=%lld ", ans);
	l = 1, r = cnt1;
	while(l <= cnt1){
		while(ps[l] * ps[r] > x && r > l)r--;
		ans += cnt1 - r;
		if(r == l)r++;
		l++;
	}
//	printf("ans2=%lld\n", ans - lst);
	return 1LL * (n - 1) * n / 2 - ans >= K;
}
bool check2(LL x){
	int l = 1, r = 1;
	LL ans = 0;
	while(l <= cnt2 && r <= cnt1){
		while(ng[l] * ps[r] > x && r <= cnt1)r++;
		ans += cnt1 - r + 1;
		l++;
	}
	return ans >= K;
}
int main(){
	cin>>n>>K;
	LL x;
	for(int i = 1;i <= n; i++){
		scanf("%lld", &x);
		if(x <= 0)ng[++cnt2] = x;
		else ps[++cnt1] = x;
	}
	sort(ps + 1, ps + 1 + cnt1);
	sort(ng + 1, ng + 1 + cnt2);
	if(1LL * cnt1 * cnt2 < K){
//		K -= 1LL * cnt1 * cnt2;
		LL l = 0, r = 1e18, ans = 1e18;
		while(l <= r){
			LL mid = l + r >> 1;
//			printf("mid=%lld\n", mid);
			if(check1(mid))r = mid - 1, ans = mid;
			else l = mid + 1;
		}
		cout<<ans<<endl;
	}
	else{
		LL l = -1e18, r = 0, ans = 0;
		while(l <= r){
			LL mid = l + r >> 1;
			if(check2(mid))r = mid - 1, ans = mid;
			else l = mid + 1;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1792
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef double Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	while(cin>>n,n){
		vvi in(n,vi(8));
		rep(i,n)rep(j,8)cin>>in[i][j];
		vip w;
		rep(i,n)loop(j,i+1,n){
			double d[8];
			rep(k,8)d[k]=in[i][k]+in[j][k]*(k<6?-1:1);
			double a=d[3]*d[3]+d[4]*d[4]+d[5]*d[5]-d[7]*d[7];
			double b=d[0]*d[3]+d[1]*d[4]+d[2]*d[5]+d[6]*d[7];
			double c=d[0]*d[0]+d[1]*d[1]+d[2]*d[2]-d[6]*d[6];
			b*=2;
			if(b*b-4*a*c+EPS<0)continue;
			double D=sqrt(EPS+b*b-4*a*c);
			double t1=(-b+D)/2/a;
			double t2=(-b-D)/2/a;
			if(t1>0)w.pb({t1,{i,j}});
			if(t2>0)w.pb({t2,{i,j}});
		}
		sort(all(w));
		vector<int> co(n,1);
		vi out(n);
		rep(i,n)out[i]=in[i][6]/in[i][7];
		rep(i,w.size()){
			int a=w[i].second.first;
			int b=w[i].second.second;
			double t=w[i].first;
			if(co[a]&&co[b]&&out[a]>t&&out[b]>t){
				co[a]=co[b]=0;
				out[a]=out[b]=w[i].first;
			}
		}
		rep(i,n)cout<<shosu(9)<<out[i]<<endl;
	}
}
/*
	(dx+vx*t)^2+(dy+vy*t)^2+(dz+vz*t)^2=(dr-vr*t)^2
	(vx^2+vy^2+vz^2-vr^2)t^2+2(dxvx+dyvy+dzvz+drvr)*t
		+dx^2+dy^2+dz^2-dr^2
		
	
*/




Measured memory_bytes: 4316
n = gets.to_i
h = gets.split.map(&:to_i)
ans = true
h[0] -= 1
(1...n).each do |i|
    if h[i] > h[i-1]
        h[i] -= 1
    elsif h[i] < h[i-1]
        ans = false
        break
    end
end
puts (ans ? "Yes" : "No")

Measured memory_bytes: 8580
# C - Sentou
N,T = map(int, input().split())
t = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(N-1):
    tmp = t[i]
    if tmp <= T:
        if t[i+1]-t[i] >= T:
            ans += T
        else:
            ans += t[i+1]-t[i]
    else:
        if t[i+1]-t[i] >= T:
            ans += T
        else:
            ans += t[i+1]-t[i]
ans += T
print(ans)

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

int main() {
  int n, a;
  a =1;
  cin>>n;
  
  vector<int>vect(n);
  for(int i = 0; i<n; i++){
    cin>> vect.at(i);
  }
  
  sort(vect.begin(), vect.end());  
  
  for(int i = 1; i<n; i ++){
    if(vect.at(i-1) < vect.at(i)){
      a ++;
    }
  }
  cout<< a << endl;

}


Measured memory_bytes: 3648
def solve(s, w):
    if w >= s:
        return "unsafe"
    else:
        return "safe"


def main():
    s, w = map(int, input().split())
    res = solve(s, w)
    print(res)


def test():
    assert solve(4, 5) == "unsafe"
    assert solve(100, 2) == "safe"
    assert solve(10, 10) == "unsafe"


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int count=0;
  int a; cin>>a;
  vector <int> x(a);
  for(int i=0;i<a;i++) cin>>x.at(i);
  sort(x.begin(),x.end());
  cout<<x.at(a-1)-x.at(0)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll>   vl;
#define f(i,n)  for(i=0;i<n;i++)
#define f1(i,n)  for(i=1;i<n;i++)
#define fr(i,n) for(i=n-1;i>=0;i--)
#define em emplace_back
#define mp make_pair
#define in insert
#define fi first
#define sc second
#define b begin
#define e end
#define er erase
#define l length
#define c clear
#define si size
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
const double pi=3.141592653;
const ll infi=1000000001;
const ll MOD=1000000007;
const ll mod=998244353;
const string no="NO\n",yes="YES\n";

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

// void dfs(vl v[],ll node,ll hai[]){
//     hai[node]=1;
//     for(auto i:v[node]){
//         if(hai[i]==0){
//             dfs(v,i,hai);
//         }
//     }
// }

// ll con(vl v[],ll hai[],ll sz){
//     ll count=0;
//     for(int i=1;i<sz;i++){
//         if(hai[i]==0){
//             count++;
//             dfs(v,i,hai);
//         }
//     }
    // return count;
// }

// void gcde(int a,int b,int *x,int *y){
//     if(a==0){
//         *x=0;
//         *y=1;
//         return;
//     }    
//     int x1,y1;
//     gcde(b%a,a,&x1,&y1);
    
//     *x=y1-(b/a)*x1;
//     *y=x1;
// }


// ll recur(vl v,ll in,ll m,ll n){
//     if(in==-1)  return 1000000000001;
//     ll d,e,c;
//     d=max(m/v[in],n*v[in]);
//     c=recur(v,in-1,m/v[in],n*v[in]);
//     e=recur(v,in-1,m,n);
//     return min(c,min(e,d));
// }

// ll bexpo(ll a,ll p){
//     ll x=1;
//     while(p){
//     if(p&1){
//         x=(x*a)%mod;
//     }
//     a=(a*a)%mod;
//     p>>=1;
//     }
//     return x;
// }
// ll fact[500001],invf[500001];
// int dx[8]{-1,0,0,1,-1,-1,1,1};
// int dy[8]{0,-1,1,0,-1,1,-1,1};
// ll dp[200001];


int main() {
    fastio
    int n;
    cin>>n;
    ll a[n],s=0,i,j;
    f(i,n){
        cin>>a[i];
        s+=a[i];
    }
    ll ans=0;
    f(i,n-1){
        s-=a[i];
        ans=(ans+(a[i]*(s%MOD))%MOD)%MOD;
    }
    cout<<ans;

	return 0;
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e3+5;
pair<int,int>a[N];
int dp[N][N];
int n;
int go(int pos,int t)
{
    if(t<=0)
        return 0;
    if(pos==n+1)
        return 0;
    int &ans=dp[pos][t];
    if(ans!=-1)
        return ans;
    ans=0;
    ans=max(ans,go(pos+1,t));
    if(t>0)
    {
        ans=max(ans,a[pos].ss+go(pos+1,t-a[pos].ff));
    }
    return ans;
}
int32_t main()
{
        IOS;
        int t;
        cin>>n>>t;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i].ff>>a[i].ss;
        }
        sort(a+1,a+n+1);
        memset(dp,-1,sizeof(dp));
        cout<<go(1,t)<<endl;

 }

Measured memory_bytes: 71040
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <cstring>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define Cout(obj) cout << obj << endl
#define Size(obj) (int)(obj).size()
#define fcout cout << fixed << setprecision(10)
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cap, rev;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const int MaxV = 10000;

vector<edge> graph[MaxV];
bool used[MaxV];

void addEdge(int from, int to, int cap)
{
    graph[from].push_back({to, cap, Size(graph[to])});
    graph[to].push_back({from, 0, Size(graph[from]) - 1});
}

int dfs(int v, int t, int f)
{
    if(v == t) return f;
    used[v] = true;

    for(auto &e : graph[v])
    {
        if(!used[e.to] && e.cap > 0)
        {
            int d = dfs(e.to, t, min(f, e.cap));

            if(d > 0)
            {
                e.cap -= d;
                graph[e.to][e.rev].cap += d;
                return d;
            }
        }
    }

    return 0;
}

int maxFlow(int s, int t)
{
    int flow = 0;
    for(;;)
    {
        memset(used, false, sizeof(used));

        int f = dfs(s, t, iINF);

        if(f == 0) return flow;

        flow += f;
    }
}

int X, Y, E;

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

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

    int S = X + Y, T = S + 1;

    REP(i, X)
    {
        addEdge(S, i, 1);
    }    

    REP(i, Y)
    {
        addEdge(X + i, T, 1);
    }

    REP(i, E)
    {
        int x, y;
        cin >> x >> y;
        addEdge(x, y + X, 1);
    }

    Cout(maxFlow(S, T));

    return 0;
}


Measured memory_bytes: 3588
package main 
import (
    "bufio"
    "fmt"
    "os"
    )

var r = bufio.NewReader(os.Stdin)

func main() {
    var x,y int 
    fmt.Fscan(r, &x)
    fmt.Fscan(r, &y)
    s:=x*y
    z:=2*x+2*y
    fmt.Println(s, z)
}



Measured memory_bytes: 1140
#include <iostream>
#include <algorithm>
#include <map>
#include <stack>
using namespace std;
int main(){
	int n,x,y;
	cin>>n;
	for(int i=0;i<n;++i){
		string blocks[8];
		stack <pair<int,int> > st;
		for(int j=0;j<8;++j) cin>>blocks[j];
		cin>>x>>y;
		st.push(make_pair(x-1,y-1));
		cout<<"Data "<<(i+1)<<":\n";
		for(;!st.empty();){
			int x=(st.top()).first,y=(st.top()).second;
			st.pop();
			for(int j=x-3;j<x+4&&j<8;++j){
				if(j<0)continue;
				if(blocks[y][j]=='1'){
					blocks[y][j]='0';
					st.push(make_pair(j,y));
				}
			}
			for(int j=y-3;j<y+4&&j<8;++j){
				if(j<0)continue;
				if(blocks[j][x]=='1'){
					blocks[j][x]='0';
					st.push(make_pair(x,j));
				}
			}
		}
		for(int j=0;j<8;++j)cout<<blocks[j]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

vector<int> a;

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < 3 * n; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.begin(), a.end(),greater<int>());
    long long ans = 0;

    int big_ind = 0;
    while(big_ind < 2*n){
        ans += a[big_ind + 1];
        big_ind += 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<set>
#include <cstdio>
#include<vector>
#include<algorithm>

#define ll long long
using namespace std;
	long long n ;
int main(){
    cin>>n;
    vector<int> a(3*n);
    for(int i=0; i<3*n; i++) scanf("%d", &a[i]);
    ll res = 0;
    sort(a.rbegin(), a.rend());
    for(int i=1; i<2*n; i+=2 ){
	res+=a[i];
    }
    cout<<res<<"\n";
}

Measured memory_bytes: 1408
import numpy as np

N = int(input())
X = str(input())
num_one = X.count("1")

dp = [-1] * N
dp[0] = 0
def dfs(n):
    if dp[n] == -1:
        dp[n] = 1 + dfs(n % bin(n).count('1'))
    return dp[n]

num_one = X.count("1")
bool_arr = np.array([True if X[N-i-1] == "1" else False for i in range(N)])
zero_ver = np.array([pow(2,  i, num_one + 1) for i in range(N)])
zero_ver_sum = sum(zero_ver[bool_arr])

one_ver = -1
one_ver_sum = 0
flag = False
if num_one != 1:
    one_ver = np.array([pow(2,  i, num_one - 1) for i in range(N)])
    one_ver_sum = sum(one_ver[bool_arr])
else:
    flag = True
for i in range(1,N+1):
    start = 0
    if bool_arr[N-i] == False:
        start = (zero_ver_sum + pow(2, N - i, num_one + 1)) % (num_one + 1)
        print(dfs(start)+1)
    else:
        if flag:
            print(0)
        else:
            start = (one_ver_sum - pow(2, N - i, num_one - 1))  %  (num_one - 1)
            print(dfs(start)+1)


Measured memory_bytes: 40044
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;

int main(){
	cin>>m>>n;
	int N=m+10006;
	vi dp(N,inf);
	dp[0]=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		for(int j=0;j<N-x;j++) dp[j+x]=min(dp[j+x],dp[j]+y);
	}
	int res=inf;
	for(int i=m;i<N;i++) res=min(res,dp[i]);
	cout<<res<<endl;
}

Measured memory_bytes: 384
using System;
using System.IO;
using System.Linq;

namespace MinPro2019D
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var L = ss.Next(int.Parse);
            var dp = new long[5];

            for (var i = 0; i < L; i++)
            {
                var A = ss.Next(long.Parse);

                for (var t = 1; t < 5; t++)
                {
                    dp[t] = Math.Min(dp[t - 1], dp[t]);
                }

                for (var t = 0; t < 5; t++)
                {
                    if (Math.Abs(t - 2) == 0) dp[t] += (A % 2) ^ 1;
                    if (Math.Abs(t - 2) == 1) dp[t] += (A % 2) + (A == 0 ? 2 : 0);
                    if (Math.Abs(t - 2) == 2) dp[t] += A;
                }
            }

            sw.WriteLine(dp.Min());
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }

    public class StreamScanner
    {
        static readonly char[] Separator = {' '};
        readonly TextReader textReader;

        string[] line = new string[0];
        int index = 0;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (index < line.Length) return parser(line[index++]);
            index = 0;
            line = textReader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 17472
#include<bits/stdc++.h>
#include<iomanip>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define KETA 40

using namespace std;

typedef long long  ll;
typedef pair<ll,ll> P1;
typedef pair<string,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<Pi,int> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n,a,b;
	cin>>n>>a>>b;
	if(a*n<=b)cout<<a*n<<endl;
	else cout<<b<<endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

ll modPow(ll x, ll n) {
    ll ret = 1;
    while(n) {
        if(n&1LL) (ret *= x) %= MOD;
        n >>= 1;
        (x *= x) %= MOD;
    }
    return ret;
}

ll dp[41][(1<<17)+10];

int main(){
    int n;
    vi v(3);
    cin >> n;
    rep(i, 3) cin >> v[i];
    int sum_v = v[0] + v[1] + v[2];
    dp[0][0] = 1;
    auto check = [&](int mask) {
        bool f = true;
        f &= (mask >>=(v[2]-1)) & 1;
        f &= (mask >>=v[1]) & 1;
        f &= (mask >>=v[0]) & 1;
        return f;
    };
    auto pop_mask = [&](int mask) {
        if(mask == 0) return 0;
        bool f = true;
        repr(i, sum_v) {
            if(mask & (1<<i)) {
                if(f) {
                    mask -= (1<<i);
                    f = false;
                    break;
                }
            }
        }
        return mask;
    };
    auto getSize = [&](int mask) {
        if(mask == 0) return 0;
        repr(i, sum_v) {
            if(mask&(1<<i)) {
                return i+1;
            }
        }
        return 0;
    };
    auto push_mask = [&](int mask, int add) {
        if(add > sum_v) return 0;
        while(getSize(mask)+add > sum_v) {
            mask = pop_mask(mask);
        }
        mask <<= add;
        mask |= 1<<(add-1);
        return mask;
    };
    rep(i, n) rep(mask, 1<<sum_v) {
        REP(k, 1, 11) {
            int nxt = push_mask(mask, k);
            if(check(mask) || check(nxt)) continue;
            (dp[i+1][nxt] += dp[i][mask]) %= MOD;
        }
    }
    ll sum = 0LL;
    rep(mask, 1<<sum_v) (sum += dp[n][mask]) %= MOD;
    ll ans = modPow(10, n);
    (ans += MOD - sum) %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 41216
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
# import math
mod = 10**9 + 7

# n = int(input())
# a = list(map(int, input().split()))
s = input()
l = ['SUN','MON','TUE','WED','THU','FRI','SAT']
if s == l[0]: print(7)
elif s == l[1]: print(6)
elif s == l[2]: print(5)
elif s == l[3]: print(4)
elif s == l[4]: print(3)
elif s ==l[5]: print(2)
elif s == l[6]: print(1)


Measured memory_bytes: 3060