akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


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

//INT_MAX	2,147,483,647 = 2*1.0e9

vector<ll> a;
vector<ll> p;

ll calc(int n, ll x){
  if(n == 0){
    if(x == 0) return 0;
    else return 1;
  } else {
    if(x == 1) return 0;
    if(1 < x && x <  2 + a[n-1]) return calc(n-1, x-1);
    if(x == 2 + a[n-1]) return p[n-1] + 1;
    if(2+a[n-1] < x && x < 3 + 2*a[n-1]) return p[n-1] + 1 + calc(n-1, x-2-a[n-1]);
    return p[n];
  }
}


int main(){
  int N; ll X;
  cin >> N >> X;

  a.resize(N+1);
  p.resize(N+1);

  a[0] = 1; p[0] = 1;
  for(int i = 0; i < N; i++){
    a[i+1] = 2 * a[i] + 3;
    p[i+1] = 2 * p[i] + 1;
  }

  cout << calc(N, X) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 long long N,t=1000000007;
  cin>>N;
  long long k=1,m=1,l=1,ans;
  for(int i=0 ; i<N;i++){
    k*=10;
    if(k>=t)
      k=k%t;
    
    
  }
  for(int i=0; i<N;i++){
    l*=9;
    if(l>=t)
      l=l%t;
    
  }
  for(int i=0 ; i<N;i++){
    m*=8;
    if(m>=t)
      m=m%t;
    }
  l=l*2%t;
  ans=k-l+m;
  if(ans<0)
    ans+=t;
  ans=ans%t;
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3632
a, b, c = map(int, input().split())

cnt = 0
while True:
    # print(a, b, c)
    x, y, z = a, b, c

    if x % 2 == 1 or y % 2 == 1 or z % 2 == 1:
        break

    if x == y and y == z and z == x:
        cnt = -1
        break

    x, y, z = a/2, b/2, c/2
    a, b, c = y+z, z+x, x+y
    cnt += 1
print(cnt)


Measured memory_bytes: 61672
import java.util.*;

class Main{

    final static int LEN=150;
    static int[][] graph = new int[LEN][LEN];
    static int[] d = new int[LEN];
    static int[] f = new int[LEN];

    static int n, u, k;
    static int time;

    public static void main(String args[]){
	Scanner in = new Scanner(System.in);

	n=in.nextInt();
	for(int i=0; i<n; i++){
	    u=in.nextInt();
	    k=in.nextInt();
	    //read vartex informetion
	    for(int j=0; j<k; j++){
		graph[u-1][in.nextInt()-1]=1;
	    }
	}

	//DFS
	for(int i =0; i<n; i++){
	    if(d[i]==0){
		dfs(i);
	    }
	}

	//print
	for(int i=0; i<n; i++){
	    System.out.println( i+1 + " " + d[i] + " " + f[i]);
	}
    }

    static void dfs(int i){
	time++;
	d[i]=time;

	//visit node
	for(int j=0; j<n; j++){
	    if(graph[i][j]!=0 && d[j]==0){
		dfs(j);
	    }
	}
	//get end time
	time++;
	f[i]=time;
    }
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n,k;
 cin>>n>>k;
 ll a[n+10];
 rep(i,0,n)cin>>a[i];
 
 ll ans=1e9;
 rep(i,0,n-k+1){
  ans=min(ans,abs(a[i])+abs(a[i+k-1]-a[i]));
  ans=min(ans,abs(a[i+k-1])+abs(a[i+k-1]-a[i]));
 }
 if(ans==1e9)ans=0;
 pr(ans);
 return 0;}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> N;
	vector<int> v(N), c(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < N; i++)cin >> c[i];
	for (int i = 0; i < N; i++)ans += ((v[i] - c[i] > 0) ? v[i] - c[i] : 0);
	cout << ans << endl;
}


Measured memory_bytes: 256
import static java.lang.System.*;
import java.util.*;

class UnionFind {
    int[] par;
    long[] num;

    UnionFind(int n) { 
    	par = new int[n];
    	num = new long[n];
        for(int i = 0; i < n; i++) {
        	par[i] = i;
        	num[i] = 1;
        }
    }

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

    void unite(int x, int y) {
        int rx = root(x); 
        int ry = root(y);
        if (rx == ry) return; 
        
        par[rx] = ry;
        num[ry] += num[rx];
    }

    boolean same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    long getNum(int n) {
    	return num[root(n)];
    }
};

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		UnionFind uf = new UnionFind(n);

		int[] a = new int[m];
		int[] b = new int[m];
		for(int i=0; i<m; i++) {
			a[m-i-1] = sc.nextInt()-1;
			b[m-i-1] = sc.nextInt()-1;
		}
		
		long[] ans = new long[m];
		ans[0] = (long)n*((long)n-1)/2;
		
		for(int i=0; i<m-1; i++) {
			if(uf.same(a[i], b[i])) ans[i+1] = ans[i];
			else {
				long ac = uf.getNum(a[i]);
				long bc = uf.getNum(b[i]);
				ans[i+1] = ans[i] - ac * bc;
				uf.unite(a[i], b[i]);
			}
		}

		for(int i=0; i<m; i++) {
			out.println(ans[m-i-1]); 
		}
	}

}


Measured memory_bytes: 94252
#include<bits/stdc++.h>
#define INF            1e9
#define REP(i,n)       for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)      for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n)  for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPR(i,n)      for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)     for(lint i=(n);i>0;--i)
#define REPRI(i,ini,n) for(lint i=(ini)-1,i##_len=(n);i>=i##_len;--i)
#define REPC(i,obj)    for(auto i:obj)
#define R_UP(a,b)      (((a)+(b)-1)/(b))
#define ALL(obj)       (obj).begin(),(obj).end()
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
int binary_search_p(int first_w, int last_w, int k, int max_w, const vector<int>&w)
{
	auto get_minimum_k = [&w](int p_candidate)
	{
		int result = 1;
		int temp = 0;
		REPC(i, w)
		{
			if (temp + i <= p_candidate)temp += i;
			else
			{
				result++;
				temp = i;
			}
		}
		return result;
	};
	int p_candidate = first_w + (last_w - first_w) / 2;
	int min_k = get_minimum_k(p_candidate);
	if (first_w > last_w)
	{
		int result;
		for (int i = max(p_candidate, max_w);; i++)
		{
			int minimum_k = get_minimum_k(i);
			if (minimum_k <= k)return i;
		}
	}
	return min_k <= k ? binary_search_p(first_w, p_candidate - 1, k, max_w, w) : binary_search_p(p_candidate + 1, last_w, k, max_w, w);
}
signed main()
{
	int n = in(), k = in();
	vector<int>w(n);
	int min_w = 10001, max_w = -1, sum_w = 0;
	REPC(&i, w)
	{
		i = in();
		if (min_w > i)min_w = i;
		if (max_w < i)max_w = i;
		sum_w += i;
	}
	cout << binary_search_p(min_w, sum_w, k, max_w, w) << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=998244353;
ll mod_pow(ll x, ll n, ll mod=MOD){
    if (n==0) return 1;
    ll res=mod_pow(x*x%mod, n/2, mod);
    if (n%2==1) res=res*x%mod;
    return res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<ll> d(n,0), x(n,0);
    rep(i,0,n) cin>>d[i];
    if(d[0]!=0){
        cout <<0<<"\n";
        return 0;
    }
    sor(d);
    rep(i,0,n){
        x[d[i]]++;
    }
    bool t=true;
    rep(i,1,d[n-1]+1){
        if(x[i]==0) t=false;
    }
    ll ans=1;
    if(d[0]!=0){
        cout <<0<<"\n";
        return 0;
    }
    if(n==1){
        cout <<1<<"\n";
        return 0;
    }
    if(d[1]!=1){
        cout <<0<<"\n";
        return 0;
    }
    if(!t){
        cout <<0<<"\n";
        return 0;
    }
    rep(i,0,d[n-1]){
        ans=ans*mod_pow(x[i],x[i+1])%MOD;
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))

dic = {}
for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1
#print(dic)
dic = sorted(dic.items(), key=lambda x:x[0])
dic.reverse()
#print(dic)
ans = 0
cnt = 0
for i in range(len(dic)):
    if dic[i][1] >= 4 and cnt == 0:
        ans = dic[i][0] ** 2
        break
    elif dic[i][1] >= 2:
        if cnt == 0:
            ans = dic[i][0]
            cnt += 1
        else:
            ans = ans * dic[i][0]
            break
print(ans)

Measured memory_bytes: 21772
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=new int[n][];
		for(int i = 0;i<n;i++) {
			var e=sc.Ia;
			a[i]=new int[2];
			a[i][0]=e[0]-e[1];
			a[i][1]=e[0]+e[1];
		}
		Array.Sort(a,(u,v)=>u[1]-v[1]);
		int d=a[0][1];
		int ans=0;
		for(int i = 1;i<n;i++) {
			if(d>a[i][0]){ans++;}
			else{
				d=a[i][1];
			}
		}
		Console.WriteLine("{0}",n-ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 23872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

const ll mod = 1e6+7;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
    // cin >> tt;
    while((tt)--){
        ll n; cin >> n;
        vll v(n);
        rep(i,n){
            cin >> v[i];
        }
        ll mx = 100000000000;
        repA(i,1,n*n){
            // ll p=v[i];
            ll ans=0;
            rep(j,n){
                // cout << v[j]
                ans +=(v[j]-i)*(v[j]-i);
                // cout << ans << endl;
            }
            // cout << ans << endl;
            mx = min(mx, ans);
        }
        cout << mx << endl;
    }
}



Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main(String...args) {
		Scanner scan = new Scanner(System.in);

		while(true) {
		double heikin = 0;
		double powM = 0;
		int howM = 0;
			if((howM = scan.nextInt()) == 0 ) {
				break;
			}
			int mem = 0;
			for(int i = 0; i < howM ; i++) {
				mem = scan.nextInt();
				heikin += mem;
				powM  +=Math.pow(mem , 2);
			}
			heikin /= howM;
		    powM  /=howM;
           Double powH = Math.pow(heikin,2);
			//System.out.println(heikin  + " " + powM);
			System.out.println(Math.sqrt(powM - powH));
		}
	}
}


Measured memory_bytes: 31044
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
typedef long long ll;
ll N;
priority_queue<ll> pq;
priority_queue<ll,vector<ll>,greater<ll> > mp;

int main(){
    cin >> N;
    vector<ll> a(N*3);
    for(int i=0;i<N*3;i++){
        cin>> a[i];
    }
    vector<ll> R(N*2+1,0);
    vector<ll> L(N*2+1,0);
    for(int i=0;i<N;i++){
        L[i+1] = L[i] + a[i];
        mp.push(a[i]);
    }
    for(int i=N;i<2*N;i++){
        ll mi = mp.top();
        if(a[i]>mi){
            L[i+1] = L[i]+a[i]-mi;
            mp.push(a[i]);
            mp.pop();
        }else{
            L[i+1] = L[i];
        }
    }
    
    for(int i=0;i<N;i++){
        R[i+1] = R[i]+a[3*N-1-i];
        pq.push(a[3*N-i-1]);
    }
    for(int i=N;i<N*2;i++){
        ll ma = pq.top();
        if(a[N*3-1-i]<ma){
            R[i+1] = R[i]-ma+a[N*3-1-i];
            pq.pop();
            pq.push(a[3*N-1-i]);
        }else{
            R[i+1] = R[i];
        }
    }
    ll ans = -(1LL<<60);
    for(int i=N;i<=N*2;i++){
        ans = max(ans,L[i]-R[3*N-i]);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 8052
main :: IO ()
main = do
  l1 <- getLine
  let [a, b, h, m] = map (fromIntegral . read) $ words l1 :: [Double]
      w1 = (60*h + m)/(12*60) * 2*pi
      w2 = m/60 * 2*pi
      p1 = (a*sin w1, a*cos w1)
      p2 = (b*sin w2, b*cos w2)
  print $ d p1 p2

d (x1, y1) (x2, y2) = sqrt $ (x2 - x1)**2 + (y2 - y1)**2


Measured memory_bytes: 4524
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
#include<stack>

using namespace std;

#define INF 999999999
#define REP(i,n) for(int i=0; i<(int)(n); i++)

int main(){
	int i, j;
	long long int p, t, q, l, r;
	char c;
	//??? ans;
	cin >> q;
	r = 0;
	l = 0;
	REP(i,q){
		cin >> p >> c >> t;
		if(c=='(') l+=t;
		else r+=t;
		if(l==r)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
n, q = gets.split(' ').map(&:to_i)
t = 0
queue = []
(0...n).each { |n|
  queue << gets.split(' ')
}
while process = queue.shift
  pt = process[1].to_i
  if pt <= q
    t += pt
    puts "#{process[0]} #{t}"
  else
    t += q
    process[1] = pt - q
    queue << process
  end
end

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll score(ll a, ll b, ll c) {
	return max(a, max(b, c)) - min(a, min(b, c));
}
ll calc(ll W, ll H) {
	ll best = 1LL * W * H;
	for (int i = 1; i < W; ++i) {
		best = min(best, score(i * H, (W - i) / 2 * H, (W - i - (W - i)/2) * H));
		best = min(best, score(i * H, (W - i) * (H / 2), (W - i) * (H - (H / 2))));
	}
	return best;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int H, W; cin >> H >> W;
	print(min(calc(W, H), calc(H, W)));
}

Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int a, b, t;

void init()
{
}

void solve()
{
    cout << (t / a) * b << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> t;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <map>

class uftree{
  std::vector<int> parent;
  std::vector<int> rank;
  std::vector<int> ufsize;
  public:
  uftree(int n) : parent(n), rank(n), ufsize(n, 1) {
    for(int i = 0; i < n; i++){
      parent[i] = i;
    }
  }
  int root(int x){
    std::vector<int> update_node_arr;
    while(parent[x] != x){
      update_node_arr.push_back(x);
      x = parent[x];
    }
    for(const auto& it: update_node_arr) parent[it] = x;
    return x;
  }

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

  int size(int x){
    return ufsize[root(x)];
  }

  void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x==y) return;
    int xsize = size(x);
    int ysize = size(y);
    if(rank[x]<rank[y]){
      parent[x] = y;
      ufsize[y] += xsize;
    }else{
      parent[y] = x;
      ufsize[x] += ysize;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
};


int main(){
  int N,K,L;
  std::cin >> N >> K >> L;

  uftree uf1(N), uf2(N);
  for(int i = 0; i < K; i++){
    int p,q;
    std::cin >> p >> q;
    p--;q--;
    uf1.unite(p,q);
  }
  for(int i = 0; i < L; i++){
    int p,q;
    std::cin >> p >> q;
    p--;q--;
    uf2.unite(p,q);
  }
  std::map<std::tuple<int, int>, long long> con_map;
  for(int i = 0; i < N; i++){
    con_map[std::make_tuple(uf1.root(i), uf2.root(i))] += 1;
  }

  for(int i = 0; i < N; i++){
    std::cout << con_map[std::make_tuple(uf1.root(i), uf2.root(i))] << (i==N-1?"\n":" ");
  }

  return 0;
}



Measured memory_bytes: 16640
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define clr clear()
#define ins insert
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define cusmem(x,val) for(auto &i:x) i=val;
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);\
            cin.tie(NULL);\
            cout.tie(NULL);
using namespace std;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int>pli;
typedef vector<ll> vl;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpii;
string impossible;

mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
// const int N=6;
const int N=4e5+5;
const int L=41;
int MOD=1e9+7;
ll n,m,k,i,j;
bool f0,f1,f2;
const int MAXN=2e3;
int main(){
    #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin); 
            freopen("output.txt","w",stdout);
    #endif
    fastio
    cout<<fixed<<setprecision(11);
    int tests=1;    
    // cin>>tests;
    for(int te=1;te<=tests;te++){
        string n;   cin>>n;
        int sum=0;
        for(int i=0;i<n.size();i++){
            int dig=n[i]-'0';
            sum+=dig;
            sum%=9;
        }
        if(sum) cout<<"No\n";
        else    cout<<"Yes\n";

    }
    return 0;
}





Measured memory_bytes: 3740
S = list(input())

# input
n1 = 753
l1=[0]*(len(S)-2)

for a1 in range(len(S)-2):
  l1[a1]=abs(n1-(int(S[a1])*100+int(S[a1+1])*10+int(S[a1+2])))

print(min(l1))

Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int N,S[3030]; long long D[3030][3030];

int main()
{
	scanf ("%d",&N);
	for (int i=0;i<N;i++) scanf ("%d",&S[i]), D[i][i] = S[i];
	for (int l=1;l<N;l++){
		for (int i=0,j=l;j<N;i++,j++){
			D[i][j] = S[i] - D[i+1][j];
			if (D[i][j] < S[j] - D[i][j-1])
				D[i][j] = S[j] - D[i][j-1];
		}
	}
	printf ("%lld\n",D[0][N-1]);

	return 0;
}

Measured memory_bytes: 71808
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B;
    cin >> A >>B;
    // if(A==12)
    // 	cout << 1<<endl;
    // else
    // 	cout << A+1<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;

    if(A%2==1 && B%2==1)
    	puts("Yes");
    else
    	puts("No");
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int tot = a[n-1];
    rep(i,n-1) {
        tot ^= a[i];
    }
    rep(i,n) {
        int tmp = tot;
        int ans = tmp^a[i];
        cout << ans << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  FOR(i, 1, n + 1) {
    ll c = n / i;
    ans += i * c * (c + 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef pair<ll, int> ll_i;

int main() {
    ll n, dig;
    cin >> n;
    ll N = n;
    ll sum = 0;

    while(n){
        dig = n % 10;
        sum = sum + dig;
        n = n / 10;
    }
    if (N % sum == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <cstring>
#include <cmath>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  inputInt3(N,K,Q);
  inputIntArray(a,Q);
  long point[N+1] = {0};
  
  //main
  fN(i,Q) point[a[i]-1]++;//1人目の添え字は0。
  fN(i,N) {
    if(point[i] > Q-K){ cout << "Yes" << endl;}
    else { cout << "No" << endl;}
  }
  
  // output
    
  return 0;
}

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

struct ball{
	char name[11];
  	int n;
};

int main(){
	ball S,T;
  	char u[11];
  	cin >> S.name >> T.name;
  	cin >> S.n >> T.n;
  	cin >> u;
  	if((std::string)u==(std::string)S.name){
    	S.n--;
    }else{
    	T.n--;
    }
	cout << S.n <<" "<< T.n;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

ll lcm(ll a,ll b){
    if(a==b) return a;
    return a / __gcd(a,b) * b;
}

int main(){
    int N;
    cin >> N;
    ll ans = 1;
    rep(i,N){
        ll T;
        cin >> T;
        ans = lcm(ans,T);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    s64 x, y;
    cin >> x >> y;

    s64 ans = 0;
    while (x * ((s64)1 << ans) <= y) ++ans;

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n, w, v, ww;
  LL w0;
  cin>>n>>w;
  vector<vector<int> > vs(4);
  cin>>w0>>v;
  vs[0].push_back(v);

  REP(i, n-1){
    cin>>ww>>v;
    ww-=w0;
    vs[ww].push_back(v);
  }
  REP(i, 4) {
    sort(vs[i].begin(), vs[i].end(), greater<int>());
    FOR(j, 1, vs[i].size()){
      vs[i][j]+=vs[i][j-1];
    }
  }

  int ans=0, work;
  LL x;
  REP(i, vs[3].size()+1){
    REP(j, vs[2].size()+1){
      REP(k, vs[1].size()+1){
        work=0;
        if(i>0) work+=vs[3][i-1];
        if(j>0) work+=vs[2][j-1];
        if(k>0) work+=vs[1][k-1];
        x=w-(w0+3)*i-(w0+2)*j-(w0+1)*k;
        if(x<0) continue;
        x=x/w0;

        if(x>=vs[0].size()) x=vs[0].size();
        if(x>0) work+=vs[0][x-1];
        //cout<<x<<" "<<work<<endl;
        ans=max(ans, work);
      }
    }
  }
  ECHO(ans);
  return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : dpl_1a.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main() {
	int n, m, d[20], dp[50001];
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> d[i];
	}
	memset(dp,-1,sizeof(dp));
	dp[0] = 0;
	for(int i = 0;i <= n;i++){
		for(int j = 0;j < m;j++){
			if(i + d[j] <= n && (dp[i + d[j]] == -1 || dp[i + d[j]] > dp[i] + 1)){
				dp[i + d[j]] = dp[i] + 1;
			}
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1364
#include <cstdio>
#include <iterator>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int MAXN = 123456;
const LL INF = (LL)1e15;
LL a[3 * MAXN], l[3 * MAXN], r[3 * MAXN];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < 3 * N; i++) {
        scanf("%lld", &a[i]);
        l[i] = -INF;
        r[i] = INF;
    }
    r[3 * N] = INF;
    priority_queue<LL, vector<LL>, greater<LL>> pq;
    LL sum = 0;
    for (int i = 0; i < 3 * N; i++) {
        if ((int)pq.size() < N) {
           pq.push(a[i]);
           sum += a[i];
           if ((int)pq.size() == N) l[i] = sum;
           continue;
        }
        l[i] = sum - pq.top() + a[i];
        if (pq.top() < a[i]) {
           sum = sum - pq.top() + a[i];
           pq.pop();
           pq.push(a[i]);
        }
    }
    sum = 0;
    priority_queue<LL> pq2;
    for (int i = 3 * N - 1; i >= 0; i--) {
        if ((int)pq2.size() < N) {
           sum += a[i];
           pq2.push(a[i]);
           if ((int)pq2.size() == N) r[i] = sum;
           continue;
        }
        if (pq2.top() > a[i]) {
           sum = sum - pq2.top() + a[i];
           pq2.pop();
           pq2.push(a[i]);
        }
        r[i] = sum;
    }
    LL ans = -INF;
    for (int i = 0; i < 3 * N; i++) {
        ans = max(ans, l[i] - r[i + 1]);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 10740
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    llong mod = 1000000007;

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

    int main()
    {
    int n;
    cin>>n;
    llong ans=1;
    for(int i=1; i<=n; i++)
    {
        ans=(ans*i)%mod;
    }
    cout<<ans<<endl;
    }

Measured memory_bytes: 256
p $<.to_a[1].split.map(&:to_i).each_slice(2).to_a.transpose
.map{|a|a.group_by{|x|x}.map{|k,v|[k,v.size]}.sort_by{|x|-x[1]}}
.map{|a|[a[0][0]] + [a[1]&.slice(0)] + [a.flat_map{|(x,c)|[x] * c}]}
.transpose
.tap{|a|break a[0].uniq.size == 2 ?
  a[2][0].count{|x|x != a[0][0]} + a[2][1].count{|x|x != a[0][1]}:
  [
    a[2][0].count{|x|x != a[1][0]} + a[2][1].count{|x|x != a[0][1]},
    a[2][0].count{|x|x != a[0][0]} + a[2][1].count{|x|x != a[1][1]}
  ].min
}


Measured memory_bytes: 36472
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, k := io.NextInt(), io.NextInt()
	n %= k
	if k-n < n {
		n = k - n
	}
	io.Println(n)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define N 207
using namespace std;
bool a[N];

int main(){
    int x, n;
    cin >> x >> n;
    for (int i = 0; i < n; i ++){
        int t;
        cin >> t;
        a[t + 100] = true;
    }
    int o = 0;
    while (a[min(x + o + 100, N)] && a[max(x - o + 100, 0)]){
        o++;
    }
    if (!a[x - o + 100]){
        cout << x - o;
        return 0;
    }
    if (!a[x + o + 100]){
        cout << x + o;
        return 0;
    }
}


Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long i64;

const int MAX_N = 100005;

int N, M, A[MAX_N], P[MAX_N];
int res[MAX_N], temp[MAX_N];
i64 K, X[MAX_N], D[MAX_N];

void fpm(i64 x) {
  for (int i = 1; i <= N; ++i) res[i] = i;
  while (x) {
    if (x & 1) {
      for (int i = 1; i <= N; ++i)
	//temp[i] = P[res[i]];
	temp[i] = res[P[i]];
      for (int i = 1; i <= N; ++i)
	res[i] = temp[i];
    }
    for (int i = 1; i <= N; ++i) temp[i] = P[P[i]];
    for (int i = 1; i <= N; ++i) P[i] = temp[i];
    x >>= 1;
  }
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i)
    scanf("%lld", &X[i]), D[i] = X[i] - X[i - 1];
  
  for (int i = 1; i <= N; ++i)
    P[i] = i;
  
  scanf("%d%lld", &M, &K);
  for (int i = 1; i <= M; ++i)
    scanf("%d", &A[i]);
  
  for (int i = M; i; --i) {
    swap(P[A[i]], P[A[i] + 1]);
  }

  fpm(K);
  
  for (int i = 1; i <= N; ++i)
    temp[res[i]] = D[i];
  
  for (int i = 2; i <= N; ++i)
    X[i] = X[i - 1] + temp[i];
  
  for (int i = 1; i <= N; ++i)
    printf("%lld.0\n", X[i]);
  
  return 0;
}


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

int main()
{
	int input_n;
	int input_score_a[1000];
	int min_sa = 1000000, score_a_sa = 0;
	int counter_i, counter_j;
	
	for( ; ; )
	{
		scanf("%d", &input_n);
		if(input_n == 0)
			break;
		
		for(counter_i = 0 ; counter_i < input_n ; counter_i++)
			scanf("%d", &input_score_a[counter_i]);
		
		for(counter_i = 0 ; counter_i < input_n ; counter_i++)
		{
			for(counter_j = counter_i + 1 ; counter_j < input_n ; counter_j++)
			{
				score_a_sa = abs(input_score_a[counter_i] - input_score_a[counter_j]);
				if(min_sa > score_a_sa)
					min_sa = score_a_sa;
			}
		}
		
		printf("%d\n", min_sa);
		
		min_sa = 1000000;
	}
	return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <cstring>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
const int MAX_V=300;
//2部マッチング
int V;//頂点数
VE G[MAX_V];//グラフ隣接リスト表現
int match[MAX_V];//マッチングのペア
bool used[MAX_V];//フラグ
//
void add_edge(int from,int to){
  G[from].PB(to);
  G[to].PB(from);
}
//増加パスを探す
bool DFS(int v){
  used[v]=true;
  FOR(i,0,(int)G[v].size()){
    int u=G[v][i],w=match[u];
    if(w<0||!used[w]&&DFS(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}
//最大マッチング
int bipartite_matching(){
  int res=0;
  memset(match,-1,sizeof(match));
  FOR(v,0,V){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(DFS(v)){
        res++;
      }
    }
  }
  return res;
}
//
int main(){
  int N;
  pair<int,int> R[100],B[100];
  cin>>N;
  FOR(i,0,N){
    cin>>R[i].FI>>R[i].SE;
  }
  FOR(i,0,N){
    cin>>B[i].FI>>B[i].SE;
  }
  V=N*2;
  FOR(i,0,N){
    FOR(j,0,N){
      if(B[i].FI>=R[j].FI&&B[i].SE>=R[j].SE){
        add_edge(i,j+N);
      }
    }
  }
  cout<<bipartite_matching()<<endl;
  return 0;
}


Measured memory_bytes: 256
# Peaks
N, M = map(int, input().split())
H = list(map(int, input().split()))
Good = [True] * N

for _ in range(M):
    n1, n2 = map(int, input().split())

    n1 = n1 - 1
    n2 = n2 - 1

    if H[n1] == H[n2]:
        Good[n1] = False
        Good[n2] = False
    elif H[n1] < H[n2]:
        Good[n1] = False
    else:
        Good[n2] = False

print(Good.count(True))

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

int ans(int N,int Y){
  int x=0,y=0,z=0;
  for (int x=0;x<=N;x++){
    for (int y=0;y<=N-x;y++){
      if (Y==10000*x+5000*y+(N-x-y)*1000){
        cout<<x<<" "<<y<<" "<<N-x-y<<endl;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;
  return 0;
}

int main(){
  int N,Y;
  cin >>N>>Y;
  ans(N,Y);
}

Measured memory_bytes: 256
#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(){
    int n;
    cin >> n;
    vector <int> p(n);
    rep(i,n){
        cin >> p[i];
    }

    int ans=0;
    rep(i,n-2){
        if(p[i]<p[i+1] and p[i+1]<p[i+2] or p[i]>p[i+1] and p[i+1]>p[i+2]){
            ++ans;
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
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...));
}

int main() {
    int n;
    cin>>n;
    vector<pair<int,int>> vec(n);
    vector<int> L(n),R(n);
    int ans=0;
    rep(i,n) {
        int l,r;
        cin>>l>>r;
        l--;
        vec[i]={l,r};
        L[i]=l;
        R[i]=r;
        ans=max(ans,r-l);
    }
    sort(all(vec));
    
    {
        priority_queue<int,vector<int>,greater<int>> q;
        rep(i,n) {
            q.push(vec[i].second);
        }
        map<int,int> mp;
        
        int left1=-1,right1=2*INF;
        int left2=vec[n-1].first,right2=q.top();
        
        rep(i,n-1) {
            mp[vec[i].second]++;
            while(mp[q.top()]>0) {
                mp[q.top()]--;
                q.pop();
            }
            
            left1=vec[i].first;
            right1=min(right1,vec[i].second);
            right2=q.top();
            
            int now=max(0,right1-left1)+max(0,right2-left2);
            ans=max(ans,now);
        }
    }
    
    rep(i,n) swap(vec[i].first,vec[i].second);
    sort(all(vec));
    rep(i,n) swap(vec[i].first,vec[i].second);
    
    {
        priority_queue<int> q;
        rep(i,n) {
            q.push(vec[i].first);
        }
        map<int,int> mp;
        
        int left1=-1,right1=vec[0].second;
        int left2=q.top(),right2=vec[0].second;
        
        rep(i,n-1) {
            mp[vec[i].first]++;
            while(mp[q.top()]>0) {
                mp[q.top()]--;
                q.pop();
            }
            
            left1=max(left1,vec[i].first);
            left2=q.top();
            right2=vec[i+1].second;
            
            int now=max(0,right1-left1)+max(0,right2-left2);
            ans=max(ans,now);
            //cout<<left1<<" "<<right1<<endl;
            //cout<<left2<<" "<<right2<<endl;
        }
    }
    
    {
        sort(all(L),greater<int>());
        sort(all(R));
        int maxleft=L[0],nextleft=L[1],minright=R[0],nextright=R[1];
        rep(i,n) {
            int now=vec[i].second-vec[i].first;
            int left=(vec[i].first==maxleft ? nextleft : maxleft);
            int right=(vec[i].second==minright ? nextright : minright);
            now+=max(0,right-left);
            ans=max(now,ans);
        }
    }
    
   cout<<ans<<endl;
    
}


Measured memory_bytes: 6948
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int a,b,c,d,e,i,j,l=0,k;
cin>>a;
vector<int>v;
for(i=1;i<=a;i++)
{
 cin>>b;v.push_back(b);
}
map<int,int>m;
for(i=0;i<a;i++)
{
if(v[i]<400)
{
 m[1]=1;
}
else if(v[i]<800)
{m[2]=1;}
else if(v[i]<1200)
{m[3]=1;}

else if(v[i]<1600)
{m[4]=1;}
else if(v[i]<2000)
{m[5]=1;}
else if(v[i]<2400)
{m[6]=1;}
else if(v[i]<2800)
{m[7]=1;}
else if(v[i]<3200)
{m[8]=1;}
else
m[9]++;

}


for(i=1;i<=8;i++)
{
if(m[i]==1)l++;
}

k=l+m[9];
if(l==0)l=1;

cout<<l<<" "<<k<<endl;
}

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

using namespace std;

const int N=510;

int w,h,mp[N][N];

void Init()
{
	scanf("%d%d",&w,&h);
	for (int i=0;i<w;++i)
		for (int j=0;j<h;++j)
		{
			char ch=getchar();
			while (ch!='#' && ch!='.') ch=getchar();
			if (ch=='#') mp[i][j]=1;else mp[i][j]=0;
		}
}

void Solve()
{
	for (int i=0;i<w;++i)
	{
		for (int j=0;j<h;++j)
			if (i!=0 && (mp[i][j] || j&1 || i==w-1)) putchar('#');
			else putchar('.');
		putchar('\n');
	}
	putchar('\n');
	
	for (int i=0;i<w;++i)
	{
		for (int j=0;j<h;++j)
			if (i!=w-1 && (mp[i][j] || !(j&1) || i==0)) putchar('#');
			else putchar('.');
		putchar('\n');
	}
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main() {
        string s;
        cin >> s;
        vector<int> a;
        for (int i = 0; i < 4; i ++) {
                a.push_back(s[i] - '0');
        }
        for (int i = 0; i < 2; i ++) {
                for (int j = 0; j < 2; j ++) {
                        for (int k = 0; k < 2; k ++) {
                                int res = a[0];
                                res += i ? a[1] : -a[1];
                                res += j ? a[2] : -a[2];
                                res += k ? a[3] : -a[3];
                                if (res == 7) {
                                        cout << a[0] << (i ? '+' : '-') << a[1] << (j ? '+' : '-') << a[2] << (k ? '+' : '-') << a[3] << '=' << 7;
                                        return 0;
                                }
                        }
                }
        }
        return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef pair<int,int>P;
main(){
    int n,a;
    cin>>n;
    priority_queue<P,vector<P>,greater<P> >p;
    r(i,n){
        cin>>a;
        p.push(P(a,i));
    }
    long long sum=0;
    set<int>st;
    r(i,n){
        P A=p.top();p.pop();
        int x=A.second;
        long long LA,RA;
        int y=A.first;
        st.insert(x);
        auto it=st.find(x);
        if(it==st.begin()) LA=x+1;
        else{
            it--;
            LA=x-(*it);
            it++;
        }
        auto IT=st.end();IT--;
        if(it==IT) RA=n-x;
        else{
            it++;
            RA=(*it)-x;
            it--;
        }
        //cout<<LA<<' '<<RA<<' '<<x<<endl;
        sum+=LA*RA*y;
        //sum%=1000000007;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 13676