akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
#include <complex>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(a) (a).begin(),(a).end()

int N;

typedef complex<double> P;

P in[102];

vector<P> getCross(int i, int j) {
  double dist = abs(in[i] - in[j]);
  if (dist > 2.0) {
    return vector<P>();
  }
  if ((dist - 2.0) < 1e-10) {
    P center = in[i] + in[j];
    return vector<P>(1, P(center.real()/2, center.imag()/2));
  }
  // 円i, jの中心点を結ぶベクトル
  P ij = in[j] - in[i];
  // ベクトルの大きさ
  double ijAbs = abs(ij);
  // ij の単位法線ベクトル
  P ijN0 = (ij * P(0, 1)) / ijAbs;
  P ijN1 = (ij * P(0,-1)) / ijAbs;
  // ij の中点までのベクトル
  P ijHalf = in[i] + P(ij.real()/2, ij.imag());
  // 三角形の高さ
  double height = 1 - pow(ijAbs / 2, 2);
  // 交点までのベクトル
  P p0 = ijHalf + ijN0 * height;
  P p1 = ijHalf + ijN1 * height;
  vector<P> ret;
  ret.push_back(p0);
  ret.push_back(p1);
  return ret;
}

int main() {

  while (cin >> N, N) {
    rep(i,N) {
      double x, y;
      char camma;
      cin >> x >> camma >> y;
      in[i] = P(x, y);
      // cin >> in[i].real() >> in[i].imag();
    }
    int ans = 1;
    for (int i = 0; i < N; i++) {
      for(int j = i+1; j < N; j++) {
        vector<P> cross = getCross(i, j);
        if (cross.size() == 0)
          continue;
        for (int k = 0; k < cross.size(); k++) {
          P cur = cross[k];
          int cnt = 2;
          for (int l = 0; l < N; l++) {
            if (l == i || l == j) continue;
            double dist = abs(cur - in[l]);
            if ((dist - 1.0) < 1e-10) {
              ++cnt;
            }
          }
          // ans = max(ans, cnt);
          if (ans < cnt) {
            ans = cnt;
            // printf("%d, %d : value %d\n", i+1, j+1, ans);
          }
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

const double EPS = 1e-12;

int main(){
	double water[86401];
	int N;
	double L;
	while(cin >> N >> L, N){
		for(int i=0;i<86400;i++) water[i] = 0;
		for(int i=0;i<N;i++){
			int s, t; double d; cin >> s >> t >> d;
			for(int j=s;j<t;j++) water[j] = d;
		}
		double left = 0.0, right = 1000000;
		while(right-left>1e-8){
			double mid = (left+right)/2.0;
			double tank = L;
			bool flag = true, flagB = false;
			for(int i=0;i<86400&&flag;i++){
				tank = min(L, tank+mid-water[i]);
				if(tank < 0) flag = false;
			}
			for(int i=0;i<86400&&flag;i++){
				tank = min(L, tank+mid-water[i]);
				if(tank < 0) flag = false;
				if(abs(L-tank)<EPS){
					flagB = true;
				}
			}
			if(flag&&flagB) right = mid;
			else     left = mid;
		}
		printf("%.7lf\n", (right+left)/2.0);
	}
}

Measured memory_bytes: 1656
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w, 0));
    vector<vector<bool>> tb(h, vector<bool>(w, true));
    repi(i, h, 0)
    {
        repi(j, w, 0)
        {
            cin >> a[i][j];
        }
    }
    bool ok = true;
    while (ok)
    {
        ok = false;
        repi(i, h, 0)
        {
            int cnt = 0;
            int tbcnt = 0;
            repi(j, w, 0)
            {

                if (!tb[i][j])
                    tbcnt++;
                else if (a[i][j] == '.')
                    cnt++;
            }
            if (cnt + tbcnt == w && tbcnt < w)
            {
                ok = true;
                repi(j, w, 0)
                {
                    tb[i][j] = false;
                }
            }
        }

        repi(i, w, 0)
        {
            int cnt = 0;
            int tbcnt = 0;
            repi(j, h, 0)
            {
                if (!tb[j][i])
                    tbcnt++;
                else if (a[j][i] == '.')
                    cnt++;
            }
            if (cnt + tbcnt == h && tbcnt < h)
            {
                ok = true;
                repi(j, h, 0)
                {
                    tb[j][i] = false;
                }
            }
        }
    }
    repi(i, h, 0)
    {
        int cnt = 0;
        repi(j, w, 0)
        {
            if (tb[i][j])
            {
                cout << a[i][j];
                cnt++;
            }
        }
        if (cnt)
        {
            cout << "\n";
        }
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, m, s, t;
vector<int> v[101010];
int dp[101010][3];

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a,b;
		cin >> a >> b;
		v[a].push_back(b);
	}
	cin >> s >> t;
	
	for(int i = 0; i < 101010; i++) for(int j = 0; j < 3; j++){
		dp[i][j] = INF;
	}
	int ans = INF;
	queue<pair<int,int>> q;
	q.push(make_pair(s, 0));
	dp[s][0] = 0;
	while(!q.empty()){
		pair<int,int> p = q.front();
		q.pop();
		int pos = p.first, cnt = p.second;
		for(int i = 0; i < v[pos].size(); i++){
			if(dp[v[pos][i]][(cnt+1)%3] <= cnt+1) continue;
			dp[v[pos][i]][(cnt+1) % 3] = cnt+1;
			q.push(make_pair(v[pos][i], cnt+1));
		}
	}
	
	if(dp[t][0] == INF){
		cout << -1 << endl;
	}
	else{
		cout << dp[t][0]/3 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 6912
#!/usr/bin/perl
my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @b = map { $_ - 0 } split(/\s+/,<STDIN>);

my %cnt = ();
foreach my $b (@b){
  $cnt{$b} ++;
}

foreach my $c (keys %cnt){
  if( $cnt{$c} > $n + 1 - ( $c - 0 ) ){
    print "-1\n"; exit(0);
  }
}

my @bb = @b;
my @op = ();
my $cl = $n;
for(my $i=0;$i<$n;$i++){
  my $j;
  for($j=$cl;$j>0;$j--){
    last if $bb[$j - 1] == $j;
  }
  if( $j<=0 ){
    print "-1\n"; exit(0);
  }
  unshift(@op,$j);
  my @newbb = ();
  push(@newbb,@bb[0..($j-2)]) if $j>1;
  push(@newbb,@bb[$j..($cl-1)]) if $j<$cl;
  @bb = (@newbb);
  $cl--;
}
for(my $i=0;$i<$n;$i++){
  print "$op[$i]\n";
}

exit(0);



Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int c = S.length() - 2;
        int ans = Math.abs(753 - Integer.parseInt(S.substring(0, 3)));

        for (int i = 1; i < c; i++) {
            int n = Integer.parseInt(S.substring(i, i + 3));
            int abs = Math.abs(753 - n);
            if (abs < ans) {
                ans = abs;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include <iostream>

using namespace std;

int H, W;

void solve() {
    if(H == 0 && W == 0) return;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(i%2 == 0) {
                if(j%2 == 0) cout << "#";
                else cout << ".";
            }else {
                if(j%2 == 0) cout << ".";
                else cout << "#";
            }
        }
        cout << endl;
    }
    cout << endl;
}

int main() {
    do {
        cin >> H >> W;
        solve();
    }while(H != 0 || W != 0);
}


Measured memory_bytes: 3076
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

using llong = long long;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) { a += b, a &= MOD; }

int main() {
  // Input
  llong N;
  std::cin >> N;
  assert(1 <= N and N <= 1.0e+15);
  int numInterCity = 5;
  std::vector<llong> cap(1 + numInterCity);
  for (int i = 1; i <= numInterCity; ++i) {
    std::cin >> cap[i];
    assert(1 <= cap[i] and cap[i] <= 1.0e+15);
  }

  // Main
  int neckIndex = 0;
  llong neckCap = LINF;
  for (int i = 1; i <= numInterCity; ++i) {
    if (cap[i] < neckCap) {
      neckCap = cap[i];
      neckIndex = i;
    }
  }

  llong neckTime = (N + cap[neckIndex] - 1) / cap[neckIndex];

  // Output
  std::cout << neckTime + 4 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
const int maxn = 1e5 + 10;
int a[maxn],b[maxn];
int32_t main(){
    int n;
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> a[i + 1];
    }
    for (int i = 1;i <= n;i++){
        cin >> b[i];
    }
    int sum =0;
    vector<int> v;
    int cnt = 0;
    for (int i = 1;i <= n;i++){
        if (b[i] > a[i]) sum += b[i] - a[i],cnt++;
        else if (a[i] > b[i]) v.pb(a[i] - b[i]);
    }
    sort(v.rbegin(),v.rend());
    for (int i = 0;i < v.size();i++){
        if (sum <= 0 ) break;
        sum -= v[i];
        cnt++;
    }
    if (sum > 0) cout << -1 << endl;
    else cout << cnt;

}


Measured memory_bytes: 2428
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <limits>

int64_t mat[][6] = {
    {1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1},
};

int64_t tmp[6][6] = {};

int64_t count() {
    int64_t out = 0;
    for (int64_t h = 0; h < 6; ++h) {
        for (int64_t w = 0; w < 6; ++w) {
            if (tmp[h][w] == 0) out++;
        }
    }
    return out;
}

void paint(int64_t h, int64_t w) {
    for (int64_t i = 0; i < 6; ++i) {
        if (((h >> i) & 0x1) == 0) continue;
        for (int64_t j = 0; j < 6; ++j) {
            tmp[i][j] = 1;
        }
    }
    for (int64_t i = 0; i < 6; ++i) {
        if (((w >> i) & 0x1) == 0) continue;
        for (int64_t j = 0; j < 6; ++j) {
            tmp[j][i] = 1;
        }
    }
}

int main() 
{
    int64_t H, W, K;
    std::cin >> H >> W >> K;

    for (int64_t h = 0; h < H; ++h) {
        for (int64_t w = 0; w < W; ++w) {
            char c;
            std::cin >> c;
            if (c == '.') continue;
            mat[h][w] = 0;
        }
    }

    int64_t bit_h = 0x1;
    for (int64_t i = 1; i < H; ++i) {
        bit_h <<= 1;
        bit_h |= 1;
    }
    int64_t bit_w = 0x1;
    for (int64_t i = 1; i < W; ++i) {
        bit_w <<= 1;
        bit_w |= 1;
    }

    int64_t ans = 0;
    for (int64_t h = 0; h <= bit_h; ++h) {
        for (int64_t w = 0; w <= bit_w; ++w) {
            std::memcpy(tmp, mat, sizeof(tmp));
            paint(h, w);
            if (count() == K) ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(), s.end()
#define rAll(s) s.rbegin(), s.rend()
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int main(){
    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(),d.end());
    cout << d[n / 2] - d[n / 2 - 1] << endl;
}

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

#define endl             '\n' 
#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define EPS              1E-5
#define ff               first
#define ss               second
#define sqr(x)           (x)*(x)
#define D(x)             cout<<#x " = "<<(x)<<endl
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define SZ(a)            (int)a.size()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
#define all(a)           a.begin(),a.end()
#define intlim           2147483648
#define infinity         (1<<28)
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
 
using namespace std;
 
 
const int fx[]= {+1,-1,+0,+0};
const int fy[]= {+0,+0,+1,-1};
// const int N = 1e5 + 5;
#define piii pair<int, pair<int,int> >

const int N = 2e5 + 5;
ll arr[N],frec[N],vis[N];
int main(){
  CIN;
  int n,m;
  while(cin >> n >> m)
  {
    int i=0;
    ll ans=0;
    loop(i,n) cin >> arr[i];
    sort(arr,arr + n);
    loop(i,n-m)ans += arr[i];
    cout << ans << endl;
  }
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

class UF {
public:

    int n, par[55];

    void init(int pn) {
        n = pn;
        for (int i = 0; i < n; ++i) {
            par[i] = i;
        }
    }

    int find(int x) {
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        par[x] = y;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int N,M;

vector<P1> Edge;
int ans;

signed main(){
    cin>>N>>M;
    for(int i=0;i<M;++i){
        int a,b;
        cin>>a>>b;
        Edge.push_back(P1(a,b));
    }
    for(int i=0;i<Edge.size();++i){
        UF uf;
        uf.init(N+5);
        for(int j=0;j<Edge.size();++j){
            if(j==i)continue;
            uf.unite(Edge[j].first,Edge[j].second);
        }
        if(!uf.same(Edge[i].first,Edge[i].second))ans++;
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;
typedef vector<ll> Vl;

const ll MAX_A = 1e6;
Vl F, A;
ll K;
const int MAX_N = 2e5;
int N;

void init()
{
	cin >> N >> K;
	A.resize(N);
	F.resize(N);

	REP(i, N) cin >> A[i];
	REP(i, N) cin >> F[i];

	sort(ALL(A), greater<>());
	sort(ALL(F));
}

bool check(ll t)
{
	ll x = 0;
	REP(i, N)
	{
		ll a = A[i] - t / F[i];
		x += max((ll)0, a);
	}

	return x <= K;
}

int main()
{
	init();
	ll ng = -1, ok = MAX_A * MAX_A * 2+ 1;
	while (ok - ng > 1)
	{
		auto mid = (ng + ok) / 2;

		if (check(mid))
			ok = mid;
		else
			ng = mid;
	}

	cout << ok << endl;
}


Measured memory_bytes: 3328
def main():
	N = int(input())
	S = input()
	x = 0
	max_x = 0
	for c in S:
		if c == "I":
			x += 1
		if c == "D":
			x -= 1
		max_x = max(max_x, x)
	print(max_x)


if __name__ == '__main__':
	main()

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

using namespace std;

#define ll long long
int main()
{
    ll int n,w;
    cin>>n>>w;
    vector<pair<ll int,ll int>> v;
    for(int i=0;i<n;i++)
    {
        ll int x,y;
        cin>>x>>y;
        v.push_back({x,y});
    }
    ll int dp[w+2];
    memset(dp,0,sizeof(dp));
    for(ll int i=0;i<n;i++)
    {
        for(int j=w;j>=v[i].first;j--)
        {
            dp[j]=max(dp[j],dp[j-v[i].first]+v[i].second);
        }
    }
    cout<<dp[w]<<endl;
}


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

int main(){
  char a;
  cin >> a;
  if(isupper(a)) cout << "A" << endl;
  else cout << "a" << endl;
}


Measured memory_bytes: 3572
n, m , x, y = map(int, input().split())
X = [int(_)  for _ in input().split()]
Y = [int(_)  for _ in input().split()]
maxX = max(X)
maxX = max(maxX, x)
minY = min(Y)
minY = min(minY, y)
if minY - maxX >= 1:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include<cstdio>
int main()
{
	int a[100000+10],t,w,ans=0;
	scanf("%d",&t);
	for(int i=1;i<=t;i++)
	{
		scanf("%d%d",&a[i],&a[i+1]);
		w = a[i+1]-a[i]+1;
		ans=ans+w;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int n,a[111111],b[111111],k,x,cnt;
signed main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
		k+=a[i];
	}
	if(k%((n+1)*n/2)){
		puts("NO");
		return 0;
	}
	k/=((n+1)*n/2);
	rep(i,n){
		if(i)b[i]=a[i]-a[i-1];
		else b[i]=a[0]-a[n-1];
		b[i]-=k;
		if(b[i]>0){
			puts("NO");
			return 0;
		}
	}
	rep(i,n){
		if(b[i]<0){
			if(-(b[i])%n==0)cnt+=-(b[i])/n;
		}
	}
	if(cnt==k)puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;
int main()
{
  int k; cin>>k; int ld=k%10; 
  if(k==1){ cout<<1<<"\n"; return 0; }
  if(ld%2==0){ cout<<-1<<"\n"; return 0; }
  int res=7;  if(res%k==0){ cout<<1<<"\n"; return 0;}
  for(int i=2;i<=200000000;i++)
  { 
   res=(10*res+7)%k; if(res==0){ cout<<i<<"\n"; return 0; }  
  }
  cout<<-1<<"\n"; return 0; 
}

Measured memory_bytes: 3572
# define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12
template<class T> void debug(T a) { for (auto iiiiiiiiii : a)cout << iiiiiiiiii << endl; }
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };

signed main()
{
	INT(n);
	FOR(day, n)
	{
		int x, y, b, p;
		cin >> x >> y >> b >> p;
		int ans1 = x*b + y*p;
		int ans2 = (max(b, 5)*x + max(p, 2)*y) / 10 *8;
		cout << min(ans1, ans2) << endl;
	}
}

Measured memory_bytes: 3108
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class BRuinedSquare {
public:
	void solve(istream& in, ostream& out) {
        int x1,x2,y1,y2; in >> x1 >> y1 >> x2 >> y2;
        int x = x2-x1,y = y1 - y2;
        out << x2 + y << " " << y2 + x << " " << x1 + y << " " << y1 + x  << endl;
	}
};

int main() {
	BRuinedSquare solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=2e9;

int clr[10];

int main(){
    int n; cin>>n;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        if(a>=3200){
            clr[8]++;
            continue;
        }
        for(int j=1;j<=8;j++){
            if(a<j*400){
                clr[j-1]++;
                break;
            }
        }
    }
    int cnt=0;
    for(int i=0;i<=7;i++){
        if(clr[i])cnt++;
    }
    cout<<max(1,cnt)<<" ";
    cout<<cnt+clr[8]<<endl;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    LL n,m,x;
    cin>>n>>m>>x;
    vector<LL>v(n,0),s(n,0);
    LL a[n][m];
    for(LL i=0; i<n; i++)
    {
        cin>>v[i];
        for(LL j=0; j<m; j++)
        {
            cin>>a[i][j];
        }
    }

    LL ans=INF;

    LL f=0;

    for(LL i=0; i<(1<<n); i++)
    {
        LL b[m]= {0};
         LL st=0;
        for(LL j=0; j<n; j++)
        {
            if(i&(1<<j))
            {
                for(LL k=0; k<m; k++)
                {
                    b[k]+=a[j][k];
                }
                st+=v[j];
            }
        }
        LL f=0;
        for(LL j=0;j<m;j++)
        {
          if(x>b[j])f=1;
        }
        if(f==0)
        {
            ans=min(ans,st);
        }

    }
    if(ans==INF)ans=-1;
    cout<<ans;




}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] list = new int[n];
        
        for (int i = 0; i < n; i++) {
            list[i]= sc.nextInt();
        }
        int c = 0;
        for (int i = 1; i < n-1; i++) {
            if( (list[i] > list[i-1] && list[i] < list[i+1]) ||
                    (list[i] < list[i-1] && list[i] > list[i+1]) ) {
                c++;
            }
        }
        

        System.out.println(c);   
        }
}


Measured memory_bytes: 23764
import java.util.Scanner;
public class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long A=sc.nextLong();
		long B=sc.nextLong();
		long N=sc.nextLong();
		if(B-1>N) {
			System.out.println((A*N)/B);
		}else {
		System.out.println((A*(B-1))/B);
		}

		}
}

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

int main(){
    ll n;
    cin >> n;
    ll x=0,y=0;
    map<ll,ll> mp;
    rep(i,n){
        ll a;
        cin >> a;
        mp[a]++;
        if(mp[a]==2){
            if(y<a){
                if(x<a){
                    y=x;
                    x=a;
                }
                else y=a;
            }
        }
        if(mp[a]==4){
            if(y<a){
                if(x<a){
                    y=x;
                    x=a;
                }
                else y=a;
            }
        }
    }
    cout << x*y << endl;
    return 0;
}

Measured memory_bytes: 6528
a,b,c = list(map(int, input().split(" ")))
k = int(input())

for i in range(k):
    if b<=a:
        b = b*2
    else:
        if c<=b:
            c = c*2
    if a<b and b<c:
        print("Yes")
        break
else:
    print("No")

#red a
#green b
#blue c
#a < b < c


Measured memory_bytes: 9108
#include <iostream>

int main(){
    using namespace std;
    int a[3];
    cin >> a[0] >> a[1] >> a[2] ;
    while((a[0]!=-1)||(a[1]!=-1)||(a[2]!=-1)){
        if( (a[0]==-1) || (a[1]==-1) ){cout << "F" << endl;}
        else if(a[0]+a[1]>=80){cout << "A" << endl;}
        else if(a[0]+a[1]>=65){cout << "B" << endl;}
        else if( (a[0]+a[1]>=50) || (a[0]+a[1]>=30)&&(a[2]>=50) ){cout << "C" << endl;}
        else if(a[0]+a[1]>=30){cout << "D" << endl;}
        else{cout << "F" << endl;}
        cin >> a[0] >> a[1] >> a[2] ;
    }
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define INF 100000000
typedef pair<int,int> P;
int w,h;
int used[110][110][6];
int ban[110][110];
int dfs(int x,int y,int index);
int dx1[]={-1, 0, 1, 0,-1,-1};
int dx2[]={ 0, 1, 1, 1, 0,-1};
int dy[] ={-1,-1, 0, 1, 1, 0};
 
int main(){
  cin >> w >> h;
  memset(ban,0,sizeof(ban));
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin >> ban[i][j];
    }
  }
  memset(used,0,sizeof(used));
  int cou=0;
  queue<P> que;
  que.push(P(0,0));
  while(!que.empty()){
    P p = que.front(); que.pop();
    int nowx = p.first; int nowy = p.second;
    for(int i=0;i<6;i++){
      int nx=nowx,ny=nowy;
      if(nowy % 2 == 0) nx += dx1[i];
      else nx += dx2[i];
      ny += dy[i];
      if(nx >= 0 && nx <= w+1 && ny >= 0 && ny <= h+1){
	if(ban[ny][nx] == 1 /*&& used[ny][nx][i] == 0*/){
	  // used[ny][nx][i] = 1;
	  cou++;
	  //ban[ny][nx]=-1;
	}
	else if(ban[ny][nx] == 0 /*&& used[ny][nx][i] == 0*/){
	  //used[ny][nx][i] = 1;
	  que.push(P(nx,ny));
	  ban[ny][nx]=-1;
	}
      }
    }
  }
  cout << cou << endl;
}

Measured memory_bytes: 1552
S = input()

alf = set([chr(i) for i in range(ord('a'), ord('z')+1)])

if S == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
elif len(S) < 26:
    not_used_alf = list(alf - set(S))
    ans = S + min(not_used_alf)
    print(ans)
else:
    tmp = S[-1]
    for i in reversed(range(26)):
        if S[i] >= tmp:
            tmp = S[i]
            continue
        else:
            break
    tmp = set(S[i+1:])
    for x in [chr(i) for i in range(ord('a'), ord('z')+1)]:
        if x in tmp and x > S[i]:
            ans = S[:i] + x
            break
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
  int i,j,k;
  int ymd[100][3], n, y3=590, date;

  scanf("%d", &n);
  for(i=0; i<n; i++) {
    for(j=0; j<3; j++) {
      scanf("%d", &ymd[i][j]);
    }
  }

  for(i=0;i<n;i++) {
    date = 0;
    date += ((ymd[i][0]-1)/3)*y3;
    switch(ymd[i][0]%3){
    case 2:
      date += 195;
      for(j=0;j<ymd[i][1]-1;j++) {
	j%2 ? (date += 19):(date += 20);
      }
      date += ymd[i][2];
      break;
      
    case 1:
      for(j=0;j<ymd[i][1]-1;j++) {
	j%2 ? (date += 19):(date += 20);
      }
      date += ymd[i][2];
      break;
      
    case 0:
      date += 390;
      for(j=0;j<ymd[i][1]-1;j++) {
	date += 20;
      }
      date += ymd[i][2];
      break;
    }
    printf("%d\n", 196471 - date);
  }

  for(i=0;i<10000000;i++) {
    for(j=0;j<10000000;j++) k++;
}

  return 0;
}
      

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N,A,B,C,D;
	cin >> N;
	A = N / 1000;
	B = (N-1000*A) / 100;
	C = (N - 1000 * A - 100 * B) / 10;
	D = N % 10;
	if (A==B&&B==C) {
		cout << "Yes" << endl;
	}
	else if (D == B && B == C) {
		cout << "Yes" << endl;
	}
	else if (A == B && B == C&&C==D) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MOD=1000003;
const int MAXQ=100000;
int pw(int x,int n) { int ret=1; while(true) { if(n&1) ret=(ll)ret*x%MOD; if((n>>=1)==0) return ret; x=(ll)x*x%MOD; } }

int nq;
int qx[MAXQ],qd[MAXQ],qn[MAXQ],qans[MAXQ];

int inv[MOD];
int fac[MOD];
int ifac[MOD];


void solve() {
	inv[1]=1; FORE(i,2,MOD-1) inv[i]=(ll)(MOD-MOD/i)*inv[MOD%i]%MOD;
	fac[0]=1; FORE(i,1,MOD-1) fac[i]=(ll)fac[i-1]*i%MOD;
	ifac[0]=1; FORE(i,1,MOD-1) ifac[i]=(ll)ifac[i-1]*inv[i]%MOD;

	REP(i,nq) {
		int x=qx[i],d=qd[i],n=qn[i];
		if(d==0) { qans[i]=pw(x,n); continue; }
		int a=(ll)inv[d]*x%MOD;
		int b=a+n-1;
		if(b>=MOD) { qans[i]=0; continue; }
		if(a==0) { qans[i]=0; continue; }
		//printf("a=%d b=%d\n",a,b);
		qans[i]=(ll)fac[b]*ifac[a-1]%MOD*pw(d,b-a+1)%MOD;
	}

}

void run() {
	scanf("%d",&nq);
	REP(i,nq) scanf("%d%d%d",&qx[i],&qd[i],&qn[i]);
	solve();
	REP(i,nq) printf("%d\n",qans[i]);
}

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


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

int main(void){
	
	char s[4];
  	int i;
  
  	scanf("%s",s);
	
  	if(strlen(s) == 2){
    	printf("%s",s);
    }
  	else{
    	for(i=strlen(s)-1;i>=0;i--){
        	printf("%c",s[i]);
        }
    }

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

vector<PC> table;//??????????????????????????????
int n, co[3], num;
char c;

bool flag(PC a, PC b){
	if (a.first.first == b.first.first){
		return a.first.second < b.first.second;
	}
	return a.first.first > b.first.first;
}

int main(){
	while (cin >> n&&n){
		REP(i, n){
			cin >> c;
			co[0] = co[1] = 0;
			REP(i, n - 1){
				cin >> num;
				co[num]++;
			}
			table.push_back(PC(P(co[0], co[1]), c));
		}
		sort(ALL(table), flag);
		REP(i, n){
			cout<< table[i].second << endl;
		}
		table.clear();
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define bash push_back
#define alles(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
const int INF=1 << 30;
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vit;
typedef map<string,int> mstit;
typedef priority_queue<int> pqit;

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,k,a=1,hoge=0;
  cin >>n>>k;
  FOR(i,n){
    if(a*2>a+k) {
      for(int j = i;i<n;i++){
        a+=k;
      }
      break;
    }
    a*=2;
  }
  
  cout <<a fin;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	int N;
	cin >> N;
	vector<vector<pair<int, int>>> G(N);
	for (auto i = 0; i < N - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		G[a - 1].push_back(make_pair(b - 1, i));
		G[b - 1].push_back(make_pair(a - 1, i));
	}

	vector<int> result(N - 1);
	vector<bool> used(N);
	queue<pair<int, int>> q;
	q.push(make_pair(0, 0));
	auto maxC = 0;
	while (!q.empty())
	{
		auto p = q.front();
		q.pop();
		used[p.first] = true;

		auto c = 1;
		auto sumC = 0;
		if (p.second > 0)
		{
			sumC = 1;
		}
		for (auto e : G[p.first])
		{
			if (used[e.first])
			{
				continue;
			}

			if(p.second == c)
			{
				++c;
			}
			result[e.second] = c;
			q.push(make_pair(e.first, c));
			++c;
			++sumC;
		}
		maxC = max(maxC, sumC);
	}

	cout << maxC << endl;
	for (auto i = 0; i < N - 1; ++i)
	{
		cout << result[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main() {
    int N, X[100], sum=0, ave0, ave1, ans0=0, ans1=0;
    cin >> N;
    for (int i=0; i<N; i++) cin >> X[i], sum += X[i];

    ave0 = sum / N;
    ave1 = sum / N + 1;

    for (int i=0; i<N; i++) {
        ans0 += (X[i] - ave0) * (X[i] - ave0);
        ans1 += (X[i] - ave1) * (X[i] - ave1);
    }

    cout << min(ans0, ans1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define INF INT_MAX
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
	chutiyaap;
	ll a,b,c;cin>>a>>b>>c;
	cout<<min(a+b,min(2*b+a,min(2*a+b,min(c+b,a+c))));
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
using namespace std;
 
int main(){
    int N;
    string s;
    cin >> N;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < 1000; i++){
        int n = i;
        int idx = 0;
        int cnt = 0;
        while(idx < N){
            if(cnt == 0){
                if((int)(s[idx]-'0') == n/100){
                    cnt++;
                    n %= 100;
                }
            } else if(cnt == 1){
                if((int)(s[idx]-'0') == n/10){
                    cnt++;
                    n %= 10;
                }
            } else if(cnt == 2){
                if((int)(s[idx]-'0') == n){
                    ans++;
                    break;
                }
            }
            idx++;
        }
    }
    cout << ans << endl;
}


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

int main()
{
    int *a = new int[100010], n, max{};
    std::fill(a, a + 100010, 0);
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int tmp;
        scanf("%d", &tmp);
        a[tmp]++;
    }
    for (int i = 1; i < 100000; i++)
    {
        int tmp = a[i - 1] + a[i] + a[i + 1];
        if (tmp > max) max = tmp;
    }
    printf("%d\n", max);

    delete[] a;
    return 0;
}

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

constexpr int kInf = 1'000'000'000;

template <class T = int>
struct Dinic {
    struct Edge {
        int to, rev;
        T cap;
        Edge(int a, T b, int c) : to(a), cap(b), rev(c) {}
    };
    vector<vector<Edge>> g;
    vector<int> lev;
    int n;

    Dinic() = default;
    Dinic(int n) : n(n) {
        g.assign(n, vector<Edge>());
        lev.resize(n);
    }

    void AddEdge(int u, int v, T cap) {
        g[u].emplace_back(v, cap, g[v].size() - 0);
        g[v].emplace_back(u, 0, g[u].size() - 1);
    }

    bool Bfs(int s, int t) {
        fill(lev.begin(), lev.end(), -1);
        lev[s] = 0;
        queue<int> q;
        q.push(s);
        while (!q.empty()) {
            int x = q.front(); q.pop();
            for (Edge &e : g[x]) {
                if (lev[e.to] == -1 && e.cap > 0) {
                    lev[e.to] = lev[x] + 1;
                    q.push(e.to);
                }
            }
        }
        return lev[t] != -1;
    }

    T Dfs(int x, int t, T flow) {
        if (x == t) return flow;
        T res = 0;
        for (Edge &e : g[x]) {
            if (e.cap > 0 && lev[e.to] == lev[x] + 1) {
                T f = Dfs(e.to, t, min(e.cap, flow - res));
                res += f;
                e.cap -= f;
                g[e.to][e.rev].cap += f;
            }
        }
        if (!res) lev[x] = -1;
        return res;
    }

    T operator()(int s, int t) {
        T res = 0;
        for (; Bfs(s, t); res += Dfs(s, t, kInf));
        return res;
    }
};

int main() {
    int h, w; cin >> h >> w;
    vector<string> grid(h);
    for (int i = 0; i < h; ++i) cin >> grid[i];
    Dinic<int> flow(h + w + 2);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (grid[i][j] == 'o') {
                flow.AddEdge(i, j + h, 1);
                flow.AddEdge(j + h, i, 1);
            }
            if (grid[i][j] == 'S') {
                flow.AddEdge(h + w, i, kInf);
                flow.AddEdge(h + w, j + h, kInf);
            }
            if (grid[i][j] == 'T') {
                flow.AddEdge(i, h + w + 1, kInf);
                flow.AddEdge(j + h, h + w + 1, kInf);
            }
        }
    }
    int ans = flow(h + w, h + w + 1);
    if (ans >= kInf) ans = -1;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 896
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define pb push_back
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a;
	cin >> a;
	cout << a * (a * a + a + 1) << "\n";
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    int c = 1;
    while (c <= k) {
        if (c % 2 == 1) {
            if (a % 2 == 1) {
                a--;
            }
            b += a / 2;
            a = a / 2;

        } else {
            if (b % 2 == 1) {
                b--;
            }
            a += b / 2;
            b /= 2;
        }
        c++;
    }
    cout << a << " " << b;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>

#define MOD 1000000007
#define pi 3.14159265358979

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

	vector<int> p(n), c(n);

	for (int i = 0; i < n; i++) { cin >> p[i]; p[i]--; }
	for (int i = 0; i < n; i++) cin >> c[i];
	
	vector<bool> visited(n, false);

	ll ans = -1e18;

	for (int i = 0; i < n; i++)
	{
		if (!visited[i])
		{
			int index = i;
			ll loopSum = 0;
			ll loopLen = 0;
			vector<int> loop;

			while (!visited[index])
			{
				visited[index] = true;
				loopSum += c[index];
				loopLen++;
				loop.push_back(index);
				index = p[index];
			}

			ll cycles = k / loopLen;

			if (cycles == 0)
			{
				ll tAns = c[loop[0]];

				for (int start = 0; start < loopLen; start++)
				{
					ll tmp = 0;
					for (int j = 0; j < k; j++)
					{
						tmp += c[loop[(start + j) % loopLen]];
						tAns = max(tAns, tmp);
					}
				}
				ans = max(ans, tAns);
			}
			else
			{
				//do cycles - 1 cycle and then bruteforce
				ll tAns = c[loop[0]];
				for (int start = 0; start < loopLen; start++)
				{
					ll tmp = 0;
					for (int j = 0; j < k % loopLen + loopLen; j++)
					{
						tmp += c[loop[(start + j) % loopLen]];
						tAns = max(tAns, tmp);
					}
				}
				ans = max(ans, tAns + max((cycles-1) * loopSum, (ll)0));
			}
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 3232
#include<stdio.h>{
	int main(){
		int n,i;
		int j=0;
		double p[n];
		double x=0;
		double max=0;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%lf",&p[i]);
			if(p[i]>max){
				max=p[i];
			}
		}
		
		for(i=0;i<n;i++){
			if(p[i]==max&&j==0){
				x+=p[i]/2;
				j++;
			}
			else{
				x+=p[i];
			}
		}
		printf("%.0f",x);
	return(0);
}

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

int n;
int a[81];

signed main()
{
	int money=1000;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	
	int s=0;
	for(int i=1;i<=n-1;i++)
	{
		s=0;
		if(a[i]<a[i+1])
			s=money/a[i];
		money+=(a[i+1]-a[i])*s;
	}
	cout<<money<<endl;
	return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        
        int[] a = new int[N]; 
        int[] b = new int[N]; 
        int[] c = new int[N]; 
        int[][] dp = new int[N][3];
        
        //A:0 B:1 C:2
        for(int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
            b[i] = Integer.parseInt(sc.next());
            c[i] = Integer.parseInt(sc.next());
        }
        
        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];
        
        for(int i = 1; i <N; i++) {
            dp[i][0] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
            dp[i][1] = max(dp[i-1][0]+b[i], dp[i-1][2]+b[i]);
            dp[i][2] = max(dp[i-1][0]+c[i], dp[i-1][1]+c[i]);
        }
        
        System.out.println(max(dp[N-1][0] , max(dp[N-1][1], dp[N-1][2])));
    }
    
    public static int max(int a, int b) {
        if(a >= b) {
            return a;
        }else {
            return b;
        }
    }
    
    public static int min(int a, int b) {
        if(a >= b) {
            return b;
        }else {
            return a;
        }
    }
}

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

int main() {
  int n;
  cin>>n;
  int count=0;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  while(1){
    bool odd=false;
    for(int i=0;i<n;i++){
      if(a[i]%2==1){
        odd=true;
      }
    }
    if(odd)break;
    count++;
    for(int i=0;i<n;i++){
      a[i]/=2;
    }
  }
    cout<<count<<endl;
  }

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

struct Segtree{
	typedef int sgT;
	vector<sgT> seg;
	int nbn; sgT INF;
	int lstk;
	void init(int n){
		for(nbn=1; nbn<n+2; nbn<<=1); INF=1<<29; // min:+inf,max:-inf
		seg.assign(nbn*2, INF);
	}
	sgT comp(sgT l, sgT r){return min(l, r);}  //min<->max
	void update(int k,sgT x){
		k+=nbn-1; seg[k]=x;
		while(k>0){ k=(k-1)/2; seg[k]=comp(seg[k*2+1],seg[k*2+2]); }
	}
	sgT query2(int a,int b,int l,int r,int k){
		if(b<=l||r<=a) return INF;
		if(a<=l&&r<=b) return seg[k];
		return comp(query2(a,b,l,(l+r)/2,k*2+1), query2(a,b,(l+r)/2,r,k*2+2));
	}
	sgT query(int a,int b){ return query2(a,b,0,nbn,0); }
	sgT get(int a){return seg[nbn+a-1];}  // =query(a,a+1)

	int getpos(int l, int r, sgT v){
		int lo=l-1, hi=r;
		while(hi - lo >1){
			int md = (hi + lo) >> 1;
			if( query(lo, md+1) == v ) hi = md; else lo = md; 
		}
		return hi;
	}
};

Segtree sgg, sgk;
VI rv;


VI f(int l, int r){
	auto& sg1 = l%2? sgk : sgg;
	auto& sg2 = l%2? sgg : sgk;
	
	int v = sg1.query(l,r);
	//int a = sg1.getpos(l,r,v);
	int a = rv[v];
	int t = sg2.query(a+1,r);
	//int b = sg2.getpos(a+1,r,t);
	int b = rv[t];
	return VI{v,l,r,a,b,t};
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	rv.resize(n+2);
	sgg.init(n+2); sgk.init(n+2);

	rep(i,n){
		int c; cin >>c;
		rv[c] = i;
		if(i%2) sgk.update(i,c);
		else sgg.update(i,c);
	}
	
	priority_queue<VI, vector<VI>, greater<VI> > pq;
	pq.emplace(f(0,n));
	while(!pq.empty()){
		auto cr = pq.top(); pq.pop();
		cout << cr[0] <<" " << cr[5] <<" ";
		if(cr[3] - cr[1] > 1) pq.emplace(f(cr[1],   cr[3]));
		if(cr[4] - cr[3] > 1) pq.emplace(f(cr[3]+1, cr[4]));
		if(cr[2] - cr[4] > 1) pq.emplace(f(cr[4]+1, cr[2]));
	}
	cout <<"\n";
	return 0;
}


Measured memory_bytes: 8628
import math
x1, y1, x2, y2 = map(float, input().split())
x = abs(x1 - x2)
y = abs(y1 - y2)
xx = x ** 2
yy = y ** 2
zz = xx + yy
z = math.sqrt(zz)
print(round(z, 8))



Measured memory_bytes: 5656
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int A = scn.nextInt();
		int B = scn.nextInt();
		int C = scn.nextInt();
		int D = scn.nextInt();
		System.out.println(Math.min(A, B) + Math.min(C, D));
	}

}


Measured memory_bytes: 21716