akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

int main(){
    ll x,k,d;
    scanf("%lld%lld%lld",&x,&k,&d);
    ll xs=x;
    ll ks=k;
    x=abs(x);
    ll steps_to_minval=ceil((double)(x)/d);
    steps_to_minval=min(steps_to_minval,k);
    k-=steps_to_minval;
    ll min_val=abs(x-steps_to_minval*d);
    ll a1;
    if(k%2==0){
        a1=min_val;
    }
    else{
        a1=min_val+d;
    }
    x=abs(xs);
    steps_to_minval=floor((double)(x)/d);
    steps_to_minval=min(steps_to_minval,ks);
    ks-=steps_to_minval;
    min_val=abs(x-steps_to_minval*d);
    debug(min_val);
    ll a2;
    if(ks%2==0){
        a2=min_val;
    }
    else{
        a2=min_val+d;
    }
    debug(a1,a2);
    cout<<min(a1,a2)<<"\n";
    return 0;
}


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


int main() {

    int n;
    cin >> n;
    int sum = 0;
    int m = 0;
    rep(i,n) {
        int p; cin >> p;
        sum += p;
        m = max(m,p);
    }
    cout << sum - m/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1e5;
int n,x;
int a[maxn*2+8];

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

int main()
{
    n=read(),x=read();
    if (x==1||x==2*n-1)
	{
	    puts("No");
	    return 0;
	}
    if (n==2)
	{
	    puts("Yes");
	    puts("1 2 3");
	    return 0;
	}
    a[n]=x;
    if (x==2)
	{
	    a[n-1]=x+1,a[n+1]=x-1,a[n+2]=x+2;
	    int now=1;
	    for (int i=1;i<n-1;i++)
		{
		    if (now==x-1) now=x+3;
		    a[i]=now++;
		}
	    for (int i=n+3;i<2*n;i++)
		{
		    if (now==x-1) now=x+3;
		    a[i]=now++;
		}
	}
    else
	{
	    a[n-1]=x-1,a[n+1]=x+1,a[n+2]=x-2;
	    int now=1;
	    for (int i=1;i<n-1;i++)
		{
		    if (now==x-2) now=x+2;
		    a[i]=now++;
		}
	    for (int i=n+3;i<2*n;i++)
		{
		    if (now==x-2) now=x+2;
		    a[i]=now++;
		}
	}
    puts("Yes");
    for (int i=1;i<2*n;i++) printf("%d ",a[i]);puts("");
    return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59



int main(){
  ll i,j;
  ll h,w,d;
  cin>>h>>w>>d;
  ll x;

  vector< pair<ll,P> > v;

  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin>>x;
      v.pb(make_pair(x,P(i,j)));
    }
  }
  sort(v.begin(),v.end());
  ll c[h*w+1];

  for(i=0;i<d;i++) c[i]=0;

  for(i=d;i<h*w;i++){
    ll i1=v[i].se.fi;
    ll j1=v[i].se.se;
    ll i2=v[i-d].se.fi;
    ll j2=v[i-d].se.se;
    c[i]=c[i-d]+abs(i1-i2)+abs(j1-j2);
  }
  ll q;
  cin>>q;
  ll l,r;
  for(i=0;i<q;i++){
    cin>>l>>r; r--; l--;
    ll ans=c[r]-c[l];
    cout<<ans<<endl;
  }
  return 0;

}

Measured memory_bytes: 4468
import numpy as np
import itertools

N, D = map(int, input().split())
X = [np.array(input().split(), dtype=np.int64) for _ in range(N)]

ans = 0

for u, v in itertools.combinations(X,2):
  d = ((u - v) * (u - v)).sum()
  d2 = int(d ** 0.5)
  
  if d2 ** 2 == d:
    ans += 1
    
print(ans)

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

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> X[i].first;
		X[i].second = i;
	}

	sort(X,X+N);

	for (int i = 0; i < N; ++i)
	{
		if (i < N/2) ans[X[i].second] = X[N/2].first;
		else ans[X[i].second] = X[N/2-1].first;
	}

	for (int i = 0; i < N; ++i)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

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

int main() {
    long long int n;
    cin >> n;
    for(long long int i = 1; i <= 3500; ++i) {
        for(long long int j = 1; j <= 3500; ++j) {
            if(4*i*j-n*i-n*j == 0) continue;
            if((n*i*j)%(4*i*j-n*i-n*j) == 0 && (n*i*j)/(4*i*j-n*i-n*j) >= 1) {
                cout << i << " " << j << " " << ((n*i*j)/(4*i*j-n*i-n*j)) << '\n';
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0; i<N; i++) cin >> L.at(i);
  sort(L.begin(),L.end());
  int res = 0;
  for(int i = 0; i<N;i++){
  	for(int j = 0;j<i;j++){
    	for(int k = 0;k<j;k++){
        	if( (L.at(i) != L.at(j)) &&(L.at(j) != L.at(k))
               &&(L.at(k) + L.at(j) > L.at(i)) ) res++;
        }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3608
let S = stdin.ReadLine()

let solver =
    let rec loop r1 r2 i =
        if i = S.Length then min r1 r2
        elif i % 2 = 0 then
            loop
                (if S.[i] = '0' then r1
                 else r1 + 1)
                (if S.[i] = '1' then r2
                 else r2 + 1) (i + 1)
        else
            loop
                (if S.[i] = '1' then r1
                 else r1 + 1)
                (if S.[i] = '0' then r2
                 else r2 + 1) (i + 1)
    loop 0 0 0

solver |> stdout.WriteLine


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(void) {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> A(N+1);
    for(int i=1; i<=N; i++) {
        cin >> A[i];
    }

    for(int i=1; i<=N; i++) {
        A[i] = (A[i-1] + A[i] - 1) % K;
    }

    map<int64_t,int64_t> mp;
    for(int i=0; i<min(N+1, K); i++) {
        mp[A[i]]++;
    }

    int64_t ans = 0;
    for(int i=0; i<N; i++) {
        mp[A[i]]--;
        ans += mp[A[i]];
        if(i+K <= N) mp[A[i+K]]++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14336
#include<stdio.h>
#include<stdlib.h>

int main(void) 
{
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
    if(a < b && b < c )
    {
    	printf("Yes\n");
	}
	else 
	{
		printf("No\n");
	}
    return 0;
}


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

#ifndef ONLINE_JUDGE 
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using ll = long long;
using ull = unsigned long long;

#define F first
#define S second
#define all(x) begin(x), end(x)

template <class T>
void read_vector(vector<T>& arr) {
	const int size = arr.size();
	for (int i = 0; i < size; ++i) cin >> arr[i];
}

void exec()
{
	int n;
	cin >> n;

	vector<int> arr(n);
	read_vector(arr);

	vector<int> dp(n, INT_MAX);
	dp[0] = 0;

	for (int i = 0; i < n - 1; ++i) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(arr[i] - arr[i + 1]));
		if (i + 2 < n)
			dp[i + 2] = min(dp[i + 2], dp[i] + abs(arr[i] - arr[i + 2]));
	}

	cout << dp.back() << endl;
}

















int main()
{
	exec();

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INT long long int
using namespace std;
INT n, a[5050], x, y;
int main() {
  cin>>n>>x>>y;
  for(int i = 0 ; i < n ; i++ ) cin>>a[i];
  if( n == 1 ) cout<<abs(a[0]-y)<<endl;
  else  cout<<max(abs(a[n-1]-y), abs(a[n-2]-a[n-1]));
}


Measured memory_bytes: 256
#include<stdio.h>
char c;
int f;
int nextInt();

int N, ans, i, t;
int a[100000];
char b[100000];
int main(){
	N=nextInt();
	for(i=0; i<N; i++){
		a[i]=nextInt();
	}
	i = 1;
	ans = 1;
	while(1){
		t = a[i-1];
		if(t==2){break;}
		if(b[t-1]){break;}
		b[t-1] = 1;
		i = t;
		ans++;
	}
	if(t==2){
		printf("%d\n", ans);
	}else{
		printf("-1\n");
	}
	return 0;
}

int nextInt(){
	f=0; c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long int
#define ll long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bn begin()
#define en end()
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007
#define pi 3.141592653589
using namespace std;

int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie   
    int n ;
    cin >> n ;
    map<string, int> m ;
    rep(i, 0, n) {
        string s ;
        cin >> s ;
        m[s]++ ;
    }
    cout << "AC x " << m["AC"] << "\n" ;
    cout << "WA x " << m["WA"] << "\n" ;
    cout << "TLE x " << m["TLE"] << "\n" ;
    cout << "RE x " << m["RE"] << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

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


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
vector<long long>vi;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	long long sum = 0;
	cin >> n >> m;
	long long arr[n];
	for(int i=0;i<n;i++){
		cin >> arr[i];
		sum += arr[i];
	}
	for(int i=0;i<n;i++){
		long long temp = arr[i];
		while(temp){
			long long x = temp-(temp/2);
			vi.push_back(x);
			temp /= 2;
		}
	}
	sort(vi.begin(),vi.end(),greater<long long>());
	int sz = vi.size();
	int mn = min(sz,m);
	for(int i=0;i<mn;i++){
		sum -= vi[i];
	}
	cout << sum <<"\n";
}


Measured memory_bytes: 35684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main implements Runnable {
	//@start
	public static class WeightedUnionFind {
		int[] par; // 親の番号
		int[] ws; // 親との重みの差

		public WeightedUnionFind(int n) {
			par = new int[n];
			ws = new int[n];
			for (int i = 0; i < n; i++) {
				par[i] = -1;
			}
		}

		public int find(int x) {
			if (par[x] < 0) {
				return x;
			} else {
				final int parent = find(par[x]);
				ws[x] += ws[par[x]];
				return par[x] = parent;
			}
		}

		public int weight(int x) {
			find(x);
			return ws[x];
		}

		public boolean union(int x, int y, int w) { // x <-(w)- y (x + w = y)
			w += weight(x);
			w -= weight(y);
			x = find(x);
			y = find(y);

			if (x != y) {
				par[x] += par[y];
				par[y] = x;
				ws[y] = w;

				return true;
			} else {
				return false;
			}
		}

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

		public Integer diff(int x, int y) { // x - y を求める. 比較不能ならnull.
			if (!same(x, y)) {
				return null;
			} else {
				return this.weight(x) - this.weight(y);
			}
		}

		public int size(int x) {
			return -par[find(x)];
		}
	}
	//@end
	
	public void run() {

		try {
			Scanner sc = new Scanner(System.in);

			while (true) {
				final int n = sc.nextInt();
				final int m = sc.nextInt();

				if (n == 0 && m == 0) {
					break;
				}

				WeightedUnionFind uf = new WeightedUnionFind(n);

				for (int i = 0; i < m; i++) {
					final String ops = sc.next();

					if ("?".equals(ops)) {
						final int r = sc.nextInt() - 1;
						final int l = sc.nextInt() - 1;

						if (!uf.same(r, l)) {
							System.out.println("UNKNOWN");
						} else {
							System.out.println(uf.weight(l) - uf.weight(r));
						}
					} else {
						final int r = sc.nextInt() - 1;
						final int l = sc.nextInt() - 1;
						final int w = sc.nextInt();

						uf.union(r, l, w);
					}
				}
			}

			sc.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) throws IOException {
		new Thread(null, new Main(), "RUN", 8 * 1024 * 1024).start();
	}

	public static class Scanner {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		// 他のnextXXXもXXX.parseXXX()メソッドを使って作れるので省略

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 65248
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
typedef pair <LL,int> li;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

int l, tab[N], SP[N], men, i;
LL T1[N], T2[N], sum, res[N], wyn;
set<li> s;

int main() {
scanf("%d", &l);
for (i=1;i<=l;i++) scanf("%d", &tab[i]);
T1[0] = 0;
sum = 0;
for (i = 1;i <= l;i++) {
	sum += tab[i];
	T1[i] = sum;
	if (tab[i] == 0) T1[i] = min(T1[i], 2 + T1[i - 1]); else T1[i] = min(T1[i], tab[i] % 2 + T1[i - 1]);
}	

T2[l] = 0;
sum = 0;
for (i = l - 1;i >= 0;i--) {
	sum += tab[i + 1];
	T2[i] = sum;
	if (tab[i + 1] == 0) T2[i] = min(T2[i], 2 + T2[i + 1]); else T2[i] = min(T2[i], tab[i + 1] % 2 + T2[i + 1]);
}
SP[0] = 0;
for (i=1;i<=l;i++) SP[i] = SP[i - 1] + 1 - tab[i] % 2;
for (i=l;i>=0;i--) {
	res[i] = SP[i] + T2[i];
	s.insert(li(res[i], i));
}
wyn = s.begin()->first;
men = 0;
for (i=1;i<=l;i++) {
	s.erase(li(res[i - 1], i - 1));
	if (tab[i] % 2 == 0) men++;
	wyn = min(wyn, s.begin()->first + T1[i] - men);
}
printf("%lld\n", wyn);
return 0;
}

Measured memory_bytes: 18944
parseInt(x) = parse(Int,x)

parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    A, op , B = readline() |> split
    A = parseInt(A)
    B = parseInt(B)

    if op=="+"
        println(A+B)
    else
        println(A-B)
    end
end

main()


Measured memory_bytes: 109304
#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in int read()
	{
		int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
const int N=3e5+5,p=1e9+7;
int n,f[N][5][5],ans;char s[N];
in void M(int &x) {x-=p;x+=x>>31&p;}
int main()
{
	n=gs(s+1);f[0][0][0]=1;
	for(int i=0;i<n;i++)
	{
		if(s[i+1]!='1') for(int j=0;j<3;j++) for(int k=0;k<3;k++)
		(k==2)?M(f[i+1][j][k-1]+=f[i][j][k]):M(f[i+1][j][k+1]+=f[i][j][k]);
		if(s[i+1]!='0') for(int j=0;j<3;j++) for(int k=0;k<3;k++)
		(k==0)?M(f[i+1][j+(j!=2)][k]+=f[i][j][k]):M(f[i+1][j][k-1]+=f[i][j][k]);
	}
	for(int i=0;i<3;i++) for(int j=0;j<=i;j++) M(ans+=f[n][i][j]);
	write(ans,'\n');
	return ot(),0;
}
//Author: disangan233

Measured memory_bytes: 33224
Option Strict On

Module Module1
    Sub Main()
        'let'
        Dim tmp() As Long = Array.ConvertAll(
            Of String, Long)(Split(Console.ReadLine()), AddressOf Long.Parse)
        Dim A1 As Long = tmp(0)
        Dim A2 As Long = tmp(1)
        Dim A3 As Long = tmp(2)

        'var'
        Dim A() As Long = New Long() {A1, A2, A3}
        Dim ans As Long = 0
        Array.Sort(A)

        For i As Int32 = 0 To UBound(A)
            If i <> 0 Then
                ans += Math.Abs(A(i) - A(i - 1))
            End If
        Next

        Console.WriteLine(ans)

    End Sub
End Module

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

int main() {
  int N;
  cin >> N;
  VVI digits(10, vector<ll>(10));
  rep(i, N) {
    string S;
    S = to_string(i + 1);
    int beg = S.at(0) - '0';
    int end = S.at(S.size() - 1) - '0';
    digits.at(beg).at(end) += 1;
  }
  ll ways = 0;
  for (int i = 1; i < 10; i++) {
    for (int j = i; j < 10; j++) {
      ways += digits.at(i).at(j) * digits.at(j).at(i);
      if (i != j) {
        ways += digits.at(i).at(j) * digits.at(j).at(i);
      }
    }
  }
  cout << ways << endl;
  return 0;
}


Measured memory_bytes: 256
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
#define vi vector<int>
#define vpii vector<pair<int,int>> 
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>> 
#define pii pair<int,int> 
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>

ld pie=3.141592653589793238462643383279;
int mod=1e9+7;

struct point{
  ld x,y;
};

vvi mat_mul(vvi mat1,vvi mat2){
  vvi ret;
  f(i,0,2){
    vi xx;
    f(j,0,2){
      int r=0;
      f(k,0,2) r=(r+(mat1[i][k]*mat2[k][j])%mod)%mod;
      xx.pb(r%mod);
    }
    ret.pb(xx);
  }
  return ret;
}

vvi mat_exp(vvi mat,int p){
  vvi iden={{1,0},{0,1}};
  while(p!=0){
    if(p&1) iden=mat_mul(iden,mat);
    p/=2; 
    mat=mat_mul(mat,mat);
  }
  return iden;
}


int myexp(int p){
  p++;
  int r=1;
  int val=2;
  while(p!=0){
    if(p&1){
      r*=val;
    }
    val*=val;
    p/=2;
  }
  r-=2;
  return r;
}


int fact[2000005];
int infact[2000005];
 
int inv(int a){
  int y=mod-2;
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r;
}
 
int po(int a,int y){
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r; 
}
 
void facto(){
  fact[0]=1;
  f(i,1,2000005) {fact[i]=i*fact[i-1]; fact[i]%=mod;}
  f(i,0,2000005) infact[i]=inv(fact[i]); 
}
 
int nck (int n,int k){
  if(k<0 || k>n) return 0;
  int ret=fact[n]; ret*=infact[k]; ret%=mod;
  ret*=infact[n-k]; ret%=mod;
  return ret;
}
  
void mymul(int arr[],int num){
  int carry=0;
  f(i,0,100){
    arr[i]=arr[i]*num+carry;
    carry=arr[i]/10;
    arr[i]%=10;
  }
}

map<int,int> mp;

int myfun(int val){
  auto it = mp.lower_bound(val);
  if(it==mp.begin()) return 0;
  --it; 
  return it->second;
}

void myerase(int val,int key){
 
}

  
int32_t main(){ 
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int n; cin>>n;
  int a[n];
  f(i,0,n){
    int x; cin>>x; --x;
    a[i]=x;
  }
  int cnt=0;
  f(i,0,n) if(a[i]==i){
    ++cnt;
    swap(a[i],a[(i+1)%n]);
  }
  cout<<cnt;
  return 0; 
}
// check for overflows dummy !!!

Measured memory_bytes: 4440
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
}


Measured memory_bytes: 384
A, B, C, X, Y = [int(x) for x in input().split()]


sum1 = 0
sum1 = A * X + B * Y

sum2 = 0
sum2 += C * min(X, Y) * 2
if (X < Y):
    sum2 += B * abs(Y - X)
else:
    sum2 += A * abs(Y - X)

sum3 = 0
sum3 = C * max(X, Y) * 2

print(min(sum1, sum2, sum3))


Measured memory_bytes: 3060
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, 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")
    };
}

fn main() {
    input!{
        mut s: usize
    }
    let mut t: Vec<bool> = vec![false; 1000001];
    let mut i = 1;
    while !t[s] {
        t[s] = true;
        if s % 2 == 0 {
            s /= 2;
        } else {
            s = 3 * s + 1;
        }
        i += 1;
    }
    println!("{}", i);
}


Measured memory_bytes: 4352
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def longs: Seq[Long] = strings.map(_.toLong)
    def doubles: Seq[Double] = strings.map(_.toDouble)
    def i(n: Int): Int = ints(n)
    def d(n: Int): Double = doubles(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]): Unit = {
    readLines(10).map(_.i(0)).sorted.reverse.take(3).foreach(println(_))
  }
}

Measured memory_bytes: 44064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	string s;
	cin >> s;

	if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

typedef double R;
typedef complex<R> P;
R const eps = 1e-8;
R const pi = acos(-1);

int main(){
    int n;
    while(cin>>n && n){
        vector<P> ps(n);
        rep(i,n){
            R x,y; cin >> x >> y;
            ps[i] = P(x,y);
        }
        int ans = 1;
        rep(i,n)rep(j,i){
            P & p = ps[i];
            P & q = ps[j];
            R d = abs(p-q)/2;
            if(d+eps > 1.0) continue;
            P m = (p+q)/R(2);
            R l = sqrt(1-d*d);
            P c = m + (p-m)/d*l*P(0,1);
            int cnt = 0;
            dump(abs(c-p));
            rep(k,n) if(abs(c-ps[k]) < 1.0+eps) cnt++;
            ans = max(ans,cnt);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007
const double pi =3.1415926535897932;

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    double a,b,h,m;cin>>a>>b>>h>>m;
    double th= abs(m/2+h*30-6*m);
    th= pi*th/180;
    double ans = sqrt(a*a+b*b -2*a*b*cos(th));
    printf("%.15lf",ans);
 
return 0;
}

Measured memory_bytes: 4232
def main():
    N = int(input())
    L = list(map(int, input().split()))
    count = 0
    for i, l1 in enumerate(L):
        for j in range(i+1, len(L)):
            for k in range(j+1, len(L)):
                lengths = sorted([L[i], L[j], L[k]])
                if sum(lengths[:2]) > lengths[2]:
                    if len(set(lengths)) == 3:
                        count += 1
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
import bisect


q = int(input())

S = []


for _ in range(q):

    command, *list_num = input().split()
    x = int(list_num[0])

    index_left_x = bisect.bisect_left(S, x)
    index_right_x = bisect.bisect_right(S, x)

    if   command == "0":
        # insert(x)
        x = int(list_num[0])
        S.insert(index_left_x, x)
        print(len(S))
    elif command == "1":
        # find(x)
        x = int(list_num[0])
        print(index_right_x - index_left_x)
    elif command == "2":
        # delete(x)
        x = int(list_num[0])
        S[index_left_x:index_right_x]= []
    elif command == "3":
        # dump(L, R)
        L = x
        R = int(list_num[1])

        index_left = bisect.bisect_left(S, L)
        index_right = bisect.bisect_right(S, R)
        
        for element in S[index_left:index_right]:
            print(element)
    else:
        raise


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

int main(){
    long long n,m;
    cin >> n >> m;
    if(n==1&&m==1){
        cout << 1 << endl;
        return 0;
    }
    if(n==1||m==1){
        cout << n*m-2 << endl;
    }else if(n==2||m==2){
        cout << 0 << endl;
    }else{
        long long l=(n-2)*(m-2);
        cout << l << endl;
    }
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vpll v(m);
  rep(i,m){
    ll a,b; cin>>a>>b; a--,b--;
    v[i]={a,b};
  }
  reverse(all(v));
  ll sum=n*(n-1)/2;
  vll ans(m);
  ans[0]=sum;
  UnionFind uf(n);
  rep(i,m-1){
    if(!uf.isSame(v[i].first,v[i].second)){
      sum-=uf.size(v[i].first)*uf.size(v[i].second);
      uf.connect(v[i].first,v[i].second);
    }
    ans[i+1]=sum;
  }
  rrep(i,m){
    cout<<ans[i]<<endl;
  }
  
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e8;
typedef pair<int,int> P;

int main(){
  int N;cin>>N;
  vector<int> B(N,0);
  REP(i,0,N-1)cin>>B[i];
  int ans=B[0];
  REP(i,0,N-1)ans+=min(B[i],B[i+1]);
  print((ans+B[N-2]))

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define re register
#define LL long long
#define SIZE 405
using namespace std;
int n;
LL a[SIZE],s[SIZE],dp[SIZE][SIZE];
int main()
{	
    cin>>n;
    memset(dp,0x3f3f3f3f,sizeof(dp));
    for(re int i=1;i<=n;++i)
    	cin>>a[i],dp[i][i]=0,s[i]=s[i-1]+a[i];
    for(re int l=n;l>=1;--l)
    	for(re int r=l+1;r<=n;++r)
    	{
    		for(re int k=l;k<r;++k)
    			dp[l][r]=min(dp[l][r],dp[l][k]+dp[k+1][r]);
			dp[l][r]+=s[r]-s[l-1];
		} 
   	cout<<dp[1][n]<<endl;
    return 0;
}

Measured memory_bytes: 1536
import sys
input=sys.stdin.readline
s=' '+input().rstrip()
t=' '+input().rstrip()
m=len(s)-1
n=len(t)-1
dp=[[0]*(n+1) for i in range(m+1)]
for i in range(1,m+1):
    for j in range(1,n+1):
        if s[i]==t[j]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
ans=''
while m>0 and n>0:
    if dp[m][n]==dp[m][n-1]:
        n-=1
    elif dp[m][n]==dp[m-1][n]:
        m-=1
    elif dp[m][n]==dp[m-1][n-1]+1:
        ans=s[m]+ans
        m-=1
        n-=1
print(ans)








Measured memory_bytes: 112220
using System;
using System.Collections.Generic;
public class ABC127B {
    public static void Main() {
        int r, D;
        List<int> x = new List<int>();
        string[] str = System.Console.ReadLine().Split(' ');
        r = int.Parse(str[0]);
        D = int.Parse(str[1]);
        x.Add(int.Parse(str[2]));
        for(int i = 0; i < 10; i++) {
            x.Add(r * x[i] - D);
            System.Console.WriteLine(x[i + 1]);
        }
    }
}


Measured memory_bytes: 11092
//DPまとめコン


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define INTMAX 1000000000
#define MOD 1000000007
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VVI vector<VI>
#define alf "abcdefghijklmnopqrstuvwxyz"


//segment tree
/*
struct SegTree{
	VL seg;
	int segsize;
	void init(int n){//セグ木の初期化
		segsize = 1;
		while(n > segsize) segsize = (segsize << 1);
		for(int i=0; i< segsize * 2 - 1; i++) seg.push_back(0);
	}
	void Update(int id, LL x){
		seg[id] = x;
		while(id){
			id = (id - 1) / 2;
			seg[id] = max(seg[id * 2 + 1], seg[id * 2 + 2]);
		}
	}
	LL RMaxQ(int l, int r, int nl, int nr, int id){//[i, j)のRMaxQを求める
		if(nl >= r || nr <= l) return 0;//まったくかぶらない
		if(l<=nl&&nr<=r) return seg[id];//完全に入っている
		int mid = (nl + nr) / 2, chi = id * 2 + 1;
		return max(RMaxQ(l, r, nl, mid, chi), RMaxQ(l, r, mid, nr, chi + 1));
	}
};

*/

int N,M;
set<int>s;
int par[100001];//そのノードのトップ
int root(int x) {
	if (par[x] == x)return x;
	par[x] = root(par[x]);
	return par[x];
}

bool  Is_same(int x, int y) {
	if (root(x) == root(y)) return true;
	return false;
}

void unite(int x,int y) {//id
	if (Is_same(x, y))return;
	par[root(x)] = root(y);
	return;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) par[i] = i;
	for (int i = 0; i < M; i++) {
		int X, Y, Z; cin >> X >> Y >> Z;
		X--; Y--;
		unite(X, Y);
	}
	for (int i = 0; i < N; i++)s.insert(root(i));
	cout << (int)s.size() << endl;

	return 0;
}




Measured memory_bytes: 5376
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    int N, W;
    cin >> N >> W;
    ll w[N], v[N];
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    ll dp[N + 1][W + 1];
    for (int i = 0; i < N + 1; i++) {
        for (int j = 0; j < W + 1; j++) {
            dp[i][j] = 0;
        }
    }
    for (int i = 1; i < N + 1; i++) {
        for (int j = 0; j < W + 1; j++) {
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if (j - w[i - 1] >= 0) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
            }
        }
    }
    OUT(dp[N][W]);
}

Measured memory_bytes: 79104
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define for0(i,n) for (int i=0; i<n; i++)
#define forr(i,n) for (int i=n-1; i>=0; i--)
#define fori(i,a,b) for (int i=a; i<=b; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define read(x) int x; scanf("%d",&x);
#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int main()
{
    #ifdef DEBUG
    freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    vec(int) cnt;
    int n;
    cin >> n;
    for0(i,n) {
        read(x);
        cnt.pb(x);
    }
    sort(all(cnt));

    int low = cnt[0];
    int high = cnt[n-1];
    if (low == high) {
        if (low == n-1)
            cout<<"Yes"<<endl;
        else {
            if (n/high >= 2)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
    }
    else if (low == high-1){
        int cur = 1;
        int i=0;
        for (; i<n && cnt[i]==low; i++) {
            cur++;
        }
        if (cur > high) {
            cout<<"No"<<endl;
        }
        else {
            pr(i) pr(cur) nl
            int high_cnt=n-i;
            int num_vals = high-cur+1;
            prl(high_cnt)
            prl(num_vals)
            if (high_cnt/num_vals >= 2)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
    }
    else {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 892
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int N = Integer.parseInt(in.next());
		int x,y,z,tmp;
		x=0;y=0;z=0;
		for(int i = 0; i<N; i++){
			tmp=Integer.parseInt(in.next());
			if(tmp%4==0)x++;
			else if(tmp%2==0)y++;
			else z++;
		}
		String ans = "No";
		if(x>=z)ans = "Yes";
		if(x+1>=z&&y%2==0)ans = "Yes";
		if(x==0&&z==0&&y>=2)ans="Yes";
		System.out.println(ans);
	}
}

Measured memory_bytes: 48708
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

void move(int sx, int sy, int tx, int ty)
{
    while (sy != ty) {
        if (sy < ty) {
            cout << "U";
            sy++;
        }
        else {
            cout << "D";
            sy--;
        }
    }

    while (sx != tx) {
        if (sx < tx) {
            cout << "R";
            sx++;
        }
        else {
            cout << "L";
            sx--;
        }
    }
}

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    if (sx == tx) {
        move(sx, sy, tx, ty);
        cout << "R";
        move(tx, ty, sx, sy);
        cout << "L";

        cout << "L";
        move(sx-1, sy, tx-1, ty);
        cout << "R";
        cout << "URR";
        move(tx+2, ty+1, sx+2, sy-1);
        cout << "LLU";
    }
    else if (sy == ty) {
        move(sx, sy, tx, ty);
        cout << "D";
        move(tx, ty, sx, sy);
        cout << "U";

        cout << "U";
        move(sx, sy+1, tx, ty+1);
        cout << "D";
        cout << "RDD";
        move(tx+1, ty-2, sx-1, sy-2);
        cout << "UUR";
    } else {
        move(sx, sy, tx, ty);
        move(tx, ty, sx, sy);

        cout << "L";
        move(sx-1, sy, tx, ty+1);
        cout << "D";
        cout << "R";
        move(tx+1, ty, sx, sy-1);
        cout << "U";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	while (cin >> N, N) {
		vector<int> A(N), B(N);
		for (int i = 0; i < N; ++i) cin >> A[i], A[i] *= -1;
		for (int i = 0; i < N; ++i) cin >> B[i], B[i] *= -1;
		sort(A.begin(), A.end());
		sort(B.begin(), B.end());
		int ans = 1 << 30;
		for (int i = 0; i < N / 2; ++i) {
			int ptr = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
			int g = (ptr - i) * 2;
			if (i * 2 + 1 <= g) ans = min(ans, i * 2 + 1);
		}
		if (ans != (1 << 30)) cout << ans << "\n";
		else cout << "NA\n";
	}
	return 0;
}


Measured memory_bytes: 3268
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long a=sc.nextInt();
		long b=sc.nextInt();
		long c=sc.nextInt();
		long d=sc.nextInt();
		long[] xy=new long[4];
		xy[0]=a*c;
		xy[1]=a*d;
		xy[2]=b*c;
		xy[3]=b*d;
		long ans=xy[0];
		for(int i=0;i<4;i++){
			ans=Math.max(xy[i],ans);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35728
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    H, N = map(int, readline().split())
    if H == N == 0:
        return False
    def get_block():
        s = readline().strip()
        v = (s[0] == '#') + (s[1] == '#')*2
        s = readline().strip()
        v += (s[0] == '#')*4 + (s[1] == '#')*8
        return v
    R = []
    for i in range(H):
        R.append(get_block())
    R.extend([0]*8)
    H += 8
    I = []
    for i in range(N):
        v = get_block(); w = get_block()
        if v == 0:
            v, w = w, 0
        if v & 3 == 0 and w & 3 == 0:
            v >>= 2; w >>= 2
        if v & 5 == 0 and w & 5 == 0:
            v >>= 1; w >>= 1
        I.append((v, w))
    def dfs(i, R0):
        if i == N:
            return 0
        v0, w0 = I[i]
        r = 0
        for k, f in ((0, 0), (1, 5), (2, 3), (3, 0)):
            v = v0 << k; w = w0 << k
            if v >= 16 or w >= 16 or v & f or w & f:
                continue
            h = H-1
            while h and R0[h-1] & v == 0 and R0[h] & w == 0:
                h -= 1
            R = R0[:]
            R[h] |= v; R[h+1] |= w
            c = 0
            if R[h+1] == 15:
                for j in range(h+2, H):
                    R[j-1] = R[j]
                c += 1
            if R[h] == 15:
                for j in range(h+1, H):
                    R[j-1] = R[j]
                c += 1
            r = max(r, dfs(i+1, R) + c)
        return r
    write("%d\n" % dfs(0, R))
    return True
while solve():
    ...



Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <queue>

using namespace std;
using ll = long long int;
using P = pair<int, ll>;

int main()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  k--;
  if(s[k] == 'A') s[k] = 'a';
  if(s[k] == 'B') s[k] = 'b';
  if(s[k] == 'C') s[k] = 'c';
  cout << s << endl;
}


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

using namespace std;

int main(){

  vector<int> mountain;
  int height;

  for(int i=0; i<10; i++){
    cin >> height;
    mountain.push_back(height);
  }

  sort(mountain.begin(),mountain.end(), greater<int>());

  for(int i=0; i<3; i++){
    cout << mountain[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
N, K = map(int, input().split())
P = tuple(map(int, input().split()))
P2 = P[K:]

max_sum = 0
sum_ = sum(P[:K])

for p, q in zip(P, P2):
  max_sum = max(max_sum, sum_)
  sum_ += q - p
  
max_sum = max(max_sum, sum_)
          
res = (max_sum + K)/ 2
print(res)

Measured memory_bytes: 32184
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
using namespace std;
vector<int> pat[214514];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		pat[a-1].pb(b-1);
		pat[b-1].pb(a-1);
	}
	vector<int> u1,u2,d1,d2;
	for(int i=0;i<n;i++){
		u1.pb(0);
		u2.pb(0);
		d1.pb(inf);
		d2.pb(inf);
	}
	queue<int> que;
	que.push(0);
	d1[0]=0;
	u1[0]=1;
	while(!que.empty()){
		int cur = que.front(); que.pop();
		for(int i=0;i<pat[cur].size();i++){
			if(u1[ pat[cur][i] ] == 0){
				u1[ pat[cur][i] ] = 1;
				d1[ pat[cur][i] ] = d1[cur] + 1;
				que.push( pat[cur][i] );
			}
		}
		//cout<<1<<endl;
	}
	vector< pair<int,int> > pv;
	for(int i=0;i<n;i++){
		pv.pb(mp(d1[i], i));
	}
	sort(pv.begin(),pv.end());
	reverse(pv.begin(),pv.end());
	int nexst = pv[0].second;
	//cout<<pv[0].first<<" "<<pv[0].second<<endl;
	queue<int> que2;
	que2.push(nexst);
	d2[nexst]=0;
	u2[nexst]=1;
	while(!que2.empty()){
		int cur = que2.front(); que2.pop();
		for(int i=0;i<pat[cur].size();i++){
			if(u2[ pat[cur][i] ] == 0){
				u2[ pat[cur][i] ] = 1;
				d2[ pat[cur][i] ] = d2[cur] + 1;
				que2.push( pat[cur][i] );
			}
		}
		//cout<<2<<endl;
	}
	for(int i=0;i<n;i++){
		//cout<<"d"<<i<<" "<<d2[i]<<endl;
	}
	sort(d2.begin(),d2.end());
	reverse(d2.begin(),d2.end());
	int lgst = d2[0];
	if((lgst%3)!=1)cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;
}

Measured memory_bytes: 19316
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll, ll> pll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define foro(i, n) for(i=0; i<n; i++)
#define forl(i, n) for(i=1; i<=n; i++)
#define x first
#define y second
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;

struct UnionFind{
	int n;
	vi size, par, rank;
	UnionFind(int _n){
		n = _n;
		size.assign(n, 1);
		par.assign(n, 1);
		rank.assign(n, 1);
		for(int i=0; i<n; i++)
			par[i] = i;
	}
	int Find(int a){	return (a==par[a] ? a : Find(par[a]));}
	void Union(int a, int b){
		a = Find(a);
		b = Find(b);
		if(a==b)	return;
		if(rank[a]<rank[b]){
			par[a] = b;
			size[b] += size[a];
		}
		else{
			par[b] = a;
			size[a] += size[b];
			if(rank[a]==rank[b])
				rank[a]++;
		}
	}
	int getSize(int a){
		return size[Find(a)];
	}
};


int main()
{
	int i, j, k, l, tmp;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m, u, v;
	cin >> n >> m >> k;
	vi cblocks(n), cfriends(n);
	UnionFind uf(n);
	foro(i, m){
		cin >> u >> v;
		u--, v--;
		cfriends[u]++;
		cfriends[v]++;
		uf.Union(u, v);
	}
	foro(i, k){
		cin >> u >> v;
		u--, v--;
		if(uf.Find(u)==uf.Find(v)){
			cblocks[u]++;
			cblocks[v]++;
		}
	}
	foro(i, n){
		printf("%d ", uf.getSize(i) - 1 - cfriends[i] - cblocks[i]);
	}
}



Measured memory_bytes: 2816
import sys
# from math import gcd
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
n = int(sys.stdin.readline())
a = list(map(int,sys.stdin.readline().split()))
pref,suf = [0]*(n+2),[0]*(n+2)
pref[1] = a[0]
for i in range(2,n+1):
    pref[i] = gcd(pref[i-1],a[i-1])
suf[n] = a[n-1]
for i in range(n-1,0,-1):
    suf[i] = gcd(suf[i+1],a[i-1])
ans = max(suf[2],pref[n-1])
for i in range(2,n):
    ans = max(ans,gcd(pref[i-1],suf[i+1]))
print(ans)


Measured memory_bytes: 14488
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {

  int N;
  cin>>N;
  
  if(N%2==0){
    cout<<N/2<<endl;
  }
  else if(N%2!=0){
    cout<<1+N/2<<endl;
  }
}


Measured memory_bytes: 256