akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector< pair<int, int> > I(N+1, {0, 0});
	for(int i = 0; i < N; i++) cin >> I[i].ff >> I[i].ss;
	vector<int> lft_ends(N+1), rt_ends(N+1);
	for(int i = 0; i < N+1; i++) {
		lft_ends[i] = I[i].ff;
		rt_ends[i] = I[i].ss;
	}
	sort(begin(lft_ends), end(lft_ends));
	sort(begin(rt_ends), end(rt_ends));
	cat ans = 0;
	for(int i = 0; i < (N+1)/2; i++) {
		if(lft_ends[N-i] <= rt_ends[i]) break;
		ans += 2 * (lft_ends[N-i] - rt_ends[i]);
	}
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 1792
(R,C,K),*RCV = $<.map{|ln| ln.split.map(&:to_i) }

Rs = Array.new(R){ [0]*C }
RCV.each{|s,d,v|
	Rs[s-1][d-1] = v
}

r0 = [0]*C
while r1 = Rs.shift
	c,vs = 0,[0]*4
	while c < C
		if vs[0] < r0[c]
			vs[0] = r0[c]
			if vs[1] < vs[0]
				vs[1] = vs[0]
				if vs[2] < vs[1]
					vs[2] = vs[1]
					if vs[3] < vs[2]
						vs[3] = vs[2]
					end
				end
			end
		end
		if 0 < v = r1[c]
			vs[3] = vs[2]+v if vs[3] < vs[2]+v
			vs[2] = vs[1]+v if vs[2] < vs[1]+v
			vs[1] = vs[0]+v if vs[1] < vs[0]+v
		end
		r0[c] = vs[-1]
		c += 1
	end
end

p r0[-1]


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

int main() {
	string s;
	cin >> s;
	for (int i = 'a'; i <='z'; i++) {
		if (find(s.begin(), s.end(), i) == s.end()) {
			cout << (char)i << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}

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






int main(){
  


  vector<int> vec(3);
  
  int a,b,c;
  cin>>a>>b>>c;
  
  vec.at(0)=a;
  vec.at(1)=b;
  vec.at(2)=c;
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  a=vec.at(0);
  b=vec.at(1);
  c=vec.at(2);
  
  int answer=0;
  


  if ((b-c)%2==0){
    answer=(2*a-b-c)/2;
  }
  
  else {
    answer=((2*a-b-c)/2)+2;
  }
  
  cout<<answer<<endl;
  
  
    
    
  


    
  
  
  
}

Measured memory_bytes: 256
// “Incredible change happens in your life when you decide to take control of what
// you do have power over instead of craving control over what you don't.

// Dear online judge:
//  I've read the problem, and tried to solve it.
//  Even if you don't accept my solution, you should respect my effort.
//  I hope my code compiles and gets accepted.

#include <bits/stdc++.h>
typedef long long ll;
#define forn(i, start, end) for (ll i = start; i < ll(end); i++)
#define input(arr, n) forn(i, 0, n) cin >> arr[i];
#define input2d(arr, n, m) forn(i, 0, n) forn(j, 0, m) cin >> arr[i][j];
#define MOD 1000000007
#define pb push_back
#define ppb pop_back
#define mk make_pair
#define f first
#define s second
#define tc    \
    ll T;     \
    cin >> T; \
    while (T--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
using namespace std;

int32_t main()
{
    FAST;
    //tc
    {
        ll k;
        cin>>k;
        string s;
        cin>>s;
        if(s.length()<=k)
            cout<<s<<'\n';
        else{
            forn(i,0,k)
                cout<<s[i];
            s="...";
            cout<<s<<'\n';
        }
    }
    return 0;
}

Measured memory_bytes: 3600
a1,a2,a3 = map(int,input().split())
b1,b2,b3 = map(int,input().split())
c1,c2,c3 = map(int,input().split())

if not (a1-a2 == b1-b2 == c1-c2) or not (a2-a3 == b2-b3 == c2-c3):
    print('No')
elif not (a1-b1 == a2-b2 == a3-b3) or not (b1-c1 == b2-c2 == b3-c3):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
typedef long long ll;
int main()
{
    string s;
    cin>>s;

    if(s == "RRR")

        cout<< 3 <<endl;

    else if(s == "RRS"|| s =="SRR")

        cout << 2 <<endl;

    else if(s=="SSS")
        cout << 0 <<endl;

    else
        cout << 1 <<endl;

    return 0;
}

Measured memory_bytes: 3584
/*
ID: amagica1
TASK: ariprog
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define INF INT_MAX
#define NINF -INF
#define mp make_pair
#define endl '\n'
#define boost() cin.tie(0); cin.sync_with_stdio(0)
#define For(i, a, b) for(int i=a; i<b; i++)
#define FOR(i, a, b) for(int i=a; i<=b; i++)
#define Rev(i, a, b) for(int i=a; i>b; i--)
#define REV(i, a, b) for(int i=a; i>=b; i--)
typedef long long ll;
typedef long double ld;
typedef int64_t l;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
const ll MOD = 1e9 + 7;
const int MAXN = 200005;
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
mt19937 rng;
int randint(int a, int b){ return uniform_int_distribution<int>(a, b)(rng);}
int main() {
    //-----------FILE------------//
    //freopen("airprog.in", "r", stdin);
    //freopen("airprog.out", "w", stdout);
    //----------------------------//
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    bool ok = true;
    for (int i = 0; i <= 2; i++) {
        if (s.at(i) == s.at(i + 1)) ok = false;
    }
    if (ok) cout << "Good" << endl;
    else cout << "Bad" << endl;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List
import qualified Data.Vector.Storable as V
import qualified Data.Vector.Storable.Mutable as MV

findUF :: MV.IOVector Int -> Int -> IO Int
findUF uf x = do
    p <- MV.unsafeRead uf x
    if p == -1
        then return x
        else do
                f <- findUF uf p
                MV.unsafeWrite uf x f
                return f

u uf [x,y] = do
    px <- findUF uf x
    py <- findUF uf y
    when (px /= py) $ MV.unsafeWrite uf py px

f n _ [] = return []
f n as (e:es) = do
    uf <- MV.replicate (n+1) (-1)
    mapM (u uf) as
    mapM (u uf) es
    rs <- f n (e:as) es
    uff <- V.unsafeFreeze uf
    return $ (V.length $ V.filter (==(-1)) uff) : rs

main=do
    [n,m] <- map read.words<$>getLine
    es <- replicateM m $ map read.words <$> getLine
    ms <- f n [] es
    print $ length $ filter (>2) ms


Measured memory_bytes: 1020
X,N = map(int, input().split())
P = list(map(int,input().split()))

ans_list=[]
for i in range(101):
    check=0
    if X-i not in P:
        ans_list.append(X-i)
        check+=1
    elif X+i not in P:
        ans_list.append(X+i)
        check+=1
    if check>=1:
        print(ans_list[0])
        break


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

int main(){
  string s;
  cin >> s;
  
  int ans = s.length();
  
  //iは最初に使う色(0or1)
  for (int i=0;i<2;++i){
    //iを最初に使ったときに変えなければならないタイルの数
    int cnt = 0;
    
    for (int j=0;j<s.length();++j){
      //文字を数字に変換する方法((char)(0+'0')→'0')
      if (j%2==0&&s[j]!=(char)(i+'0')) cnt++;
      if (j%2==1&&s[j]==(char)(i+'0')) cnt++;
    }
    ans = min(ans,cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main() {
  string S; cin >> S;
  int N = S.size();
  rep(i,N){
    if(S[i]=='B'&&S[i+1]=='C'){
      S[i] = 'D';
      S.erase(S.begin()+i+1);
    }
  }
  // cout << S << endl;

  N = S.size();
  ll ans = 0;
  ll cnt = 0;
  rep(i,N){
    if(S[i]=='A'){
      cnt++;
    }else if(S[i]=='D'){
      ans += cnt;
    }else{
      cnt = 0;
    }
    // cout << ans << endl;
  }

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


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007
int i,j,k,l;
static const int MAX_N=10e5;
int main(void){
	string h;
	cin >> h;
	int t=0,i=0;
	while(1){
		t+=h[i]-'0';
			i++;
		t%=9;
		if(i>=h.size())break;
	}
	puts((t==0?"Yes":"No"));
	return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int n, k;
    cin >> n >> k;
    vi h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());

    int ans = inf;
    rep(i, n - k + 1)
    {
        //cout << h[i] << ", " << h[i + k - 1] << "\n";
        ans = min(ans, h[i + k - 1] - h[i]);
    }
    cout << ans << "\n";
    return 0;
}

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

int n, e, x, y, derece[100001], maxi_deger=0, dp[100001];
vector<int> edges[100001];

int dfs(int node){

	if(node>=n)return 0;
	int maxi=0;
	if(dp[node])return dp[node];
	for(int i=0;i<edges[node].size();i++)dp[node]=max(dp[node], dfs(edges[node][i])+1);

	return dp[node];
}

int main(void){
	cin>>n>>e;
	for(int i=0;i<e;i++){
		cin>>x>>y;
		edges[x-1].push_back(y-1);
		derece[y-1]++;
	}
	for(int i=0;i<n;i++){
	if(!derece[i]&&dfs(i)>maxi_deger)maxi_deger=dfs(i);}
	cout<<maxi_deger;


	return 0;
}

Measured memory_bytes: 11136
// わーい再帰！あかり再帰だーいすき！
#include <iostream>

using namespace std;

typedef long long ll;
ll n,x;

ll solve(ll a, ll b){
	if(b%a)
		return solve(b % a, a) + 2 * (b - b % a);
	else
		return 2 * b - a;
}

int main() {
	cin >> n >> x;
	cout << n + solve(min(x, n-x), max(x, n - x)) << endl;
}


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

int main()
{
    long long arr[5],ans=0;
    for(int i=0;i<5;i++)
    {
        cin>>arr[i];
        if(arr[i]==0)
            ans=i+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3588
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Edge implements Comparable<Edge> {

    final int from;
    final int to;
    final int len;

    Edge( final int from, final int to, final int len ) {
	this.from = from;
	this.to = to;
	this.len = len;
    }

    public int compareTo( Edge e ) {
	return len - e.len;
    }    
}

class Main {

    static int find( final int x, final int[] root ) {
	if ( x == root[ x ] ) {
	    return x;
	} else {
	    final int parents = find( root[ x ], root );
	    root[ x ] = parents;
	    return parents;
	}
    }

    static void union( final int x, final int y, final int[] root ) {
	final int parents = find( x, root );
	root[ parents ] = y;
    }

    static boolean same( final int x, final int y, final int[] root ) {
	final int parentsX = find( x, root );
	final int parentsY = find( y, root );
	return parentsX == parentsY;
    }
    
    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    ArrayList<Edge> list = new ArrayList<Edge>();
	    
	    final int n = Integer.parseInt( stdin.nextLine() );
	    if ( n == 0 ) {
		break;
	    }
	    final int m = Integer.parseInt( stdin.nextLine() );
	    for ( int i = 0; i < m; i++ ) {
		final String[] input = stdin.nextLine().split( "," );
		final int from = Integer.parseInt( input[ 0 ] );
		final int to = Integer.parseInt( input[ 1 ] );
		final int len = Integer.parseInt( input[ 2 ] );
		list.add( new Edge( from, to, len ) );
	    }

	    Collections.sort( list );
	    
	    final int[] root = new int[ n ];
	    for ( int i = 0; i < n; i++ ) {
		root[ i ] = i;
	    }
	    Set<Integer> set = new HashSet<Integer>();

	    int ans = 0;
	    for ( Edge e : list ) {
		if ( !same( e.from, e.to, root ) ){
		    union( e.from, e.to, root );
		    ans += e.len / 100 - 1;
		}
	    }
	    System.out.println( ans );
	}	
    }    
}

Measured memory_bytes: 47656
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

ll d[1001]={};

int main() {
	int n;
	ll a,b;
	cin>>n>>a>>b;
	ll p1,p2;
	cin>>p1;
	ll total=0;
	for(int i=1;i<n;++i){
		cin>>p2;
		if((p2-p1)*a<b){
			total+=(p2-p1)*a;
		}else{
			total+=b;
		}
		p1=p2;
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<iostream>
using namespace std;
int main()
{
    string a;   
    bool v[2]={0}; 
    cin>>a; 
    for(int i=0;i<a.length();i++)
    { 
        if(a[i]=='C') 
            v[0]=1; 
        if(a[i]=='F'&&v[0]) 
            v[1]=1; 
    }
    if(v[1]) 
        cout<<"Yes"; 
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define MAX_N 10000
using namespace std;

int main()
{
  int s_len, t_len;
  int S[MAX_N], T[MAX_N];
  cin >> s_len;
  for (int i = 0; i < s_len; i++) {
    cin >> S[i];
  }
  cin >> t_len;
  for (int i = 0; i < t_len; i++) {
    cin >> T[i];
  }
  int n = 0;
  for (int i = 0; i < t_len; i++) {
    bool found = false;
    for (int j = 0; j < s_len; j++) {
      if (T[i] == S[j]) {
        found = true;
      }
    }
    if (found) {
      n++;
    }
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 3100
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    ori = sum(a)

    for i in range(n):
        bt = b[i]
        if a[i] < bt:

            a[i+1] = max(a[i+1]-(bt-a[i]), 0)
            a[i] = 0
        else:
            a[i] -= bt
    end = sum(a)
    print(ori-end)
resolve()

Measured memory_bytes: 81892
# coding: utf-8
class Case03

  def initialize
  end

  def show
    p self.instance_variables
        .map{ |sym| [sym, self.instance_variable_get(sym)] }
        .to_h
  end
  
  # 実行する
  def execute
    read
    solve
    output
  end

  # 読込
  def read
    @n = gets.chomp.to_i
    @a = gets.chomp.split.map(&:to_i)
  end

  # 回答
  def solve
    @t = []
    @a.each_with_index {|x,i| @t << [x,i+1] }
    @t.sort! {|x,y| x[0] <=> y[0] }
    @result = @t.map { |x| x[1] }
  end
  
  # 出力
  def output
    puts @result.join(' ')
  end

end

Case03.new.execute if $0 == __FILE__



Measured memory_bytes: 14688
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    int a, b;
    cin >> a >> b;

    cout << a * b << endl;
    return 0;
}


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

int main() {
    int N, K, d, A, ans = 0;
    cin >> N >> K;
    set<int> S;
    while (K--) {
        cin >> d;
        while (d--) {
            cin >> A;
            S.insert(A);
        }
    }
    cout << N - S.size() << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  string S, T;
  cin >> S >> T;

  vector<int> s(26, -1);
  vector<int> t(26, -1);

  int count_s = 0;
  int count_t = 0;
  rep(i, S.size())
  {
    char c_s = S[i] - 'a';
    if (s[c_s] == -1)
    {
      s[c_s] = count_s;
      count_s++;
    }

    char c_t = T[i] - 'a';
    if (t[c_t] == -1)
    {
      t[c_t] = count_t;
      count_t++;
    }

    if (s[c_s] != t[c_t])
    {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  rep(i,N) cin>>a[i];
  
  int ans=4000000;
  for(int i=-100;i<=100;i++){
    int sum=0;
    rep(j,N){
      sum += (a[j]-i)*(a[j]-i);
    }
    ans =min(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define revREP(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1000000000

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;

//ある値がvector内の要素に含まれているか否か判定する
int vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance(vec.begin(), itr);
    if (index != vec.size()) { // 発見できたとき
        return 1;
    } else { // 発見できなかったとき
        return 0;
    }
}

////////////////////////// let's code! /////////////////////////////

int i, j, k;

///// variables frequent to use /////

long permutation(int n, int value) {
    if (n == 1) {
        return value;
    } else {
        if (value > 1000000007) {
            value = n % 1000000007;
            return value * permutation(n - 1, value);
        } else {
            return value * permutation(n - 1, value);
        }
    }
}

int main() {
    long N, K;

    cin >> N >> K;

    vector<int> A(N);

    int Rcount = 0;
    int Lcount = 0;

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

    REP(i, N) {
        int cur = A[i];
        for (j = i; j < N; j++) {
            if (A[j] < cur) Rcount++;
        }
    }

    REP(i, N) {
        int cur = A[i];
        for (j = i; j >= 0; j--) {
            if (A[j] < cur) Lcount++;
        }
    }

    long result = 0;
    result += Rcount * (((K * (K + 1)) / 2)  % 1000000007) + Lcount * (((K * (K - 1)) / 2) % 1000000007);
    cout << result % 1000000007;
};

Measured memory_bytes: 256
#include <limits>
#include <cstdio>
#include <vector>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
template<typename Type> class RMQ {
private:
	int size_; vector<Type> dat;
	Type query_(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return numeric_limits<Type>::max();
		if (a <= l && r <= b) return dat[k];
		int lc = query_(a, b, 2 * k, l, (l + r) / 2);
		int rc = query_(a, b, 2 * k + 1, (l + r) / 2, r);
		return min(lc, rc);
	}
public:
	RMQ(int size__) {
		for (size_ = 1; size_ < size__; size_ <<= 1); dat.resize(size_ * 2, numeric_limits<Type>::max());
	}
	RMQ(vector<Type> v) {
		for (size_ = 1; size_ < dat.size(); size_ <<= 1); dat.resize(size_ * 2, numeric_limits<Type>::max());
		for (int i = 0; i < v.size(); i++) dat[i + size_] = v[i];
		for (int i = size_ - 1; i >= 1; i--) dat[i] = min(dat[2 * i], dat[2 * i + 1]);
	}
	int size() { return size_; }
	int ndat() { return numeric_limits<Type>::max(); }
	void update(int i, int x) {
		i += size_; dat[i] = x;
		while (i > 1) i >>= 1, dat[i] = min(dat[2 * i], dat[2 * i + 1]);
	}
	Type query(int l, int r) {
		return query_(l, r, 1, 0, size_);
	}
};
int n, d, e[200000]; long long ret; vector<int> f[200000];
int main() {
	scanf("%d%d", &n, &d);
	for (int i = 0; i < n; i++) f[i].resize(3), scanf("%d%d%d", &f[i][1], &f[i][2], &f[i][0]);
	sort(f, f + n);
	for (int i = 0; i < n; i++) e[i] = f[i][0];
	RMQ<int> r1(n); for (int i = 0; i < n; i++) r1.update(i, f[i][1]);
	RMQ<int> r2(n); for (int i = 0; i < n; i++) r2.update(i, -f[i][1]);
	RMQ<int> r3(n); for (int i = 0; i < n; i++) r3.update(i, f[i][2]);
	RMQ<int> r4(n); for (int i = 0; i < n; i++) r4.update(i, -f[i][2]);
	for (int i = 0; i < n; i++) {
		int ptr = upper_bound(e, e + n, e[i] + d) - e;
		int wp = -r2.query(i, ptr) - r1.query(i, ptr);
		int hp = -r4.query(i, ptr) - r3.query(i, ptr);
		ret = max(ret, 1LL * wp * hp);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 22196
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#define inf 999999999
using namespace std;

typedef int weight;
typedef vector<weight> array;
typedef vector<array> matrix;

void backward_traverse(int v, int s, int r, matrix &g,
  vector<int> &no, vector< vector<int> > &comp,
  vector<int> &prev, vector<weight> &mcost,
  vector<int> &mark, weight &cost, bool &found) {
  const int n = g.size();
  if (mark[v]) {
    vector<int> temp = no;
    found = true;
    do {
      cost += mcost[v];
      v = prev[v];
      if (v != s) {
        while (comp[v].size() > 0) {
          no[comp[v].back()] = s;
          comp[s].push_back(comp[v].back());
          comp[v].pop_back();
        }
      }
    } while (v != s);
    for (int j = 0; j < n; ++j)
      if (j != r && no[j] == s)
        for (int i = 0; i < n; ++i)
          if (no[i] != s && g[j][i] < inf)
            g[j][i] -= mcost[ temp[j] ];
  }
  mark[v] = true;
  for (int i = 0; i < n; ++i)
    if (no[i] != no[v] && prev[ no[i] ] == v)
      if (!mark[ no[i] ] || i == s)
        backward_traverse(i, s, r, g,
            no, comp, prev, mcost, mark, cost, found);
}

weight minimum_spanning_arborescence(int r, matrix &g) {
  const int n = g.size();

  vector<int> no(n);
  vector< vector<int> > comp(n);
  for (int i = 0; i < n; ++i) {
    no[i] = i;
    comp[i].push_back(i);
  }
  weight cost = 0;
  while (1) {
    vector<int> prev(n, -1);
    vector<weight> mcost(n, inf);
    for (int j = 0; j < n; ++j) {
      if (j == r) continue;
      for (int i = 0; i < n; ++i) {
        if (no[i] != no[j] && g[j][i] < mcost[ no[j] ]) {
            mcost[ no[j] ] = g[j][i];
            prev[ no[j] ] = no[i];
        }
      }
    }
//for(int I=0;I<n;I++)printf("%d\n",mcost[I]);
    bool stop = true;
    vector<int> mark(n);
    for (int i = 0; i < n; ++i) {
      if (i == r || mark[i] || comp[i].size() == 0) continue;
      bool found = false;
      backward_traverse(i, i, r, g,
          no, comp, prev, mcost, mark, cost, found);
      if (found) stop = false;
    }
    if (stop) {
      for (int i = 0; i < n; ++i)
        if (prev[i] >= 0)
          cost += mcost[i];
      return cost;
    }
  }
}

int main(){
	int V,E,r,s,t,w;
	scanf("%d%d%d",&V,&E,&r);
	matrix g(V);
	for(s=0;s<V;s++){
		g[s].resize(V);
		for(t=0;t<s;t++)g[s][t]=inf;
		g[s][t++]=0;
		for(;t<V;t++)g[s][t]=inf;
	}
	for(;E--;)scanf("%d%d%d",&s,&t,&w),g[t][s]=w;
	printf("%d\n",minimum_spanning_arborescence(r,g));
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;


ll N, K;
string s;

int main(void) {
  cin >> N >> K;
  cin >> s;
  ll f=0;
  if(s[0]=='0') {
    s='1'+s;
    N++;
    f=1;
  }
  ll i;
  vector<ll> v, w;
  
  for(i=0; i<N;) {
    if(s[i]=='0') {
      ll cnt=0;
      while(i<N && s[i]=='0') {
        cnt++;
        i++;
      }
      v.pb(cnt);
    }else if(s[i]=='1') {
      ll cnt=0;
      while(i<N && s[i]=='1') {
        cnt++;
        i++;
      }
      w.pb(cnt);
    }
  }
  
  if(v.size()<=K) {
    if(f) N--;
    pt(N);
    return 0;
  }
  
  ll ans=0;
  ll t=0;
  for(i=0; i<K; i++) {
    t+=v[i];
    t+=w[i];
  }
  if(K<w.size()) t+=w[K];
  
  if(f) ans=t-1;
  else ans=t;
  
  
  for(i=K; i<v.size(); i++) {
    t-=w[i-K];
    t-=v[i-K];
    if(i+1<w.size()) t+=w[i+1];
    t+=v[i];
    
    chmax(ans, t);
  }
  
  pt(ans);
}






Measured memory_bytes: 1404
N, K = [int(c) for c in input().split()]
nB, nR = K, N-K

if nR==0:
    print(1)
    for k in range(2, K+1):
        print(0)
    exit()

mod = int(1e9+7)

binom = [[0 for _ in range(2001)] for _ in range(2001)]
binom[0][0] = 1
for n in range(1, 2001):
    binom[n][0] = 1
    for k in range(1,2001):
        binom[n][k] = (binom[n-1][k] + binom[n-1][k-1]) % mod
      	
for k in range(1, K+1):
    blue   = binom[nB-1][k-1]
    red_m1 = binom[nR-1][k-2] if k>=2 else 0
    red_0  = binom[nR-1][k-1]
    red_p1 = binom[nR-1][k  ]

    print((blue*(red_m1 + red_0*2 + red_p1)) % mod )

Measured memory_bytes: 99228
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    int c=0;
    for(int i=0;i<4;i++){
        if(s[i]=='+') c++;
        else c--;
    }
    cout << c << endl;
}


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

int main() {
    ll N, X;
    cin >> N >> X;
    ll ans = 0;
    vector<ll> level(51, 0), ps(51, 0);
    level[0] = 1;
    ps[0] = 1;
    for (int i=1; i<=N; ++i) {
        level[i] = level[i-1]*2LL+3LL;
        ps[i] = ps[i-1]*2LL+1LL;
    }
    if (X == level[N]) {
        cout << ps[N] << endl;
        return 0;
    }
    else if (X <= N) {
        cout << 0 << endl;
        return 0;
    }

    for (int cur=N; cur>=0; --cur) {
        if (X+1 == level[cur]) {
            ans += ps[cur];
            break;
        }
        else if (X > level[cur]/2) {
            ans += ps[cur-1]+1;
            X -= level[cur-1]+2;
            //if (X > level[cur-1]) X--;
        }
        else if (X == level[cur]/2) {
            ans += ps[cur-1];
            X -= level[cur-1]+1;
            //if (X > level[cur-1]) 
        }
        else {
            X--;
        }
        if (X == 0) break;
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int a, b;
	cin >> a >> b;

	cout << max(a - b, max(a + b, a * b)) << endl;


}

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

int main(void)
{
    int n;
    cin >> n;
    while (n-- > 0)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a *= a;
        b *= b;
        c *= c;
        if (a + b == c || b + c == a || a + c == b)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 2992
fun main(args: Array<String>) {
        val sc = if (args.size > 1) java.util.Scanner(java.io.File(args[1])) else java.util.Scanner(System.`in`)
        solve(sc)
    }

    fun solve(sc: java.util.Scanner) {
        val H = sc.nextInt()
        val W = sc.nextInt()
        sc.nextLine()
        val S: Array<CharArray> = (1..H).map { sc.nextLine().toCharArray() }.toTypedArray()
        (0..(H - 1)).forEach { y ->
            (0..(W - 1)).forEach { x ->
                if (S[y][x] == '.') {
                    val n = arrayOf(
                            -1 to -1,
                            -1 to 0,
                            -1 to 1,
                            0 to -1,
                            0 to 1,
                            1 to -1,
                            1 to 0,
                            1 to 1
                    ).map { d ->
                        try {
                            S[y + d.first][x + d.second] == '#'
                        } catch (e: ArrayIndexOutOfBoundsException) {
                            false
                        }
                    }.count { it }
                    S[y][x] = "%d".format(n).toCharArray()[0]
                }
            }
        }
        S.forEach { println(it.joinToString("")) }
    }


Measured memory_bytes: 41792
MOD = 998244353
max = (10**5)*2 + 1
facts = [1 for i in range(max)]
invs = [1 for i in range(max)]

def inv(x):
    return pow(x,MOD-2,MOD)

for i in range(1,max):
    facts[i] = facts[i-1]*i%MOD
    invs[i] = inv(facts[i])

def comb(n,r):
    return facts[n]*invs[r] * invs[n-r] % MOD

n,m,k = map(int,input().split())
ans = 0
for i in range(k+1):
    ans = (ans + comb(n-1,i)*pow(m-1,n-1-i,MOD)*m) % MOD
print(ans)

# k = 0
# (m-1) ** (n-1) * m % mod
# k = 1 
# (n-1Ck) * (m-1)**(n-1-k) * m % mod

Measured memory_bytes: 24636
N, L = map(int, input().split())
Ringo = sum([i+L-1 for i in range(1,N+1)])
ans = 1e+09
for j in range(1,N+1):
  Ringo2 = sum([i+L-1 for i in range(1,N+1) if i != j])
  tem = abs(Ringo - Ringo2)
  ans = min(ans, tem)
print(Ringo-ans if Ringo > Ringo2 else Ringo+ans)

Measured memory_bytes: 38768
#include <stdio.h>

int main(void) {
	int i, j, temp;
	int mountains[10];
	
	for (i=0; i<10; i++) {
		scanf("%d", &mountains[i]);
	}
	
	for (i=0; i<9; i++) {
		for (j=i+1; j<10; j++) {
			if (mountains[i] < mountains[j]) {
				temp = mountains[i];
				mountains[i] = mountains[j];
				mountains[j] = temp;
			}
		}
	}
	
	printf("%d\n%d\n%d\n", mountains[0], mountains[1], mountains[2]);
	
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
  		
      	int n = sc.nextInt();
      	int stack;
      	List<Integer> nums = new ArrayList<Integer>();
      	int num = 1;
      
      	for(int i = 0;i < n;i++){
          	stack = sc.nextInt();
        	if(stack == num) {
              nums.add(stack);
              num++;
            }
        }
      	
      	if(num == 1)System.out.println(-1);
      	else System.out.println(n - nums.size());
        
	}
}


Measured memory_bytes: 65568
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<vector<ll> > dp(n,vector<ll>(n,0));
    ll x,y;
    cin >> x >> y;
    x--;
    y--;
    for(ll i=0;i<n;i++) {
    	for(ll j=i;j<n;j++) {
    		dp[i][j] = j-i;
    		dp[j][i] = dp[i][j];
    	}
    }

    for(ll i=0;i<n;i++) {
    	for(ll j=i;j<n;j++) {
    		
    			dp[i][j] = min(dp[i][x] + 1 + dp[y][j],dp[i][j]);
    			dp[j][i] = dp[i][j];
    		 
    	}
    }
    map<ll,ll> m;
    for(ll i=0;i<n;i++) {
    	for(ll j=i;j<n;j++) {
    		m[dp[i][j]]++;
    	}
    }
    for(ll i=1;i<n;i++) {
    	cout << m[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 31744
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		 long double   ld;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;


int main()
{
    ll a;
    cin>>a;
    cout<<(a^1)<<nn;






}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






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


int main()
{

    int n, a, b;
    cin >> n >> a >> b;
    int ans;
    if (n * a > b)
    {
        ans = b;
    }
    else
    {
        ans = n * a;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace	std;
int main(){

  int n,now=0,a[100000],yet[100000]={0},result=0,i;

  cin>>n;
  for(i=0;i<n;i++) cin>>a[i];

  for(i=0;i<n;i++){
    if(yet[now]==1){
      cout<<-1<<endl;
      return 0;
    }
    yet[now]=1;
    now=a[now]-1;
    result++;
    if(now==1){
      cout<<result<<endl;
      return 0;
    }
  }

}



Measured memory_bytes: 1024
#include <iostream>

using namespace std;
using ll = long long;

#define ALL(x) begin(x), end(x)

int main() {
  int N,D,X;
  cin >> N >> D >> X;

  int ans{X};
  int a;
  for (int i = 0; i != N; ++i) {
    cin >> a;
    ans += (D-1)/a+1;
  }

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int N, Y;
	cin >> N >> Y;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			int k = N - i - j;
			if (k >= 0 && 10000 * i + 5000 * j + 1000 * k == Y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
/* last edited at 28/8/2015 by charis
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C
*/

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

void BubbleSort(int N, char C[], int D[]){
	for(int i=0; i<N-1; i++){
		for(int j=N-1; j>i; j--){
			if(D[j]<D[j-1]){
				int t=D[j-1]; D[j-1]=D[j]; D[j]=t;
				char s=C[j-1]; C[j-1]=C[j]; C[j]=s;		
			}
		}
	}
}

void SelectionSort(int N, char E[], int F[]){
	for(int i=0; i<N-1; i++){
		int min=i;
		for(int j=i+1; j<N; j++){
			if(F[min]>F[j]) min=j;
		}
		int t=F[i]; F[i]=F[min]; F[min]=t;
		char s=E[i]; E[i]=E[min]; E[min]=s;		
	}
}

bool check(int N, char A[], int B[], char C[], int D[]){
	for(int i=0; i<N-1; i++){	
		for(int j=i+1; j<N; j++){
			for(int m=0; m<N-1; m++){
				for(int n=m+1; n<N; n++){
					if(B[i]==B[j] && B[j]==D[m] && D[m]==D[n]){
						if(A[i]==C[n] && A[j]==C[m]) return false;
					}
				}
			}
		}
	}
	return true;
}

int main(){
	int N;
	cin >> N;
	char A[N], C[N], E[N];
	int B[N], D[N], F[N];
	for(int i=0; i<N; i++){
		cin >> A[i] >> B[i];
		C[i]=A[i]; D[i]=B[i]; E[i]=A[i]; F[i]=B[i]; 
	}

	BubbleSort(N, C, D);
	
	for(int i=0; i<N-1; i++){
		cout << C[i] << D[i] << " ";
	}
	cout << C[N-1] << D[N-1] << endl;
	if(check(N, A, B, C, D)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	SelectionSort(N, E, F);
	
	for(int i=0; i<N-1; i++){
		cout << E[i] << F[i] << " ";
	}	
	cout << E[N-1] << F[N-1] << endl;
	if(check(N, A, B, E, F)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;	
	
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> v;
long long nmax;
void add(long long a){
	for(long long i=a;i<=nmax+1;i+=i&-i){
		v[i]++;
	}
}
long long cul(long long a){
	long long ans=0;
	for(long long i=a;i>=1;i-=i&-i){
		ans+=v[i];
	}
	return ans;
}

int main() {
	int n;cin>>n;
	long long k;cin>>k;
	vector<long long> a(n+1),b(n+1);
	vector<pair<long long,int>> p(n+1);
	a[0]=0;
	for(int i=0;i<n;i++){
		cin>>a[i+1];
		a[i+1]-=k;
	}
	for(int i=1;i<n+1;i++){
		a[i]+=a[i-1];
	}
	for(int i=0;i<n+1;i++){
		p[i].first=a[i];
		p[i].second=i;
	}
	sort(p.begin(),p.end());
	long long num=1;
	long long temp=p[0].first;
	for(int i=0;i<n+1;i++){
		if(p[i].first!=temp){
			num++;
			temp=p[i].first;
		}
		b[p[i].second]=num;
	}
	long long min=0;
	long long max=0;
	for(int i=0;i<n+1;i++){
		if(min>a[i])min=a[i];
		if(max<a[i])max=a[i];
	}
	for(int i=0;i<n+1;i++){
		a[i]-=min;
		a[i]++;
	}

	max-=min;
	max++;
	min=1;
	nmax=2;

	for(int i=0;i<5;i++){
		nmax*=10;
	}
	v=vector<int>(nmax+2,0);
	long long ans=0;
	for(int i=0;i<n+1;i++){
		add(b[i]);
		ans+=cul(b[i])-1;
	}
//	for(int i=0;i<n+1;i++){
//		cout<<b[i]<<' ';
//	}
//	cout<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7424
N = int(input())
D = [list(map(int, input().split())) for i in range(N)]
Q = []
f = [1]
for i in range(N):
  f.append(f[i] * (i+1))
for i in range(N-1):
  for j in range(i+1, N):
    Q.append(((D[i][0] - D[j][0]) ** 2 + (D[i][1] - D[j][1]) ** 2) ** (1/2))
S = sum(Q) * (2 * f[N-1])
print(S / f[N])

Measured memory_bytes: 3188
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var W = cin.ReadInt;
            var H = cin.ReadInt;
            var x = cin.ReadInt;
            var y = cin.ReadInt;

            double ans1 = (double)W * (double)H / 2.0;
            int ans2 = (W % 2 == 0 && H % 2 == 0 && W / 2 == x && H / 2== y) ? 1 : 0;
            Console.WriteLine(ans1 + " " + ans2);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if (a+b == 15)cout << "+"<<endl;
    else if (a*b == 15)cout << "*" << endl;
    else cout << "x" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
if(c>=a&&c>=b){printf("%d",c*10+b+a);}
  else if(b>=a&&b>=c){printf("%d",b*10+c+a);}
    else if(a>=b&&a>=c){printf("%d",a*10+c+b);}
  return 0;
}

Measured memory_bytes: 128
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S;
    cin >> S;
    string res = "";
    int N = S.size();
    int i = 0;
    while(i < N) {
        char c = S[i];
        res += c;
        int j = 1;
        while(c == S[i+j]) {
            j++;
        }
        i += j;
    }
    map<char,int> mp;
    for(char c:res) {
        if(mp.count(c)) mp[c]++;
        else mp[c] = 1;
    }
    int ans;
    if(mp['W'] == 0 || mp['B'] == 0) ans = 0;
    else ans = mp['W'] + mp['B']-1;
    cout << ans << endl;
}


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

int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    stack<char> st;
    st.push(S[0]);
    for (ll i=1; i<N; i++) {
        if (st.top()!=S[i]) {
            st.push(S[i]);
        }
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*8
#define ll long long
#define mod 1000000007

pair<ll,ll> q[nn];ll ql,qr;
ll n;ll s;
vector<ll> dq[nn];
ll ans=0;ll lst;
void dfs(ll x)
{
	ans+=abs(q[x].first-lst);lst=q[x].first;
	reverse(dq[x].begin(),dq[x].end());
	for(int i=0;i<dq[x].size();i++)
		dfs(dq[x][i]);
}
int main()
{
	scanf("%lld%lld",&n,&s);
	for(ll i=1;i<=n;i++)
	{
		scanf("%lld%lld",&q[i].first,&q[i].second);
		q[i].first-=s;
	}
	sort(q+1,q+n+1);ql=1,qr=n;int tl=-1;
	while(ql<=qr)
	{
		if(((q[ql].first<=0)^(q[qr].first<=0)));
		else
		{
			lst=0;
			if(q[ql].first>0)
				for(ll i=ql;i<=qr;i++) 
					dfs(i);
			else
				for(ll i=qr;i>=ql;i--) 
					dfs(i);
			break;
		}
		if(q[ql].second>=q[qr].second)
		{
			dq[ql].push_back(qr);
			q[ql].second+=q[qr].second;qr--;
		}
		else if(q[ql].second<q[qr].second)
		{
			dq[qr].push_back(ql);
			q[qr].second+=q[ql].second;ql++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 15736
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int M = 10000;

    // 10000 以下の素数リストを作る
    vector<bool> isPrime(M+1, true);
    isPrime[1] = false;

    for (int i = 2; i <= M; i++) {
        for (int j = 2; j*j <= i; j++) {
            if (i%j == 0) isPrime[i] = false;
        }
    }

    int N;
    while (cin >> N)
    {
        int count = 0;
        for (int i = 1; i <= N; i++) {
            if (isPrime[i] && isPrime[N-i+1]) count++;
        }

        cout << count << endl;
    }
}

Measured memory_bytes: 1196
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    from functools import reduce
    def gcd(*numbers):
        return reduce(math.gcd, numbers)
    n = I()
    lst = LI()
    ans = gcd(*lst)
    print(ans)
main()            


Measured memory_bytes: 21388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using vl = vector<long long>;
using P = pair<long long,long long>;
 
int main(){
	ll n,m; cin >> n >> m;
	vl a(n); rep(i,n)cin >> a[i];
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	double sum = 0; rep(i,n)sum += a[i];
	a[m-1] >= sum/(4*m) ? cout << "Yes" << endl : cout << "No" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations_with_replacement
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, m, q = map(int, input().split())
    abcd = [None] * q
    for i in range(q):
        abcd[i] = tuple(map(int, input().split()))

    A = list(range(m))
    ans = 0
    comb = list(combinations_with_replacement(A, n))
    for c in comb:
        tmp_ans = 0
        for i in range(q):
            if c[abcd[i][1]-1] - c[abcd[i][0]-1] == abcd[i][2]:
                tmp_ans += abcd[i][3]
        ans = max(ans, tmp_ans)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 21916
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

		if (N % 3 == 0) {
			System.out.println(N / 3);
		} else {
			if (N % 3 > 3) {
				System.out.println((int)Math.ceil(N/3));
			} else {
				System.out.println((int)Math.floor(N/3));
			}
		}



	}
}


Measured memory_bytes: 21844
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

Q,H,S,D = inpl()
N = int(input())
L0_5 = min(Q*2,H)
L1   = min(L0_5*2,S)
L2 = min(L1*2,D)
ans = N//2 * L2 + (N%2) * L1
print(ans)


Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());

    int alice = 0;
    int bob = 0;
    rep(i, n){
        if(i % 2 == 0) alice += a[i];
        else bob += a[i];
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
n = int(input())
ans_dic = dict.fromkeys([i for i in range(1, 10**5)], 0)
for i in range(1, 10**2 + 1):
    for j in range(1, 10**2 + 1):
        for k in range(1, 10**2 + 1):
            tryvalue = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if tryvalue <= 10**4 + 3:
                ans_dic[tryvalue] += 1
for l in range(1, n + 1):
    print(ans_dic[l])


Measured memory_bytes: 20504