akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long L;
  scanf("%lld", &L);

  ll total = 0;
  int min_apple = I_INF;
  rep(i, 0, N) {
    total += L + i;
    if (abs(min_apple) > abs(L + i)) {
      min_apple = L + i;
    }
  }

  put(total - min_apple);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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


Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    int n,m,x,tmp;
    cin >> n >> m >> x;
    int a[n+1]={};
    for(int i=0;i<m;i++){
      cin >> tmp;
      a[tmp] = 1;
    }
    int up=n-x,upcount=0,down=x,downcount=0;
    for(int i=x+1;i<n+1;i++){
      if(a[i]==1)
        upcount++;
    }
    for(int i=x-1;i>-1;i--){
      if(a[i]==1)
        downcount++;
    }
    if(upcount>downcount)
      cout << downcount << "\n";
    else
      cout << upcount << "\n";
    return 0;
}


Measured memory_bytes: 256
ABC = list(map(int,input().split()))

count = 0
for i in ABC:
    if(i == ABC[0]):
        count += 1
    if(i == ABC[1]):
        count += 1
    if(i == ABC[2]):
        count += 1

count = count - 3
if(count == 2):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long int minn=9223372036854775807,n,sum;
std::vector<int> a;
int main(){
  cin >> n;
  a.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int l = -100; l <= 100; l++) {
    for (int i = 0; i < n; i++) {
      sum += pow(a[i]-l,2);
    }
    minn = min(minn,sum);
    sum = 0;
  }
  cout << minn;
}


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

int main(){
  int N;
  cin >> N;
  vector<float> v(N);
  for(int i=0; i < N; i++){
    cin >> v.at(i);
  }
  
  sort(v.begin(), v.end());
  
  float a;
  a = (v.at(0) + v.at(1)) / 2;
  
  //cout << a << endl;
  
  for(int i=2; i<N; i++){
    a = (a + v.at(i)) / 2;
  }
  
  cout << a << endl;
}

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

int main() {
  string S;
  cin >> S;
  int flag = 0;
  int n = S.size();
  if(n%2 != 0){
    flag = 1;
  }
  else{
  for(int i=0;i<n;i++){
    if(i%2 == 0){
      if(S.at(i)!='h'){
        flag = 1;
        break;
      }
    }
     else{
      if(S.at(i)!='i'){
        flag = 1;
        break;
      }
    }
  }
  }
  if(flag == 0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
}
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y,a,b;

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

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

using namespace std;
#define ll long long
#define mod 1000000007

vector<int> g[100001];
ll dp[1000][1000];
int h, w;
char a[1000][1000];

ll f(ll i, ll j) {
    if (i == h - 1 && j == w - 1) return 1;

    if (dp[i][j] != -1) return dp[i][j];

    ll ans = 0;
    if (i + 1 < h && a[i + 1][j] == '.') {
        ans += f(i + 1, j);
    }

    if (j + 1 < w && a[i][j + 1] == '.') {
        ans += f(i, j + 1);
    }

    ans %= mod;
    dp[i][j] = ans;
    return ans;
}

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

    memset(dp, -1, sizeof(dp));
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++) {
            a[i][j] = s[j];
        }
    }
    cout << f(0, 0) << "\n";
}


Measured memory_bytes: 14884
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

vector<int> sort(vector<int> &v){
  int l = v.size();
  int i = 0;
  while(i != l-1){
    for(int j = l-1;j > i;j--)if(v[j-1] > v[j])swap(v[j],v[j-1]);
    i++;
  }
  return v;
}

int main(){
   int N,K;
   cin >> N >> K;
   vector<int> p(N);
   rep(i,N)cin >> p[i];
   sort(p);
   int ans = 0;
   rep(i,K){
     ans += p[i];
   }
   cout << ans <<endl;

}


Measured memory_bytes: 3592
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		int n = parseInt(sc.next());
		int[] p = new int[n];
		for (i = 0; i < n; i++) {
			p[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.parallelSort(p);
		int ans=0;
		for (i = 0; i <= 100; i++) {
			if(Arrays.binarySearch(p, x-i)<0) {
				ans=x-i;
				break;
			} else if(Arrays.binarySearch(p, x+i)<0) {
				ans=x+i;
				break;
			}
		}
		out.println(ans);
	}
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    vector<int> A(N);
    rep(i,N)cin>>A.at(i);
    sort(begin(A),end(A));
    cout<<A.at(N-1)-A.at(0)<<endl;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
miss = 0
clear = 0
for s in range(min(n, y//10000) + 1):
	if clear == 1:
		break
	else:
		for t in range(min(n-s, (y-10000*s)//5000) + 1):
		    money = 10000*s + 5000*t
		    if y - money == (n-s-t)*1000:
			    print(str(s)+" "+str(t)+" "+str(n-s-t))
			    miss = 1
			    clear = 1
if miss == 0:
	print("-1 -1 -1")

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

#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = INF + 7;

/////////////////////////////////////////////////////////////////////

const int N = 1e2 + 10;

int a[N], b[N];

int main() {

   	sync;

	int n, sum = 0; cin >> n;
	for(int i = 1; i < n; i++) cin >> b[i];
	b[0] = b[n] = INF;
	for(int i = 1; i <= n; i++) sum += min(b[i], b[i - 1]);
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
using System;

class MainClass {
  public static void Main (string[] args) {
    //入力
    var input = Console.ReadLine().Split(' ');
    var N = long.Parse(input[0]);
    var M = long.Parse(input[1]);
    var ans = (long)0;
    if(N * 2 <= M){
      ans = N;
      //作成作業
      ans += (M - N * 2) / 4;
    }else{
      ans = M / 2;
    }
    //出力
    Console.WriteLine(ans);
  }
}

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

#define cnd(c, a, b) (c ? a : b);
#define fl(x,y,z) for(int x=y;x<z;x++)
#define fe(x,y,z) for(int x=y;x<=z;x++)
#define fge(x,y,z) for(int x=y;x>=z;x--)

#define debug(x) std::cerr << #x << " --> " << x << "\n";
#define fastIO std::ios_base::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define pb push_back
#define pob pop_back
 
#define ln '\n'

typedef long long int ll;

void solve() {
	ll h, w, m;
	ll x,y;
	cin >> h>>w >> m;
	vector<int> rc, cc;
	vector<int> vrm, vcm;
	unordered_map<ll, ll> mp;
	fl(i,0,h) {
		rc.pb(0);
	}
	fl(i,0,w) {
		cc.pb(0);
	}

	fl(i,0,m) {
		cin>>x>>y;
		mp[(x-1)*w+(y-1)]=1;
		// cout<<"IND: "<<(x-1)*w+(y-1)<<ln;
		rc[x-1]++;
		cc[y-1]++;
	}

	ll rmax, cmax;
	fl(i,0,h) {
		if(i==0) {
			rmax = rc[i];
			vrm.pb(i);
			x = i;
		} else {
			if(rmax<rc[i]) {
				vrm.clear();
				vrm.pb(i);
				rmax = rc[i];
				x = i;
			} else if(rmax==rc[i]) {
				vrm.pb(i);
			}
		}
	}

	fl(i,0,w) {
		if(i==0) {
			cmax = cc[i];
			vcm.pb(i);
			y = i;
		} else {
			if(cmax<cc[i]) {
				cmax = cc[i];
				vcm.clear();
				vcm.pb(i);
				y = i;
			} else if(cmax==cc[i]) {
				vcm.pb(i);
			}
		}		
	}

	// fl(i,0,vrm.size()) {
	// 	cout<<vrm[i]<<" ";
	// }
	// cout<<ln;

	// fl(i,0,vcm.size()) {
	// 	cout<<vcm[i]<<" ";
	// }
	// cout<<ln;
	// cout<<rmax<<" "<<cmax<<ln;

	ll ans = 0;
	fl(i,0,vrm.size()) {
		fl(j,0,vcm.size()) {
			if(mp[vrm[i]*w + vcm[j]]==1) {
				ans = cmax + rmax - 1;
			} else {
				ans = cmax+rmax;
				break;
			}
		}
		if(ans==(cmax+rmax)) {
			break;
		}
	}
	cout<<ans<<ln;
	return;
}

int main() {
    fastIO
    int t = 1;
    // cin >> t;
    fl(i,0,t) {
    	// cout << "Case #"<< i+1 <<": ";
    	solve();
    }
    return 0;
}

Measured memory_bytes: 23272
#include <iostream>
using namespace std;
  
int main(){
    int cost[22][22]={0};
    int n,m,i,j,k,a,b,c,d;
    char cc;
    cin>>n>>m;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            cost[i][j] = 1<<28;
        }
    }
    for(i=0;i<m;i++){
        cin>>a>>cc>>b>>cc>>c>>cc>>d;
        cost[a][b]=c;cost[b][a]=d;
    }
    for(k=1;k<=n;k++){
      for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
    cin>>a>>cc>>b>>cc>>c>>cc>>d;
    }
    cout << c-d-cost[a][b]-cost[b][a] << endl;
}

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

const int maxn = 1e5 + 10;
int t[maxn], x[maxn], y[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    for (int i = 1; i <= n; ++i) cin >> t[i] >> x[i] >> y[i];
    for (int i = 1; i <= n; ++i) {
        int dis = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        if (dis > t[i] - t[i - 1]) return cout << "No" << endl, 0;
        if ((t[i] - t[i - 1] - dis) % 2 == 1) return cout << "No" << endl, 0;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1408
program main
  implicit none
  character(4) S
  integer i,j,ans,x
  !read(*, *) (L(i), i = 1,N)
  read(*, *) S
  ans = 1
  do i = 1,4
    x = 0
    do j = 1,4
      if(S(i:i) == S(j:j)) then
        x = x + 1
      end if
      
    end do
    if(x /= 2) then
      ans = 0
    end if
  end do
        
  if (ans == 0) then
    write(*, *) 'No'
  else
    write(*, *) 'Yes'
  end if
end program main


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

using namespace std;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int numM = 0;
	long long sum = 0;
	int min = INT_MAX;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		sum += abs(a);
		if (a < 0) {
			numM++;
		}
		min = std::min(min, abs(a));
	}
	if (numM % 2 == 0) {
		cout << sum << endl;
	}
	else {
		cout << sum - 2 * min << endl;
	}

	return 0;
}

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

int main(){
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  int x[N];
  int y[M];
  int xmax;
  int ymin;
  for (int i=0;i<N;i++){
    cin >>x[i];
    xmax=i==0?x[i]:max(xmax,x[i]);
  }
  for (int i=0;i<M;i++){
    cin >>y[i];
    ymin=i==0?y[i]:min(ymin,y[i]);
  }
  if (xmax<ymin and ymin>X and xmax<Y){
    cout << "No ";
  }
  cout << "War" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) {
                res.push_back(n / i);
            }
        }
    }

    return res;
}
int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    ll sum = 0;
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }

    vector<ll> res = divisor(sum);
    ll ans = 0;
    rep(i, res.size()) {
        vector<ll> mod;
        rep(j, N) {
            if (A[j] % res[i]) mod.push_back(A[j] % res[i]);
        }
        sort(all(mod));
        repd(j, 1, mod.size()) {
            mod[j] += mod[j - 1];
        }
        bool flag = false;
        ll len = (ll)mod.size();
        rep(j, mod.size()) {
            // cout << res[i] << " " << mod[j] << ":" << j  << " " << res[i] * (len - j - 1) - (mod[len - 1] - mod[j]) << endl;
            if ((mod[j] == (res[i] * (len - j - 1) - (mod[len - 1] - mod[j]))) && mod[j] <= K) {
                flag = true;
                break;
            }
        }
        if (flag || len == 0) {
            chmax(ans, res[i]);
        }
    }

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Cake[] cakes = new Cake[n];
		for (int i = 0; i < n; i++) {
		    cakes[i] = new Cake(sc.nextLong(), sc.nextLong(), sc.nextLong());
		}
		long max = 0;
		for (int i = 0; i < 4; i++) {
    		Cake.type = i;
    		Arrays.sort(cakes);
    		max = Math.max(max, getMax(cakes, m, true));
    		max = Math.max(max, getMax(cakes, m, false));
		}
	    System.out.println(max);
   }
   
   static long getMax(Cake[] cakes, int size, boolean order) {
       long beauty = 0;
       long populaur = 0;
       long taste = 0;
       for (int i = 0; i < size; i++) {
           Cake c;
           if (order) {
               c = cakes[i];
           } else {
               c = cakes[cakes.length - i - 1];
           }
           beauty += c.beauty;
           populaur += c.populaur;
           taste += c.taste;
       }
       return Math.abs(beauty) + Math.abs(populaur) + Math.abs(taste);
   }
   
   static class Cake implements Comparable<Cake> {
       static int[][] types = new int[][] {{1, 1, 1}, {-1, 1, 1}, {1, -1, 1}, {1, 1, -1}};
       static int type = 0;
       
       long beauty;
       long taste;
       long populaur;
       
       public Cake(long beauty, long taste, long populaur) {
           this.beauty = beauty;
           this.taste = taste;
           this.populaur = populaur;
       }
       
       public int compareTo(Cake another) {
           long a = beauty * types[type][0] + taste * types[type][1] + populaur * types[type][2];
           long b = another.beauty * types[type][0] + another.taste * types[type][1] + another.populaur * types[type][2];
           if (a < b) {
               return -1;
           } else if (a == b) {
               return 0;
           } else {
               return 1;
           }
       }
   }
}




Measured memory_bytes: 27896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    ll n,ans=0;cin>>n;

    for(int i=1;i <= n;i++)
    {
        ll cnt=0,x=i;
        while(x>0){
            x/=10;
            cnt++;
        }
        if(cnt%2==1)ans++;

    }

    cout<<ans<<endl;


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/




int main() {
    int n;

    cin >> n;
    vector<int> a(n);

    rep(i, n) cin >> a[i];
    ll ans = 0;
    
    rep(i, n) {
        ans += a[i] - 1;
    }

    cout << ans << endl;
    return 0;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cctype>
#include <stack>
#include <bitset>
#include <unordered_set>
#include <map>
#include <set>
#include <cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long lolo;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ulolo;

const int maxn = (int)2e5 + 5;
const lolo maxx = (lolo)10000001;
const int maxm =(int)2e3 + 5;
const int INF = 0x3f3f3f3f;
const lolo inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int MOD = (int)1e6 + 3;

template<class T>
inline void read(T &x) {
    x = 0; T flag = 1;char c;
    do { c = (char) getchar(); if (c == '-') break; } while (c < '0' || c > '9');
    if (c == '-') { c = '0', flag = -1;}
    do { x = x * 10 + c - '0';c = (char) getchar();} while (c >= '0' && c <= '9');
    x *= flag;
}
template<class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    x = x % 10;
    putchar('0' + x);
}

char S[maxn], T[maxn];
int dist[4];
int main() {
//    freopen("../in.txt", "r", stdin);
    int H, W;
    read(H);read(W);
    int n;
    read(n);
    int sr, sc;
    read(sr);read(sc);
    dist[0] = sc;
    dist[1] = sr;
    dist[2] = W-sc+1;
    dist[3] = H-sr+1;
    scanf("%s%s", S, T);
    bool ans = true;
    for (int i = 0; i < n; ++i) {
        if (S[i]=='U') {
            if (--dist[1]<=0) {
                ans = false;
                break;
            }
        } else if (S[i]=='D') {
            if (--dist[3]<=0) {
                ans = false;
                break;
            }
        } else if (S[i]=='L') {
            if (--dist[0]<=0) {
                ans = false;
                break;
            }
        } else if (S[i]=='R') {
            if (--dist[2]<=0) {
                ans = false;
                break;
            }
        }
        if (T[i]=='U') {
            if (dist[3]<H) {
                ++dist[3];
            }
        } else if (T[i]=='D') {
            if (dist[1]<H) {
                ++dist[1];
            }
        } else if (T[i]=='L') {
            if (dist[2]<W) {
                ++dist[2];
            }
        } else if (T[i]=='R') {
            if (dist[0]<W) {
                ++dist[0];
            }
        }
    }
    puts(ans?"YES":"NO");
    return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  int k,x; cin>>k>>x;
  set<int> s;
  for (int i=0; i<k; i++) {
    s.insert(x-i); s.insert(x+i); s.insert(x);
  }
  for (int i: s) cout<<i<<" ";
  cout<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<long double> count(N);
    for (int i = 1; i <= N; ++i) {

        int counter = 0;
        int initial = i;

        do {
            if (initial >= K) {
                break;
            }

            ++counter;
            initial *= 2;
        } while (true);


        long double calc = 1;
        for (int j = 0; j < counter; ++j) {
            calc = calc * 0.50000000000000;
        }

        // cout << counter << endl;
        count[i - 1] = calc;
    }

    long double sum = 0;
    for (int i = 0; i < count.size(); ++i) {
        sum += count[i];
    }

    cout << setprecision(100) << sum / N << endl;

    return 0;
}

Measured memory_bytes: 1792
import itertools as ite
import math
import random

INF = 10 ** 18
MOD = 10 ** 9 + 7

dx_ = [-1, 1, 0, 0]
dy_ = [0, 0, -1, 1]

m = {"L" : 0, "R" : 1, "D" : 2, "U" : 3}

N = input()
ls = []
ts = [0]

x1 = x2 = x3 = y1 = y2 = y3 = -INF

for loop in range(N):
    x, y, d = raw_input().split()
    x, y = int(x), int(y)
    d = m[d]
    ls += [(x, y, d)]
    if d == 0:
        x1 = max(x1, x)
        y2 = max(y2, y)
    if d == 1:
        x3 = max(x3, x)
        y2 = max(y2, y)
    if d == 2:
        x2 = max(x2, x)
        y1 = max(y1, y)
    if d == 3:
        x2 = max(x2, x)
        y3 = max(y3, y)
ts += [x1 - x2, x2 - x3, (x1 - x3) / 2.0]
ts += [y1 - y2, y2 - y3, (y1 - y3) / 2.0]

x1 = x2 = x3 = y1 = y2 = y3 = -INF

for x, y, d in ls:
    x, y = -x, -y
    d = d / 2 * 2 + (d % 2 == 0)
    if d == 0:
        x1 = max(x1, x)
        y2 = max(y2, y)
    if d == 1:
        x3 = max(x3, x)
        y2 = max(y2, y)
    if d == 2:
        x2 = max(x2, x)
        y1 = max(y1, y)
    if d == 3:
        x2 = max(x2, x)
        y3 = max(y3, y)
ts += [x1 - x2, x2 - x3, (x1 - x3) / 2.0]
ts += [y1 - y2, y2 - y3, (y1 - y3) / 2.0]

ans = INF

for t in ts:
    if t < 0 or t > 10 ** 10:
        continue
    x1 = y1 = INF
    x2 = y2 = -INF
    for x, y, d in ls:
        dx, dy = dx_[d], dy_[d]
        X = x + dx * t
        Y = y + dy * t
        x1 = min(x1, X)
        x2 = max(x2, X)
        y1 = min(y1, Y)
        y2 = max(y2, Y)
    ans = min(ans, (x2 - x1) * (y2 - y1))
print "%.12f" % ans


Measured memory_bytes: 45980
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl h(n);
  rep(i,n){
    cin >> h[i];
  }
  ll cnt=0;
  ll H=0;
  rep(i,n){
    if(H<=h[i]){
      cnt++;
      H=h[i];
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std ;
int A[110] ;
bool cmp( int a , int b ) { return a > b ; }
int main(){
    int N ;
    scanf( "%d" , &N ) ;
    int a , b ;
    a = b = 0 ;
    for( int i = 1 ; i <= N ; i++ )
        scanf( "%d" , &A[i] ) ;
    sort( A + 1 , A + 1 + N , cmp ) ;
    for( int i = 1 ; i <= N ; i++ ){
        if ( i & 1 ) a += A[i] ;
        else b += A[i] ;
    }
    cout << a - b << endl ;
    return 0 ;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace cp
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var max = 0L;
            for (int i = 0; i < n; i++)
            {
                if (max - 1 > array[i])
                {
                    Console.WriteLine("No");
                    return;
                }
                max = array[i] > max ? array[i] : max;
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 29404
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace kyopro
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nk = Console.ReadLine().Split(' ');
            int n = int.Parse(nk[0]);
            int k = int.Parse(nk[1]);
            int tokuten = 0;
            double aaa = 1;
            double bbb = 0;
            for(int i = 1;i <= n; i++)
            {
                aaa = 1;
                tokuten = i;
                aaa = aaa / n;
                while(tokuten < k)
                {
                    tokuten = tokuten * 2;
                    aaa = aaa / 2;
                }
                bbb = bbb + aaa;
            }
            Console.WriteLine(bbb);
        }
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


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

    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    rep(i, M) cin >> A[i];

    int to_s = 0, to_e = 0;

    int i = 0;
    while(true){
        if(A[i] < X){
            to_s++;
        }else{
            break;
        }
        i++;
    }
    while(true){
        if(i >= M) break;
        if(A[i] > X){
            to_e++;
        }
        i++;
    }
    cout << min(to_s, to_e) << endl;
    return 0;
}


// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    string s; cin >> s;
    vector<int> cnt((int)s.size(), 0); // Eを向いている人のカウント
    cnt[0] = (s[0] == 'E') ? 1 : 0;
    rep1(i, s.size()-1) {
        int tmp = (s[i] == 'E') ? 1 : 0;
        cnt[i] += cnt[i-1] + tmp;
    }
    int ans = INF;
    // rep(i, n) cout << cnt[i] << endl;
    rep(i, s.size()) {
        // cout << i << " " << i+1-cnt[i]-(int)(s[i]=='W') << " " << cnt[n-1]-cnt[i] << endl;
        int tmp = (i+1-cnt[i]-(int)(s[i]=='W'))+(cnt[n-1]-cnt[i]);
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1812
l, r = map(int, input().split())
result = 10 ** 9
if r-l == 1:
  result = (l*r) % 2019
else:
  r = min(r, l + 2019)
  for i in range(l, r+1):
    for j in range(l, r+1):
      if i < j:
        result = min(result, (i*j)%2019)
        
print(result)

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

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

    int n, m;
    cin >> n >> m;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<vector<int64_t>> s(3, vector<int64_t>(m + 2));
    for (int i = 1; i < n; i++) {
        int d = a[i] - a[i - 1];

        if (d > 0) {
            s[1][1] += d;
            s[1][m + 1] -= d;
            s[2][a[i - 1] + 2] += -1;
            s[2][a[i] + 1] -= -1;
            s[1][a[i] + 1] -= -1 * (d - 1);

        } else {
            d += m;

            s[1][1] += a[i];
            s[1][a[i] + 1] -= a[i];
            s[2][2] += -1;
            s[2][a[i] + 1] -= -1;
            s[1][a[i] + 1] -= -1 * (a[i] - 1);

            s[1][a[i] + 1] += d;
            s[1][m + 1] -= d;
            if (a[i - 1] <= m - 2) {
                s[2][a[i - 1] + 2] += -1;
                s[2][m + 1] -= -1;
                s[1][m + 1] -= -1 * (m - a[i - 1] - 1);
            }
        }
    }

    for (int k = 1; k >= 0; k--) {
        int64_t c = 0;
        for (int j = 1; j <= m + 1; j++) {
            s[k][j] += (c += s[k + 1][j]);
        }
    }

    if (s[0][m + 1] != 0) throw;

    cout << *min_element(&s[0][1], &s[0][m + 1]) << endl;

    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define inf 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0;i < n;i++) {
    string si;
    cin >> si;
    sort(si.begin(), si.end());
    s[i] = si;
  }
  unordered_map<string, int> anag;
  ll ans = 0;
  for (int i = 0;i < n;i++) {
    string si = s[i];
    auto itr = anag.find(si);
    if (itr != anag.end()) {
      ans += anag[si];
      anag[si]++;
    }
    else anag[si] = 1;
  }
  cout << ans << endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);


inline LL in() { LL in; scanf("%lld", &in); return in; }
inline void outLL(LL out, bool endl = 1) { printf("%lld%c", out, " \n"[endl]); }

template<typename M>
struct UnionFind {
	using t = typename M::t;
	vector<int> data;
	vector<t>Mdata;
	UnionFind(int n) { data.assign(n, -1); Mdata.assign(n, M::id()); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			Mdata[x] = M::op(Mdata[x], Mdata[y]);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	t query(int x) { return Mdata[root(x)]; }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
	void add(int x, const t val) { x = root(x); Mdata[x] = M::op(Mdata[x], val); }
	void update(int x, const t val) { x = root(x); Mdata[x] = M::upd(Mdata[x], val); }
};
int main() {
	LL N = in(), M = in();
	VL x(N);
	FOR(i, 0, N) {
		x[i] = in();
	}
	using tp = tuple<LL, LL, LL>;
	vector<tp>edges(M);
	FOR(i, 0, M) {
		int a = in() - 1, b = in() - 1, c = in();
		edges[i] = tp(c, a, b);
	}

	struct info {
		using t = struct node {
			LL xsum, edgecnt;
			node(LL a = 0, LL b = 0) :xsum(a), edgecnt(b) {}
		};
		static t op(const t& a, const t& b) {
			return { a.xsum + b.xsum, a.edgecnt + b.edgecnt };
		}
		static t upd(const t& a, const t& b) {
			return b;
		}
		static t id() { return node(); }
	};
	UnionFind<info> uf(N);
	FOR(i, 0, N) {
		uf.update(i, info::node(x[i], 0));
	}
	SORT(edges);
	LL ans = M;
	for (auto edge : edges) {
		LL c, a, b; tie(c, a, b) = edge;
		uf.unionSet(a, b);
		auto vinfo = uf.query(a);
		vinfo.edgecnt += 1;
		uf.update(a, vinfo);
		if (vinfo.xsum >= c) {
			ans -= vinfo.edgecnt;
			vinfo.edgecnt = 0;
			uf.update(a, vinfo);
		}
	}
	cout << ans << "\n";
}

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

signed main(void)
{
	int x;
	cin >> x;
	if (x)
		cout << 0 << endl;
	else
		cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

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

    int h = x / 3600;
    int m = (x % 3600) / 60;
    int s = x % 60;

    cout << h << ":" << m << ":" << s << endl;
}



Measured memory_bytes: 3124
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)

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

void Main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, 3) if(s[i] == t[i]) ans++;
  cout << ans << endl;
}

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String line;
		int[] num = new int[3];
		num[0] = 1;
		while ((line = reader.readLine()) != null) {
			if (line.isEmpty())
				break;
			if (line.equals("A,B") || line.equals("B,A")) {
				int t = num[0];
				num[0] = num[1];
				num[1] = t;
			} else if (line.equals("A,C") || line.equals("C,A")) {
				int t = num[0];
				num[0] = num[2];
				num[2] = t;
			} else if (line.equals("B,C") || line.equals("C,B")) {
				int t = num[1];
				num[1] = num[2];
				num[2] = t;
			}
		}
		int result = 0;
		for (int i = 0; i < 3; i++) {
			if (num[i] == 1) {
				result = i;
			}
		}
		System.out.println(result == 0 ? "A" : result == 1 ? "B" : "C");
	}
}

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

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

char s[20][2000];
int main(){
	int h,w,K;cin>>h>>w>>K;
	rep(i,h)scanf("%s",s[i]);
	int Min=INT_MAX;
	rep(i,1<<(h-1)){
		vector<int>v{0,h};
		rep(j,h-1){
			if(i>>j&1)v.push_back(j+1);
		}
		sort(v.begin(),v.end());
		int cnt=0;
		int d[15]{};
		rep(k,w){
			bool flag=false;
			rep(j,v.size()-1){
				for(int t=v[j];t<v[j+1];t++){
					d[j]+=s[t][k]-'0';
				}
				if(d[j]>K){
					flag=true;
				}
			}
			if(flag){
				memset(d,0,sizeof(d));
				flag=false;cnt++;
				rep(j,v.size()-1){
					for(int t=v[j];t<v[j+1];t++){
						d[j]+=s[t][k]-'0';
					}
					if(d[j]>K){
						flag=true;
					}
				}
				if(flag)goto g;
			}
		}
		Min=min(Min,__builtin_popcount(i)+cnt);
		g:;
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 n;
  cin >> n;
  vector<string> q(n);
  rep(i,0,n) cin >> q[i];
  i64 cnt = 0;
  rep(i,0,n) {
    if(q[i] == "A") {
      cnt++;
    }
    else {
      cnt--;
    }
    if(cnt < 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if(cnt != 0) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
}



Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>

using namespace std;

void solve() {
    long long h, w, t;
    cin >> h >> w;

    long long ans, minans = 1e5, maxsq, minsq;
    for (int j=0; j<2; ++j) {
        for (long long i=1; i < h; ++i) {
            maxsq = max(w*i, max((h-i)*(w/2), (h-i)*(w/2) + (h-i)*(w&1)));
            minsq = min(w*i, min((h-i)*(w/2), (h-i)*(w/2) + (h-i)*(w&1)));
            ans = maxsq - minsq;
            //cout << maxsq << " " << minsq <<endl;
            if (ans < minans)
                minans = ans;
        }

        for (long long i=1; i < h; ++i) {
            maxsq = max(w*i, max(((h-i)/2)*w, ((h-i)/2)*w + w*((h-i)&1)));
            minsq = min(w*i, min(((h-i)/2)*w, ((h-i)/2)*w + w*((h-i)&1)));
            ans = maxsq - minsq;
            //cout << maxsq << " " << minsq <<endl;
            if (ans < minans)
                minans = ans;
        }
        t = w;
        w = h;
        h = t;
    }

    cout << minans;

}

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


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

int main(void){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  cout << A[N - 1] - A[0];
  return 0;
}

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


using namespace std;

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

int n;

ll score(vector<int> & p) {
	ll score = 0;
	rep(i, n - 1) {
		score += abs(p[i] - p[i + 1]);
	}
	return score;
}

void dump(vector<int> & p) {
	cout << "----" << endl;

	rep(i, n) {
		cout << p[i] << " ";
	}
	cout << endl;
}

int main() {

	cin >> n;

	ll a[n];
	rep(i, n) {
		cin >> a[i];
	}
	sort(&a[0], &a[n]);

	ll total = 0;



	if (n % 2 == 0) {
		vector<int> ans;
		for (int i = 0; i < n / 2; i++) {
			ans.push_back(a[n / 2 - i - 1]);
			ans.push_back(a[n - i - 1]);
		}
		cout << score(ans) << endl;
	} else {
		vector<int> ans0;
		for (int i = 0; i < n / 2; i++) {
			ans0.push_back(a[n / 2 - i - 1]);
			ans0.push_back(a[n / 2 + 1 + i]);

		}
		//dump(ans0);
		ans0.push_back(a[n / 2]);

		vector<int> ans1;
		for (int i = 0; i < n / 2; i++) {
			ans1.push_back(a[n / 2 + 1 + i]);
			ans1.push_back(a[n / 2 - i - 1]);
		}
		ans1.push_back(a[n / 2]);
		//dump(ans1);

		cout << max(score(ans0), score(ans1)) << endl;
	}
	

	return 0;
}

Measured memory_bytes: 2168
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,a[101],m,s=0;
	scanf("%d",&n);
	for(register int i=1;i<=n;++i){
	    scanf("%d",&a[i]);
	    s+=a[i];
	}
	scanf("%d",&m);
	while(m--){
		int x,y;
		scanf("%d%d",&x,&y);
		printf("%d\n",s+y-a[x]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N, D; cin >> N >> D;
    vector<int> d(N); for (auto &i : d) cin >> i;
    vector<int> A(N), B(N);
    A[0] = D;
    for (int i = 1; i < N; i++) {
        A[i] = min(A[i-1], abs(A[i-1] - d[i-1]));
    }
    B[N-1] = 1;
    for (int i = N-2; i >= 0; i--) {
        if (B[i+1] <= d[i+1] / 2) B[i] = B[i+1];
        else B[i] = B[i+1] + d[i+1];
    }
    int Q; cin >> Q;
    for (int i = 0; i < Q; i++) {
        int q; cin >> q; q--;
        cout << (A[q] >= B[q] ? "YES" : "NO") << '\n';
    }
    return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
#define V(i) vector<i>
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define crep(i,N,n) for (__typeof(n) i = N; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define P(i,j) pair<i,j>
#define MP make_pair
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define MOD 1000000007
typedef long long ll;
typedef long l;
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
int main()
{
    fio;
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    clock_t z = clock();
    ll n; double d;
    cin>>n>>d;
    ll cc =0;
    while(n--)
    {
        double x,y;
        cin>>x>>y;
        if(sqrt(x*x + y*y) <= d)
        {
            cc++;
        }
    } 
    cout<<cc;
    debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 3864
let () = 
    let rec f _ = 
        let (h, w) = Scanf.sscanf(read_line()) "%d %d" (fun x y -> (x, y)) in
        if h = 0 && w = 0 then ()
        else (
            let outer = String.make w '#' in
            let inner = "#" ^ String.make (w - 2) '.' ^ "#" in
            Printf.printf "%s\n" outer;
            for _ = 2 to h - 1 do Printf.printf "%s\n" inner; done;
            Printf.printf "%s\n" outer;
            print_newline ();
            f ()
        )
    in f ();;


Measured memory_bytes: 2296
class DoublyLinkedList
  def initialize
    @ctl = Node.new
  end
  
  def solve
    n = gets.chomp.to_i

    n.times do
      case(cmd = gets.chomp)
      when "deleteFirst"
        deleteFirst
      when "deleteLast"
        deleteLast
      when /insert/
        insert(cmd.split(/ /)[1].to_i)
      else
        delete(cmd.split(/ /)[1].to_i)
      end
    end
    return show
  end

  def show
    s = []
    pt = @ctl.next
    while(pt != @ctl)
      s << pt.value
      pt = pt.next
    end
    return s.join(" ")
  end
  
  def insert(x)
    nd = Node.new(x)
    
    @ctl.next.prev = nd
    nd.next = @ctl.next
    @ctl.next = nd
    nd.prev = @ctl
  end
  
  def delete(x)
    pt = @ctl.next
    while(pt != @ctl)
      if (x == pt.value)
        deleteNode(pt)
        break
      else
        pt = pt.next
      end
    end
  end

  def deleteFirst
    deleteNode(@ctl.next)
  end

  def deleteLast
    deleteNode(@ctl.prev)
  end

  def deleteNode(n)
    n.prev.next = n.next
    n.next.prev = n.prev
    n.next = n
    n.prev = n
  end
end


class Node
  attr_accessor  :next, :prev, :value
  
  def initialize(x = nil)
    @next = self
    @prev = self
    @value = x
  end
end

if $0 == __FILE__
  puts DoublyLinkedList.new.solve
end

Measured memory_bytes: 307152
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define pint pair<int,int>
using namespace std;


int main() {
    int n; cin >> n;
    vector<pint> v(n);
    rep(i,n) cin >> v[i].first >> v[i].second;
    sort(ALL(v));
    vector<pint> save;
    save = v;
    int cnt = 0;
    REP(i,1,n) {
        if(v[i].first - v[i].second < v[i-1].first + v[i-1].second) {
            if(v[i-1].first+v[i-1].second<v[i].first+v[i].second) {
                v[i].first = v[i-1].first;
                v[i].second = v[i-1].second;
            }
            cnt++;
        }
    }
    cout << n-cnt << endl;

    return 0;
}

Measured memory_bytes: 1792
x=int(input())

if(x>=600):
    if(x>=800):
        if(x>=1000):
            if(x>=1200):
                if(x>=1400):
                    if(x>=1600): 
                        if(x>=1800): print('1')
                        else: print('2')
                    else: print('3')
                else: print('4')
            else: print('5')
        else: print('6')
    else: print('7')
else: print('8')
        

Measured memory_bytes: 9168
#define _CRT_SECURE_NO_WARNINGS
#define lp(i,n) for(int i=0;i<n;i++)
#include<bits/stdc++.h>


using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;

	return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  vector<int> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(ALL(a));
  cout<<a[2]*10+a[1]+a[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		String str[] = new String[8];
		for (int i = 0; i < 8; i++)
		{
			str[i] = sc.next();
		}
		for (int i = 0; i < 3; i++)
		{
			StringBuffer buf[] = new StringBuffer[8];
			for (int j = 0; j < 8; j++)
			{
				buf[j] = new StringBuffer(str[j]);
			}
			System.out.println(90 * (1 + i));
			for (int x = 0; x < 8; x++)
			{
				for (int y = 0; y < 8; y++)
				{
					char a = str[y].charAt(x);
					int u = -y + 7;
					int v = x;
					buf[v].setCharAt(u, a);
				}
			}
			for (int j = 0; j < 8; j++)
			{
				str[j] = buf[j].toString();
				System.out.println(str[j]);
			}
		}
	}
}

Measured memory_bytes: 12000