akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//n!
ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
}
 
// 繰り返し二乗法 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
 
//nCr O(r) nがでかくても安心
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    //a=n!/(n-r)!=n~n-r+1までの総積->O(r)
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    //b=inv(r!)
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
 
ll inv_mod(ll n){
    // フェルマーの小定理
    return pow_mod(n,mod-2);
}


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

    int n;cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    vector<pair<ll,int>> v;
    rep(i,n) v.push_back(make_pair(a[i],0));
    rep(i,n) v.push_back(make_pair(b[i],1));
    sort(ALL(v));
    ll rem0=0,rem1=0;
    ll ans=1;
    for(auto x:v){
        ll num=x.first;
        if(x.second==1){
            if(rem0>0){
                ans=(ans*rem0)%mod;
                rem0--;
            }
            else{
                rem1++;
            }
        }
        else{
            if(rem1>0){
                ans=(ans*rem1)%mod;
                rem1--;
            }
            else{
                rem0++;
            }

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


Measured memory_bytes: 7536
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', function (line) {
  var a = line.split(' ');
  var c = parseInt(a[0],10);
  var d = parseInt(a[1],10);
  if(c==d && c==0)
    process.exit();
  if(c>d)
    console.log(d+" "+c);
  else
    console.log(c+" "+d);
});
process.stdin.on('end', function () {
});


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    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;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {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;}

vvint g;
map<P,mint> memo;

// 0は黒 1は白
mint dfs(int v, int color, int p = -1) {
    if (memo.count(P(v,color))) return memo[P(v,color)];
    mint res = 1;
    if (color == 0) {
        for (int n_v : g[v]) {
            if (n_v == p) continue;
            res *= dfs(n_v,1,v);
        }
    }
    if (color == 1) {
        for (int n_v : g[v]) {
            if (n_v == p) continue;
            res *= dfs(n_v,0,v)+dfs(n_v,1,v);
        }
    }
    return memo[P(v,color)] = res;
}

int main() {
    int n; cin >> n;
    g.resize(n);
    rep(i,n-1) {
        int x, y; cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    cout << dfs(0,0) + dfs(0,1) << endl;
}

Measured memory_bytes: 29312
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

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; }
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int A1,B1,C1;
int main(void){
    cin >> A1 >> B1 >> C1;
    cout << max(0, C1 - A1 + B1) << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ECrestedIbisVsMonster solver = new ECrestedIbisVsMonster();
        solver.solve(1, in, out);
        out.close();
    }

    static class ECrestedIbisVsMonster {
        long mod = 1000000007;
        int MAXN = 200005;
        PrintWriter out;
        InputReader in;
        int h;
        int n;
        int[][] arr = new int[MAXN][2];
        int[] dp = new int[MAXN];

        int go(int health) {
            if (health <= 0)
                return 0;
            if (dp[health] != -1)
                return dp[health];
            int min = (int) mod;
            for (int i = 0; i < n; i++)
                min = Math.min(min, go(health - arr[i][0]) + arr[i][1]);
            return dp[health] = min;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            h = ni();
            n = ni();
            int i = 0;
            for (i = 0; i < n; i++) {
                arr[i][0] = ni();
                arr[i][1] = ni();
            }
            Arrays.fill(dp, -1);
            pn(go(h));
        }

        int ni() {
            return in.nextInt();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

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

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 29140
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define ld long double
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define deb(x) cout<<#x<<" "<<x<<el;
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n==1) return x;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                              //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

template<typename T>
T maxx(T a,T b)
{
  if(a<b) re b;
  re b;
}
template<typename T, typename... Args>
T maxx(T a,T b, Args... args)
{
    re(maxx(maxx(a,b),args...));
}

template<typename T>
T minn(T a,T b)
{
  if(a<b) re a;
  re b;
}
template<typename T, typename... Args>
T minn(T a,T b, Args... args)
{
    re(minn(minn(a,b),args...));
}

template<typename T>
void read(T& a)
{
  cin>>a;
}
template<typename T, typename... Args>
void read(T& a,Args&... args)
{
  cin>>a; read(args...);
}

template<typename T>
void write(T a)
{
  cout<<a<<' ';
}
template<typename T, typename... Args>
void write(T a,Args... args)
{
  cout<<a<<' '; write(args...);
}

inline ll min(ll a,ll b)
{
  if(a<b) re a;
  else re b;
}
inline ll max(ll a,ll b)
{
  if(a<b) re b;
  else re a;
}

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

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=((ans*((n-i)%N))%N*modInverse(i+1,N))%N;
  }
  re ans;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    ll n,m,k;
    string s;
    cin>>s;
    n=0;
    forup(i,s.L())
    {
      n+=s[i]-'0';
    }
    if(n%9) cout<<"No";
    else cout<<"Yes";

  }


  return 0;
}


Measured memory_bytes: 3788
main :: IO ()
main = do
  [a, b, k] <- map read . words <$> getLine
  print $ solve a b k

solve :: Int -> Int -> Int -> Int
solve a b k = filter (\n -> n `canDivide` a && n `canDivide` b) (reverse [1 .. min a b]) !! (k - 1)

canDivide :: Integral a => a -> a -> Bool
k `canDivide` n = mod n k == 0


Measured memory_bytes: 508
// ----------------------------------------------------------
#if 1
	#include <stdio.h>
	#include <set>
	#include <map>
	#include <unordered_map>
	#include <unordered_set>
	#include <list>
	#include <queue>
	#include <stack>
	#include <cmath>
	#include <ctime>
	#include <cstdio>
	#include <vector>
	#include <string>
	#include <bitset>
	#include <cctype>
	#include <cstdlib>
	#include <cstring>
	#include <utility>
	#include <numeric>
	#include <complex>
	#include <sstream>
	#include <fstream>
	#include <iomanip>
	#include <cassert>
	#include <iostream>
	#include <iterator>
	#include <algorithm>
	#include <functional>
#else
	#include <bits/stdc++.h>
#endif

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef long double LD;

const LL MOD = (LL)1000000007;
const LL LL_INF = (LL)1 << 62;
const int INT_INF = (int)1 << 30;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)
#define SWAP(x,y) 		((x!=y)&&(x^=y,y^=x,x^=y))



int main(int argc, char* argv[]) {

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

	LL n,wrk;
	LL ans = 0;
	map<LL,LL> a={};

	cin >> n;

	REP(i, n) {
		cin >> wrk;
		a[wrk]++;
	}


	for(const auto& wrk:a){
#if 0
		cout << wrk.first << ":" << wrk.second <<endl;
#endif
		ans++;
	}

	cout << ans <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,A,B;
  cin >> N >> A >> B;
  N = N-A;
  while(N>=B)
  {
    N -= B;
  }
  cout << N << endl;
  return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 1000000007
int main() {
	std::string a;
	std::cin >> a;
	for (auto &c : a) c -= '0';
	int n = a.size();
	int d = ri();
	int dp[n][d][2]; // 1 : strict
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i <= a[0]; i++) dp[0][i % d][i == a[0]]++;
	auto add = [&] (int &i, int &j) {
		i += j;
		if (i >= MOD) i -= MOD;
	};
	for (int i = 0; i + 1 < n; i++) {
		for (int j = 0; j < d; j++) {
			for (int k = 0; k <= a[i + 1]; k++) add(dp[i + 1][(j + k) % d][k == a[i + 1]], dp[i][j][1]);
			for (int k = 0; k < 10; k++) add(dp[i + 1][(j + k) % d][0], dp[i][j][0]);
		}
	}
	int res = dp[n - 1][0][0] + dp[n - 1][0][1] - 1;
	if (res >= MOD) res -= MOD;
	if (res < 0) res += MOD;
	std::cout << res << std::endl;
	return 0;
}


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

int main(){

	while(1){
		int n,i,human,sup,cns,output[7]={0};

		cin >> n;
		if(n==0) break;	

			for(i=0;i<n;i++){
				cin >> human;
				
				cns=10;
				for(sup=0;sup<=6;sup++){
					if(human<cns && human>=cns-10){
						output[sup]++;
					}
					
					if(human>60){
						output[6]++;
						break;
					}

					cns=cns+10;
				}
			}

			for(i=0;i<7;i++){
				cout << output[i] << endl;
			}
	}
	return 0;
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int n,x,a[N];
map<int,int>mp;
set<int>ss;
int main()
{//puts("Yes");return 0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&x),a[i]=x,ss.insert(x),mp[x]++;
	if(ss.size()==1)
	{
		if(a[1]==0)puts("Yes");
		else puts("No");return 0;
	}
	if(n%3!=0||ss.size()>3)
	{
		puts("No");return 0;
	}
	sort(a+1,a+n+1);
	int m=unique(a+1,a+n+1)-a-1;
	if(ss.size()==2)
	{
		if(a[1]&&a[2])return puts("No"),0;
		if(mp[a[1]]*2==mp[a[2]])puts("Yes");
		else puts("No");return 0;
	}
	if(mp[a[1]]==mp[a[2]]&&mp[a[2]]==mp[a[3]]&&(a[1]^a[2])==a[3])
	puts("Yes");else puts("No");
}


Measured memory_bytes: 7808
#include <iostream>
#include <climits>
#include <stack>
//#include <conio.h>

using namespace std;

int n = 0;
int input[100] = {};
bool done[102][10002]={};
int nowMax=0;

void Search(int num,int score);
void Record(int num);

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> input[i];
	}
	Search(0,0);
	cout << nowMax << endl;
	//getch();
	return 0;
}

void Search(int num,int score){
	if(num==n){
		Record(score);
		return;
	}
	if(done[num][score]==true){
		return;
	}
	done[num][score]=true;
	Search(num+1,score+input[num]);
	Search(num+1,score);
}

void Record(int num){
	if(num%10==0){
		return;
	}
	if(num>nowMax){
		nowMax=num;
	}
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

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

void solve() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll d = B - A;
  if (d % 2 == 0) {
    cout << d / 2 << endl;
  } else {
    cout << min((B - A + 1) / 2 + (A - 1), (B - A + 1) / 2 + (N - B)) << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int where[maxn], to[maxn], can[maxn], a[maxn], b[maxn];
int main(){
	where[0] = 1;
	int n, q; cin >> n >> q;
	for(int i = 1; i <= q; i++) cin >> a[i] >> b[i];
	for(int i = 1; i <= q; i++){
		where[i] = where[i - 1];
		if(where[i] == a[i] || where[i] == b[i])
			where[i] ^= a[i] ^ b[i];
	}
	for(int i = 1; i <= n; i++) to[i] = i;
	for(int i = q; i >= 0; i--){
		int w = where[i];
		if(w) can[to[w - 1]] = 1;
		if(w + 1 <= n) can[to[w + 1]] = 1;
		swap(to[a[i]], to[b[i]]);
	}
	can[where[q]] = 1;
	int s = 0;
	for(int i = 1; i <= n; i++) s += can[i];
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 1792
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int A, B;
    cin >> A >> B;
    
    cout << A * B << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

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

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};

ll mod_pow(ll x, ll n){
    ll res = 1;
    while(n>0){
        if(n & 1){
            res = res * x;
        }
            x = x * x;
            n >>= 1;
    }
    return res;
}
int main(){
  ll x;
  cin>>x;
  for(int a=0 ; a<=1000 ; a++){
    for(int b=-100 ; b<=1000 ; b++){
      if(mod_pow(a, 5)-mod_pow(b,5)==x){
        cout<<a<<" "<<b<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <limits>
#include <utility>
#include <algorithm>
#include <tuple>
#include <limits>

typedef long long ll;

int main(int argc, char *argv[])
{
    ll n;
    std::vector<ll> a;

    std::cin >> n;

    a.resize(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    ll sum = 0;
    ll max = a[0];
    for (int i = 1; i < n; i++) {
        if (a[i] < max) {
            const int step = max - a[i];
            sum += step;
        } else {
            max = a[i];
        }
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 4800
#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int main(){
  int N,M;
  int r;
  while(cin>>N>>M,N||M){
    cin>>r;
    int t,n,m,s;
      vector<PP> v(r);
    for(int i=0;i<r;i++){
      cin>>t>>n>>m>>s;
      v[i]=PP(P(t,n),P(m,s));
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
      int s,e,h,ans=0,cnt=0;
      cin>>s>>e>>h;
      int st;
      for(int j=0;j<r;j++){
	if(v[j].second.first==h){
	  if(v[j].second.second==1){
	    if(cnt==0){
	      st=v[j].first.first;
	      if(st<s){
		st=s;
	      }
	  
	    }
	    cnt++;
	  }else{
	    cnt--;
	    int end=v[j].first.first;
	    if(v[j].first.first>e){
	      end=e;
	    }
	    if(cnt==0){
	      ans+=max(end-st,0);
	    }

	  }
	}

      }
      cout<<ans<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1208
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
	int n, j, sum = 0, t[100], m, i, x[100], p[100], time[100];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &t[i]);
	}
	scanf("%d", &m);
	for (i = 0; i < m; i++) {
		scanf("%d%d", &p[i], &x[i]);
	}
	for (i = 0; i < n; i++) {
		sum += t[i];
	}
	for (j = 0; j < m; j++) {
		i = p[j]-1;
		time[i] = (x[j] - t[i]);
		time[i] += sum;
		printf("%d\n", time[i]);
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int N;
int cake[2000];
long long dp[2000][2000];
long long search(int, int);
int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> cake[i];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			dp[i][j] = -1;
		}
	}
	long long ans = cake[0] + search(N - 1, 1);
	for (int i = 1; i < N - 1; ++i) {
		ans = max(ans, cake[i] + search(i - 1, i + 1));
	}
	ans = max(ans, cake[N - 1] + search(N - 2, 0));
	cout << ans << endl;
	return 0;
}
long long search(int a, int b) {
	if (a == b)return 0;
	if (cake[a] > cake[b]) {
		a = a == 0 ? N - 1 : a - 1;
	}
	else {
		b = (b + 1) % N;
	}
	if (a == b)return cake[a];
	if (dp[a][b] != -1)return dp[a][b];
	long long res;
	res = cake[a] + search(a == 0 ? N - 1 : a - 1, b);
	res = max(res, cake[b] + search(a, (b + 1) % N));
	dp[a][b] = res;
	return res;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

const int MAXN = 100010;
const ll MOD = 1000000007;

ll p[MAXN];

int calc(int n, int m)
{
	if (n < m) swap(n, m);
	if (n == m)
		return p[n]*p[n]*2%MOD;
	if (n == m+1)
		return p[n]*p[m]%MOD;
	return 0;
}

int main()
{
	
	p[0] = 1;
	for (int i = 1; i <= 100000; ++ i)
		p[i] = p[i-1]*i%MOD;
	
	int n, m;
	scanf("%d%d", &n, &m);
	printf("%d\n", calc(n, m));
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
 
int main() {
  int H,N; cin >>H>>N;
  int ans=1;
  ans=H/N+1;
  if(H%N==0)ans=H/N;
  cout <<ans<<endl;
}

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

int main(){
    int n,x; cin >> n >> x;
    vector<int> a(n);
    for(int i = 0; i < n ; i++){
        cin >> a[i];
    }
    ll res = 0;
    if(a[0] > x){
        res += a[0]-x;
        a[0] = x;
    }
    for(int i = 0 ; i < n-1 ; i++){
        if(a[i]+a[i+1] > x){
           res += a[i]+a[i+1]-x;
           a[i+1] -= a[i]+a[i+1]-x;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String[] b = a.split("");
        Set<String> set = new TreeSet<>();
        for(int i = 0;i<a.length();i++){
            set.add(b[i]);
        }


        String answer = "";
        int flag = 0;
        String[] A = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
        for(int i = 0;i<A.length;i++){
            if(set.contains(A[i]) != true){
                answer = A[i];
                flag++;
                break;
            }
        }
        if(flag == 0){
            System.out.println("None");
        }else{
            System.out.println(answer);
        }
    }
}

Measured memory_bytes: 32696
use proconio::{input, fastout};
use std::cmp;

#[fastout]
fn main() {
    input!(
        n: usize,
        c: String,
    );

    let mut r2w = 0;
    let mut w2r = 0;

    for i in c.chars() {
        if i == 'R' { r2w += 1; }
    }

    let mut ans = cmp::max(r2w, w2r);
    let c: Vec<char> = c.chars().collect();

    for i in 0..n {
        if c[i] == 'R' { r2w -= 1; }
        else { w2r += 1; }
        ans = cmp::min(ans, cmp::max(r2w, w2r));
    }

    println!("{}", ans);
}

Measured memory_bytes: 3244
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */

    int p = sc.nextInt();
    int q = sc.nextInt();
    int r = sc.nextInt();
    
    os.println(p +  q + r - Math.max(Math.max(p, q), r));
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end() 
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

typedef long long ll;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	ll n,m;
	cin >> n >> m;
	ll a[n];
	int evecnt = -1;
	bool valid = true;
	rep(i,0,n){
		cin >> a[i];
		int x = a[i];
		int cnt = 0;
		while(x%2==0){
			x/=2;	
			++cnt;
		}
		if(evecnt == -1)evecnt = cnt;
		if(evecnt != cnt)valid = false;
	}
	if(!valid || evecnt == 0){
		cout << 0 << '\n';
		return 0;
	}
	ll lcm = 1;
	rep(i,0,n){
		a[i]/=(1<<evecnt);	
		lcm = 1LL * a[i] *lcm / __gcd(a[i], lcm);
	}
	m/=(1 << (evecnt-1));
	ll ans = m/lcm - m/(2*lcm);
	cout << ans << '\n';
}


Measured memory_bytes: 1024
#include <iostream>
int main()
{
    int A,B,C,D;
    std::cin>>A>>B>>C>>D;
    while(A>0 && C>0)
    {
        C=C-B;
        A=A-D;
    }
if(C<=0)
std::cout<<"Yes"<<std::endl;
else
{
    std::cout<<"No"<<std::endl;
}
}

Measured memory_bytes: 3636
from math import ceil
A, B = map(int, input().split())
res = 0
if B-A+1<=20:
    for a in range(A,B+1):
        res^=a
    print(res)
    exit()
for a in range(A,ceil(A/4)*4):
    res ^= a
for b in range((B//4)*4,B+1):
    res ^= b
print(res)

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(ww,n)cerr << v[ww] << ' ';cerr << endl << endl;}
#define SHOW2d(v,H,W) {REP(aaa,H){REP(bbb,W)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int dp[5555][5555];
bool ok[5555][5555];
int mp1[2][5555];
int mp2[2][5555];

int main(){
	
	string A,B;cin >> A >> B;
	A = "X" + A + "X";
	B = "X" + B + "X";
	
	int iti = A.size() - 1;
	int zero = A.size() - 1;
	
	for(int i = A.size() - 1;i >= 0;i--){
		mp1[0][i] = zero;
		mp1[1][i] = iti;
		if(A[i] == '0'){
			zero = i;
		}
		else if(A[i] == '1'){
			iti = i;
		}
	}
	
	iti = B.size() - 1;
	zero = B.size() - 1;
	
	for(int i = B.size() - 1;i >= 0;i--){
		mp2[0][i] = zero;
		mp2[1][i] = iti;
		if(B[i] == '0'){
			zero = i;
		}
		else if(B[i] == '1'){
			iti = i;
		}
	}

	
	REP(i,5555){
		REP(j,5555){
			dp[i][j] = INF;
		}
	}
	
	dp[0][0] = 0;
	
	REP(i,A.size()){
		REP(j,B.size())if(dp[i][j] != INF){
			dp[mp1[0][i]][mp2[0][j]] = min(dp[mp1[0][i]][mp2[0][j]],dp[i][j] + 1);
			dp[mp1[1][i]][mp2[1][j]] = min(dp[mp1[1][i]][mp2[1][j]],dp[i][j] + 1);
		}
	}

	
	ok[A.size() - 1][B.size() - 1] = true;
	for(int i = A.size() - 1;i >= 0;i--){
		for(int j = B.size() - 1;j >= 0;j--)if(dp[i][j] != INF){
			if(ok[mp1[0][i]][mp2[0][j]] && dp[mp1[0][i]][mp2[0][j]] >= dp[i][j] + 1){
				ok[i][j] = true;
			}
			if(ok[mp1[1][i]][mp2[1][j]] && dp[mp1[1][i]][mp2[1][j]] >= dp[i][j] + 1){
				ok[i][j] = true;
			}
		}
	}


	int ii = 0;
	int jj = 0;
	string str = "";
	while(!(ii == A.size() - 1 && jj == B.size() - 1)){
		if(ok[mp1[0][ii]][mp2[0][jj]] && dp[mp1[0][ii]][mp2[0][jj]] == dp[ii][jj] +1){
			str += "0";
			ii = mp1[0][ii];
			jj = mp2[0][jj];
		}
		else if(ok[mp1[1][ii]][mp2[1][jj]] && dp[mp1[1][ii]][mp2[1][jj]] == dp[ii][jj] + 1){
			str += "1";
			ii = mp1[1][ii];
			jj = mp2[1][jj];
		}
	}
	cout << str << endl;

	return 0;
}




Measured memory_bytes: 139656
# -*- coding: utf-8 -*-
import numpy as np
import math

def calculate_distance(in1, in2):
    list1 = np.array(in1) 
    list2 = np.array(in2) 
    sub_list = list1 - list2
    pow_list = np.power(sub_list, 2)
    sum_number = sum(pow_list)
    distance = math.sqrt(sum_number)

    return distance

[N, D] = [int(i) for i in input().split()]

X = []
for n in range(N):
    X.append([int(i) for i in input().split()])

number = 0
for n in range(N):
    for nn in range(n+1, N):
        distance = calculate_distance(X[n], X[nn])
        if distance.is_integer() is True:
            number += 1

print(number)


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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int N;
   cin >> N;
   vector<pair<int, int>> A(N);
   for (int i = 0; i < N; ++i) {
      cin >> A[i].first >> A[i].second;
      A[i].second = -A[i].second;
   }
   int ans = 0;
   sort(A.begin(), A.end());
   vector<pair<int, int>> B;
   vector<pair<int, int>> C;
   for (int i = 0; i < N; ++i) {
      A[i].second = -A[i].second;
      while (B.size() && B.back().second >= A[i].second) {
         C.emplace_back(B.back());
         B.pop_back();
      }
      B.emplace_back(A[i]);
   }
   for (int i = 0; i + 1 < B.size(); ++i) {
      int leftVal = max(0, B[0].second - B[i].first + 1);
      int rightVal = max(0, B[i + 1].second - B.back().first + 1);
      ans = max(ans, leftVal + rightVal);
   }
   int leftVal = max(0, B[0].second - B.back().first + 1);
   int rightVal = 0;
   for (auto p : C) {
      rightVal = max(rightVal, p.second - p.first + 1);
   }
   for (int i = 1; i + 1 < B.size(); ++i) {
      rightVal = max(rightVal, B[i].second - B[i].first + 1);
   }
   ans = max(ans, leftVal + rightVal);
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 2296
import java.util.*;

public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    ArrayList<String> al=new ArrayList();
    for(int i=0;i<N;i++)
      al.add(sc.next());
    int a=0,w=0,t=0,r=0;
    for(String S:al)
    {
      //System.out.println(S);
      if(S.equals("AC"))
        a++;
      else if(S.equals("WA"))
        w++;
      else if(S.equals("TLE"))
        t++;
      else
        r++;
    }
    System.out.println("AC x "+a);
    System.out.println("WA x "+w);
    System.out.println("TLE x "+t);
    System.out.println("RE x "+r);
  }
}

Measured memory_bytes: 64700
#include <iostream>

using namespace std;

int main() {
    int house[5][4][11],n;
    for (int i = 1; i <= 4 ; ++i) {
        for (int j = 1; j <= 3 ; ++j) {
            for (int k = 1; k <= 10; ++k) {
                house[i][j][k] = 0;
            }
        }
    }

    cin>>n;
    for (int i = 0; i <n ; ++i) {
        int b,f,r,v;
        cin>> b >>f >> r >> v;
        house[b][f][r] += v;
    }

    for (int f = 1; f<=4; f++){
        if (f > 1) cout << "####################" << endl;
        for (int b = 1; b <= 3; ++b) {
            for (int r = 1; r <= 10 ; ++r) {
                cout<<" "<<house[f][b][r];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
xyh.sort(key=lambda x: -x[2])
for cx in range(101):
  for cy in range(101):
    good = True
    h = xyh[0][2]+abs(cx-xyh[0][0])+abs(cy-xyh[0][1])
    for i in range(n):
      if xyh[i][2] != max(h-abs(cx-xyh[i][0])-abs(cy-xyh[i][1]), 0):
        good = False
        break
    if good:
      print(cx, cy, h)
      exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
long long func(int n,vector<long long> &memo){
    if(n==0)return 2;
    else if(n==1)return 1;
    if(memo[n]!=-1)return memo[n];
    return memo[n]=func(n-1,memo)+func(n-2,memo);

}
int main(){
    int n;
    cin>>n;
    vector<long long> memo(n+1,-1);

        cout<<func(n,memo)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
constexpr lint MOD = 1000000007;

vector<lint> fac, facInv, inv;

void facInit(int nmax)
{
    fac = facInv = inv = vector<lint>(nmax + 1, 1);
    for (int i = 2; i <= nmax; i++)
    {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        facInv[i] = facInv[i-1] * inv[i] % MOD;
    }
}

lint nCr(int n, int r)
{
    if (n<r || r<0) return 0;
    return (fac[n] * facInv[r] % MOD) * facInv[n-r] % MOD;
}

int N, K;
string s;

bool is_partition_able(vector<int> partition)
{
    int r_head = 0, b_head = 0;
    int pending = 0;
    for (auto c : s)
    {
        if (c == 'r')
        {
            if (r_head < partition.size()) r_head++;
            else pending = max(pending-1, 0);
        }
        else
        {
            if (r_head == b_head || partition[b_head] < 2) pending = max(pending-1, 0);
            else
            {
                pending += partition[b_head] - 2;
                b_head++;
            }
        }
    }
    if (pending > 0 || (b_head < partition.size() && partition[b_head] > 1) || r_head < partition.size()) return false;
    return true;
}


lint calc_for_each_partition(vector<int> &partition)
{
    if (!is_partition_able(partition)) return 0;

    int rd = 0;
    map<int, int> len_map;
    for (auto v : partition)
    {
        len_map[v]++;
        if (v > 1) rd += 2;
    }
    lint ans = nCr(N + 1 + rd, 2 * accumulate(partition.begin(), partition.end(), 0));
    for (auto v : len_map) (ans *= facInv[v.second]) %= MOD;
    (ans *= fac[partition.size()]) %= MOD;
    return ans;
}


lint dfs(vector<int> partition_now)
{
    lint ans = calc_for_each_partition(partition_now);
    int used_len = 0;
    for (auto v : partition_now) used_len += 1 + max(v*2-3, 1);
    // for (auto v : partition_now) used_len += v;
    int highest = partition_now.back();

    partition_now.push_back(0);

    if (partition_now.size() - 1 < K) for (int l=1; l<=min(highest, N-used_len); l++)
    {
        partition_now.back() = l;
        ans += dfs(partition_now);
    }
    return ans % MOD;
}


// r -> b -> (n個のrまたはb)で島を作る

int main()
{
    cin >> N >> K >> s;
    facInit(70*3);

    lint ans = 1;
    for (int i=1; i<=K; i++)
    {
        (ans += dfs(vector<int>{i})) %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long res = 1;
        long sup = pow10(18);
        long num;
        for(int i = 0; i < n; i++){
            num = sc.nextLong();
            if(res == 0){
            } else if(num == 0){
                res = 0;
            } else if(res == -1){
            } else if(sup / res >= num){
                res = res * num;
            } else{
                res = -1;
            }
        }
        System.out.println(res);
        sc.close();
    }
    static long pow10(int n){
        long c = 1;
        for(int i = 0; i < n; i++){
            c *= 10;
        }
        return c;
    }
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
#define ITER(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a,value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 111;

struct Point
{
	LL x, y;
	int ind;
	
	Point(int x, int y, int ind)
	{
		this->x = x;
		this->y = y;
		this->ind = ind;
	}
	
	Point(){}
	
	bool operator <(const Point& p) const
	{
		return MP(x, y) < MP(p.x, p.y);
	}
} A[MAX];

LL vd(Point a, Point b, Point c)
{
	LL x1 = a.x - b.x;
	LL y1 = a.y - b.y;
	
	LL x2 = c.x - b.x;
	LL y2 = c.y - b.y;
	
	return x1 * y2 - x2 * y1;
}

void rotate(LL& x, LL& y)
{
	swap(x, y);
	x = -x;
}

double RES[MAX];

int main()
{
//	freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);
	
	int n;
	scanf("%d", &n);
	FOR (i, 0, n)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		A[i] = Point(x, y, i);
	}
	
	sort(A, A+n);
	
	vector<Point> U, D;
	
	U.PB(A[0]);
	D.PB(A[0]);
	
	FOR (i, 1, n)
	{
		while(SZ(U) >= 2 && vd(U[SZ(U) - 2], U.back(), A[i]) <= 0) U.pop_back();
		while(SZ(D) >= 2 && vd(D[SZ(D) - 2], D.back(), A[i]) >= 0) D.pop_back();
		
		U.PB(A[i]);
		D.PB(A[i]);
	}
	
	RFOR(i, SZ(D) - 1, 1)
	{
		U.PB(D[i]);
	}
	
	int sz = SZ(U);
	
	U.PB(U[0]);
	U.PB(U[1]);
	
	vector<Point> P = U;
	
//	FOR (i, 0, SZ(U))
//	{
//		cout<<U[i].x<<' '<<U[i].y<<endl;
//	}
//	cout<<endl;
	
	FOR (i, 1, sz + 1)
	{
		LL x1 = P[i-1].x - P[i].x;
		LL y1 = P[i-1].y - P[i].y;
		
		LL x2 = P[i].x - P[i+1].x;
		LL y2 = P[i].y - P[i+1].y;
		
//		cout<<x1<<' '<<y1<<": "<<x2<<' '<<y2<<endl;
		
		rotate(x1, y1);
		rotate(x2, y2);

//		cout<<x1<<' '<<y1<<": "<<x2<<' '<<y2<<endl;
		
		double a1 = atan2((double)y1, (double)x1);
		double a2 = atan2((double)y2, (double)x2);
		
//		cout<<a1<<' '<<a2<<endl;
		
		double ang = abs(a1 - a2);
		if (ang > PI) ang = 2 * PI - ang;
		
		RES[P[i].ind] = ang / (2 * PI);
	}
	
	FOR (i, 0, n)
	{
		printf("%.11f\n", RES[i]);
	}
}


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

namespace paiza3.AtCoder.AtCoderBeginnerContest
{
	public class ABC086
	{
		static void Main(string[] args)
		{
			var result = Console.ReadLine().Split(' ').ToArray().Select(int.Parse).Aggregate((now,next)=>now*next);
			Console.WriteLine(result % 2 == 0 ? "Even" : "Odd");
		}
	}
}

Measured memory_bytes: 11348
s = input()
if 'BC' not in s:
  print(0)
  import sys
  sys.exit()
t = s.split('BC')
m = 0
ans = 0
for l in t[:-1]:
  cnt = 0
  for c in l[::-1]:
    if c!='A':
      ans += cnt
      m = cnt
      break
    cnt += 1
  else:
    m += cnt
    ans += m
print(ans)

Measured memory_bytes: 5476
# ABC073D - joisino's travel
from heapq import heappop, heappush
from itertools import permutations

inf = 1 << 30

def dijkstra(source: int, edges: "List[Tuple[int, int]]") -> "List[int]":
    """
    Compute the distance of the shortest path from V_source to each vertex.

    Args:
        source: V_source
        edges: Edges info
    Returns:
        dist: A list of distance from V_source
    """
    edges_count = len(edges)
    dist = [inf] * edges_count
    dist[source] = 0
    undetermined = edges_count - 1  # V_0 is determined in 1-idx graph
    queue = [(0, source)]
    while queue:
        cost, v = heappop(queue)
        if cost > dist[v]:
            continue
        for next_cost, u in edges[v]:
            if cost + next_cost < dist[u]:
                dist[u] = cost + next_cost
                heappush(queue, (dist[u], u))
        undetermined -= 1
        if not undetermined:
            break
    return dist  # There may be no path from V_source to some vertices.

def main():
    N, M, R, *RABC = map(int, open(0).read().split())
    visit, ABC = RABC[:R], RABC[R:]
    edges = [[] for _ in range(N + 1)]
    for v, u, cost in zip(*[iter(ABC)] * 3):
        edges[v].append((cost, u)), edges[u].append((cost, v))
    dist = {v: dijkstra(v, edges) for v in visit}
    ans = inf
    for perm in permutations(visit):
        cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
        ans = min(ans, cur)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 8252
package main

import (
  "fmt"
)

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxt(a ...int) int {
	t := a[0]
	for _, x := range a {
		t = max(t, x)
	}
	return t
}

func main() {
	var n int
	fmt.Scan(&n)
	var dp [100001][3]int
	for i := 0; i < 3; i++ {
		dp[0][i] = 0
	}
	for i := 1; i <= n; i++ {
		var a [3]int
		fmt.Scan(&a[0], &a[1], &a[2])
		for j := 0; j < 3; j++ {
			dp[i][j] = max(dp[i-1][(j + 1) % 3], dp[i-1][(j + 2) % 3]) + a[j];
		}
	}
	fmt.Println(maxt(dp[n][0], dp[n][1], dp[n][2]))
}

Measured memory_bytes: 7936
#include <stdio.h>

int main()
{
        int i, j;
        int x, y, z, n;
        int rad;

        while (scanf("%d %d %d", &x, &y, &z) && !(x == 0 && y == 0 && z == 0)) {

                scanf("%d", &n);
                for (i = 0; i < n; i++) {
                        scanf("%d", &rad);
                        if (rad*2*rad*2 > x*x + y*y ||
                                        rad*2*rad*2 > y*y + z*z ||
                                        rad*2*rad*2 > z*z + x*x)
                                printf("OK\n");
                        else
                                printf("NA\n");
                }
        }
        return 0;

}

Measured memory_bytes: 0
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

k = i()
ans = 0
ls = list(int(k) for k in range(1,k+1))
for i in range(k):
	ans += ls[i]//2
print(ans)

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int k, s;
	cin >> k >> s;
	int cnt = 0;
	for (int x = 0; x <= k && x <= s; ++x) {
		for (int y = 0; y <= k && x + y <= s; ++y) {
			int z = s - x - y;
			if (z <= k) cnt++;
		}
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

using ll = long long;

string A, B;
string ans = "YES";

int main() {
    cin >> A;
    cin >> B;

    for (int i = 0; i < 3; i++) {
        if (A[i] != B[2 - i]) { ans = "NO"; break; }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	string n;
	cin >> n;
	long long sum = 0;
	for (int i = 0; i < n.size(); i++) {
		sum += int((n[i] - '0'));
	}
	if (sum % 9 == 0)cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int k, n;
	cin >> k >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	vector<int> v;
	v.push_back(a[0] + (k - a[n-1]));
	for(int i = 1; i < n; i++)
		v.push_back(a[i]-a[i-1]);
	
	cout << k - *max_element(v.begin(),v.end());
	
	
	
	return 0;
}



Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
using namespace std;
int n,arr[100005],dp[100005];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	dp[1]=abs(arr[0]-arr[1]);
	for(int i=2;i<n;i++){
		dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 4444