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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n,k; cin >> n >>k ;
    int mini =1000000010;
    vi h(n); rep(i,n) cin>> h[i];
    sort(all(h));
    rep(i,n-k+1) {
        if(h[i+k-1]-h[i] < mini) mini = (h[i+k-1]-h[i]);
    }
    cout << mini << '\n';
}

Measured memory_bytes: 640
using System;

class Program
{
	static void Main(string[] args)
    {
    	var input = Console.ReadLine().Split(' ');
        var Alice = input[0];
        var Bob = input[1];
        var card = new string[] {"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "1"};
        Console.WriteLine(Array.IndexOf(card, Alice) > Array.IndexOf(card, Bob) ? "Alice" : Alice == Bob ? "Draw" : "Bob");
		
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  using vi = vector<int>;
  using vvi = vector<vi>;
  vvi vec(N, vi(2 * N));
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  	for (int j = 0; j < 2 * A.at(i); j++) {
      	cin >> vec.at(i).at(j);
  	}
  }
  int res = 0;
  for(int bit = 0; bit < (1 << N); bit++){
    bool outer = true;
    for(int i = 0; i < N; i++){
      	bool innerf = true;
    	if(bit & (1 << i)){
        	for(int j = 0; j < 2 * A.at(i); j += 2){
            	int x = vec.at(i).at(j);
              	int y = vec.at(i).at(j+1);
              	if(y){
                	if(!(bit & (1 << (x-1)))){
                    	innerf = false;
                      	break;
                    }
                }
              	else{
                	if(bit & (1 << (x-1))){
                    	innerf = false;
                      	break;
                    }
                }
            }        	
        }
      	if(!innerf){
          	outer = false;
        	break;
        }
    }
    if(outer){
    	res = max(res, __builtin_popcount(bit));
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#!/usr/bin/ruby
#
# 1030.rb: Cubes Without Holes
#

require 'set'

### main

szero = Set.new

loop do
  n, h = gets.split.map(&:to_i)
  break if n == 0 && h == 0

  xy = {}
  yx = {}
  yz = {}
  zy = {}
  zx = {}
  xz = {}

  num = n ** 3

  h.times do
    pl, a, b = gets.split

    case pl
    when "xy"
      x = a.to_i
      y = b.to_i

      xy[x] = Set.new if xy[x].nil?
      yx[y] = Set.new if yx[y].nil?
      xy[x] << y
      yx[y] << x

      sxz = xz[x] || szero
      syz = yz[y] || szero
      sxyz = sxz & syz

      num -= n - sxz.size - syz.size + sxyz.size
    when "xz"
      x = a.to_i
      z = b.to_i

      xz[x] = Set.new if xz[x].nil?
      zx[z] = Set.new if zx[z].nil?
      xz[x] << z
      zx[z] << x

      sxy = xy[x] || szero
      szy = zy[z] || szero
      sxzy = sxy & szy

      num -= n - sxy.size - szy.size + sxzy.size
    when "yz"
      y = a.to_i
      z = b.to_i

      yz[y] = Set.new if yz[y].nil?
      zy[z] = Set.new if zy[z].nil?
      yz[y] << z
      zy[z] << y

      syx = yx[y] || szero
      szx = zx[z] || szero
      syzx = syx & szx

      num -= n - syx.size - szx.size + syzx.size
    end
  end

  puts num
end

Measured memory_bytes: 6532
#include <iostream>

int main(void) {
  int H, W; //行, 列
  std::cin >> H >> W;
  char s[W][H];  //座標
  int i,j;
  for(i=0; i<W; i++) {
    for(j=0; j<H; j++) {
      std::cin >> s[i][j];
    }
  }

  bool judge = false; //No->true, Yes->false
  for(i=0; i<W; i++) {
    for(j=0; j<H; j++) {
      if(s[i][j]==0x23) {
        if(!(s[i][j-1]==0x23||s[i+1][j]==0x23||s[i][j+1]==0x23||s[i-1][j]==0x23)){
          judge = true;
        }
      }
    }
    if(judge) {
      break;
    }
  }

  if(judge) {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
  }
  
  return 0;
}

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

int main() {
  int N,Z=0;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  vector<int> q(N);
  for(int i=N-1;i>=0;i--){
    int A=0;
    for(int j=i*2+1;j<N;j+=i+1){
      A+=q.at(j);
    }
    if((A+p.at(i))%2==1){
      q.at(i)=1;
      Z++;
    }
  }
  cout<<Z<<endl;
  for(int k=0;k<N;k++){
    if(q.at(k)==1){
      cout<<k+1<<endl;
    }
  }
}

Measured memory_bytes: 2432
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	string L = "qwertasdfgzxcvb",
		R = "yuiophjklnm";
	for (string s; cin >> s&&s != "#";) {
		int cnt = 0;
		bool l = (L.find(s[0]) != string::npos) ? true : false;
		for (int i = 0; i < s.size(); i++) {
			if (R.find(s[i]) != string::npos && l) {
				cnt++;
				l = false;
			}
			else if (L.find(s[i]) != string::npos && !l) {
				cnt++;
				l = true;
			}
		}
		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
/**
 *    author:  Mohamad Milhem
 *    created: 2020-01-26-19.28.52
**/

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;

int main(){

    FAST;

    double a,b;

    cin >> a >> b;

    cout << (int)(ceil(a/b)) << endl;

    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



int main(){
   int n,k; cin>>n>>k;
   vector<int> p(n),c(n);
   rep(i,0,n)cin>>p[i],p[i]--;
   rep(i,0,n)cin>>c[i];
   ll res=-INF;
   rep(i,0,n){
      int cur=p[i];
      vector<int> cir={c[i]};
      while(cur!=i){
         cir.push_back(c[cur]);
         cur=p[cur];
      }
      int m=cir.size();
      ll sum=0,add=0;
      for(auto& x:cir)sum+=x;
      chmax(sum,0LL);
      rep(j,0,m){
         add+=cir[j];
         int rem=k-(j+1);
         if(rem<0)break;
         chmax(res,(rem/m)*sum+add);
      }
   }
   cout<<res<<endl;
   return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, dp[1000008][3], lazy[1000008];

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    cin >> n;
    dp[0][0] = 1;

    ll comp = 0;
    rep(i, 1, n){
        lazy[i] += lazy[i-1]; lazy[i] %= MOD;
        dp[i][0] += lazy[i]; dp[i][0] %= MOD;
        dp[i][0] += dp[i-1][0]; dp[i][0] %= MOD;
        dp[i][1] += lazy[i]; dp[i][0] %= MOD;
        dp[i][1] += dp[i-1][0]; dp[i][1] %= MOD;
        dp[i][2] += dp[i-1][1]*(n-1)%MOD; dp[i][2] %= MOD;
        dp[i][2] += dp[i-1][2]; dp[i][2] %= MOD;

        if(i+2 <= n){
            lazy[i+2] += dp[i-1][1]; lazy[i+2] %= MOD;
        }

        if(i < n){
            comp += dp[i-1][1]*i%MOD; comp %= MOD;
        }
        else{
            comp += dp[i-1][1]*(i-1)%MOD; comp %= MOD;
        }
        //print(comp)
    }

    //rep(i, 0, n)cout << dp[i][0] << dp[i][1] << dp[i][2] << endl;
    print((dp[n][0]+dp[n][1]*(n-1)%MOD+dp[n][2]*(n-1)%MOD+comp)%MOD)
    return 0;
}

Measured memory_bytes: 31488
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X, A, B = map(int, read().split())

    X -= A
    ans = X - (X // B) * B
    print(ans)

    return


if __name__ == '__main__':
    main()


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

int main(){

    int N;
    cin >> N;

    long int A[100010];
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }

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

    sort(A, A+N);

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

    long int ans1 = 0;
    long int ans2 = 0;
    int left, right;
    int itr_l, itr_r;

    long int B[100010];
    bool state = false;

    B[N/2] = A[0];
    left = N/2 - 1;
    right = N/2 + 1;
    itr_l = 1;
    itr_r = N - 1;
    for (int i=1; i<(N+2)/2; i++) {
        if (state) {
            if (left >= 0) {
                B[left] = A[itr_l];
                left--;
                itr_l++;
            }
            if (right < N) {
                B[right] = A[itr_l];
                right++;
                itr_l++;
            }
        } else {
            if (left >= 0) {
                B[left] = A[itr_r];
                left--;
                itr_r--;
            }
            if (right < N) {
                B[right] = A[itr_r];
                right++;
                itr_r--;
            }
        }
        state = !state;
    }


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

    for (int i=1; i<N; i++) {
        ans1 += abs(B[i] - B[i-1]);
    }

    B[N/2] = A[N-1];
    left = N/2 - 1;
    right = N/2 + 1;
    itr_l = 0;
    itr_r = N - 2;
    state = true;
    for (int i=1; i<(N+2)/2; i++) {
        if (state) {
            if (left >= 0) {
                B[left] = A[itr_l];
                left--;
                itr_l++;
            }
            if (right < N) {
                B[right] = A[itr_l];
                right++;
                itr_l++;
            }
        } else {
            if (left >= 0) {
                B[left] = A[itr_r];
                left--;
                itr_r--;
            }
            if (right < N) {
                B[right] = A[itr_r];
                right++;
                itr_r--;
            }
        }
        state = !state;
    }


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

    for (int i=1; i<N; i++) {
        ans2 += abs(B[i] - B[i-1]);
    }

    // cout << "ans1 : " << ans1 << endl;
    // cout << "ans2 : " << ans2 << endl;

    if (ans1 > ans2) {
        cout << ans1 << endl;
    } else {
        cout << ans2 << endl;
    }

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1) 

const ll INF = 10010001010;
const int inf = 2000000000;


typedef tuple<string, int, int> TUP;

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

int main()
{
    int N, M;
    cin >> N;
    vector<string> S(N);

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }
    cin >> M;
    vector<string> T(M);
    for (int i = 0; i < M;i++)
    {
        cin >> T[i];
    }
    for (int i = 0; i < N;i++)
    {
        int pre = 0;
        for (int j = 0; j < N; j++)
        {
            if(S[i] == S[j]){
                pre++;
            }
        }
        for (int j = 0; j < M;j++)
        {
            if(S[i] == T[j]){
                pre--;
            }
        }
        ans = max(ans,pre);
    }
    cout << ans << endl;
}


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

int main(){
   int N, M;
   cin >> N >> M;
   int H[N];
   vector<int> g[N];
   rep(i, N) cin >> H[i];
   int a, b;
   rep(i, M){
       cin >> a >> b;
       a--; b--;
       g[a].push_back(b);
       g[b].push_back(a);
   }
   int ans = 0;
   rep(i, N){
       bool flag = true;
       for(int j:g[i])if(H[i] <= H[j]) flag = false;
       if(flag) ans++;
   }
   cout << ans << endl;


}

Measured memory_bytes: 9144
#create date: 2020-08-02 21:08

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    c = ns()
    n_r = c.count("R")
    print(c[n_r:].count("R"))

if __name__ == "__main__":
    main()

Measured memory_bytes: 63180
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int n, k, a[100];
int dp[100001];

bool f(int k)
{
    if (dp[k] != -1) return dp[k];
    for (int i = 0; i < n; ++i)
        if (k >= a[i] && !f(k - a[i]))
            return dp[k] = 1;
    return dp[k] = 0;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    memset(dp, -1, sizeof dp);
    cout << (f(k) ? "First" : "Second");
}


Measured memory_bytes: 3712
#include<stdio.h>
#include<algorithm>
using namespace std;
long long n,m,i,w=0;
int main(void)
{
	scanf("%lld %lld",&n,&m);
	if(n*2<=m){
		w+=n;
		m-=n*2;
		w+=m/4;
	}
	else{
		w+=m/2;
	}
	printf("%lld\n",w);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
	int a, b;
	scanf("%d", &a); scanf("%d", &b);
	if (a < b)
	{
		printf("a < b\n");
	}

	if (a > b)
	{
		printf("a > b\n");
	}

	if (a == b)
	{
		printf("a == b\n");
	}
	return 0;
}

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


int main(){
	int n,cnt=0;
	string s;
	cin >> n >> s;
	
	for(int i=0;i<n-2;i++){
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') cnt++;
	}
	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        aldl_1_1_a();
    }


    static void aldl_1_1_a() {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        ArrayList<Integer> data = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            data.add(sc.nextInt());
        }
        sc.close();

        for (int i = 0; i < n; i++) {
            int j = i - 1;
            int v = data.get(i);
            while (j >= 0 && data.get(j) > v) {
                data.set(j + 1, data.get(j));
                j--;
            }
            data.set(j + 1, v);
            for (int k = 0; k < n; k++) {
                if (k > 0)
                    System.out.print(" ");
                System.out.print(data.get(k));
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34180
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define ll long long
#define mod 1000000007LL
#define INF 123456789012345
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e4 + 10;

int a[200005];

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

	rep(i,n)
	{
		int tmp;cin>>tmp;
		a[i] = tmp - i-1;
	}

	sort(a,a+n);

	ll ans = 0;
	int b = a[n/2];

	rep(i,n) ans +=abs(a[i]-b);

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    long long int N,H,W,i,j,k,ans,count,cost,tmp;
    long long int S[200010];
    long long int Ssum[200010];
    string T;
    bool flag;
    count=0;
    ans=std::pow(10,18);
    flag=false;
    cin >>N>>H;
    
        if (N*500<H){
            
            cout <<"No" <<endl;
        }
        else{
            cout <<"Yes" <<endl;
        }
    
    

    
    

    return 0;
    
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
bool flag;
string s;
int main() {
	ios::sync_with_stdio(false);
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'C')
			flag = 1;
		if(flag && s[i] == 'F') {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

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

#include <atcoder/all>
typedef long long lint;
using namespace std;
using namespace atcoder;

int main() {
    string s;
    cin >> s;
    lint n = s.size();
    lint ans = n * (n + 1) / 2;
    auto sa = suffix_array(s);
    for (auto e : lcp_array(s, sa)) {
        ans -= e;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15668
#include<queue>
#include<cstdio>
#include<algorithm>

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

using namespace std;

template<class T>
class d_heap{
	static const int N_MAX=3000; // !!
	int n,d;
	T a[N_MAX];
public:
	d_heap(int d):n(0),d(d){}
	const T &find_min()const{ return a[0]; }
	void insert(const T &x){
		int u=n++;
		a[u]=x;
		while(u!=0 && a[(u-1)/d]>a[u]) swap(a[(u-1)/d],a[u]), u=(u-1)/d;
	}
	void delete_min(){
		a[0]=a[--n];
		for(int u=0;;){
			int v=u;
			for(int w=d*u+1;w<=d*u+d;w++) if(w<n && a[v]>a[w]) v=w;
			if(v==u) break;
			swap(a[v],a[u]);
			u=v;
		}
	}
	bool empty()const{ return n==0; }
	int size()const{ return n; }
};

#define define_heap d_heap< pair<int,int> > H(7);

const int INF=1<<29;

struct edge{ int v,cost1,cost2; };

int main(){
	for(int m,n;scanf("%d%d",&m,&n),n;){
		vector<edge> G[100];
		rep(i,m){
			int u,v,cost1,cost2; scanf("%d%d%d%d",&u,&v,&cost1,&cost2); u--; v--;
			G[u].push_back((edge){v,cost1,cost2});
			G[v].push_back((edge){u,cost1,cost2});
		}

		int q; scanf("%d",&q);
		while(q--){
			int s,t,type; scanf("%d%d%d",&s,&t,&type); s--; t--;

			int d[100];
			rep(u,n) d[u]=(u==s?0:INF);
			define_heap;
			H.insert(make_pair(0,s));
			while(!H.empty()){
				int d_now=H.find_min().first,u=H.find_min().second;
				H.delete_min();

				if(d[u]<d_now) continue;

				rep(i,G[u].size()){
					const edge &e=G[u][i];
					int d2=d_now+(type==0?e.cost1:e.cost2);
					if(d[e.v]>d2){
						d[e.v]=d2;
						H.insert(make_pair(d2,e.v));
					}
				}
			}

			printf("%d\n",d[t]);
		}
	}

	return 0;
}

Measured memory_bytes: 1168
-- Question C 

import Control.Applicative
import Control.Monad

main = do
  n <- readLn ::IO Int
  xs <- map read . words <$> getLine
  putStrLn $ check xs n
  
check :: [Int] -> Int -> String
check xs n
  | (m4th + 1 == oddth ) && (m4th + oddth == n) = "Yes"
  | m4th >= oddth  = "Yes"
  | otherwise = "No"
  where m4th = length (filter (\p -> p `mod` 4 == 0) xs)
        oddth = length (filter odd xs)
  




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

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

    vector<int> vecD(n);
    for(int i=0; i<n; i++) cin >> vecD.at(i);

    sort(vecD.begin(), vecD.end());
    int strt = vecD.size()/2 - 1;
    int end = strt + 1;
    int ans = vecD[end] - vecD[strt];

    ans = (vecD.size() % 2) ? 0 : ans;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define pi 3.14159265358979323846264338327950L
int main()
{
        fast;
        int t=1;
        //cin>>t;
        while(t--)
        {
                ll a[3],value[3],k,ans=0;
                cin>>a[0]>>a[1]>>a[2]>>k;
                value[0]=1;
                value[1]=0;
                value[2]=-1;
                for(int i=0;i<3;i++)
                {
                        if(a[i]<=k)
                        {
                                ans+=(a[i])*value[i];
                                k-=a[i];
                        }
                        else
                        {
                                ans+=k*value[i];
                                break;
                        }

                }
                cout<<ans<<endl;

        }
}

Measured memory_bytes: 3640
using System;

class Tenka_A{
  static void Main(){
    int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int H1 = Ar[0], H2 = Ar[1], H3 = Ar[2];
    if ((H1 < H3 && H2 > H3) || (H1 > H3 && H2 < H3)) Console.WriteLine("Yes");
    else Console.WriteLine("No");
  }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdlib>
#include<deque>
#include<stack>
#include<map>
#include<set>
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
ll n;
ll a[55];
ll dp[55][55][105];
bool vis[55][55][105];
ll fun(int l, int r, int k)
{
    if (l>r)
    return 1e-11;
    if (vis[l][r][k])
        return dp[l][r][k];
    ll sum=0;
    ll cnt=k;
    vector<ll>v;
    for (int i=1;i<=l;i++)
    {
        v.push_back(a[i]);
        sum+=a[i];
    }
    if (l==r)
    for (int i=n;i>r;i--)
    {
        v.push_back(a[i]);
        sum+=a[i];
    }
    else
      for (int i=n;i>=r;i--)
    {
        v.push_back(a[i]);
        sum+=a[i];
    }
    sort(v.begin(),v.end());
    int j=0;
    while (j<v.size() && cnt>0 && v[j]<0)
    {
        sum-=v[j];
        j++;
        cnt--;
    }
    if (k>0)
    sum=max(sum,fun((l+1),r,k-1));
    if (k>0)
    sum=max(sum,fun(l,r-1,k-1));
    vis[l][r][k]=true;
   // cout<<sum<<' '<<l<<' '<<r<<' '<<k<<endl;
    return dp[l][r][k]=sum;

}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin>>n>>k;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    //a[0]=0,a[n+1]=0;
    //memset(vis,false,sizeof(vis));
    ll ans=fun(0,n+1,k);
   // ans=max(0,ans);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1920
open Printf
open Str

let inputs string =
	let l_of_str = Str.split (Str.regexp " ") string in
	let nums = Array.of_list (List.map int_of_string l_of_str) in
	let hms nums =
		let cnt = ref 0 in
		for i=nums.(0) to nums.(1) do	
			if 0 = (nums.(2) mod i) then cnt := (!cnt+1)
		done;
		printf "%d\n" !cnt in
	hms nums;;


let s = read_line() in
	inputs s;;

Measured memory_bytes: 2340
import java.util.*;
public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String[] code = new String[n];
    boolean flg = false;
    String ans = "Yes";
    for(int i=0;i<n;i++){
        code[i] = sc.nextLine();
        if(i != 0 && !code[i].substring(0, 1).equals(code[i-1].substring(code[i-1].length() - 1, code[i-1].length()))){
            ans = "No";
            break;
        }
        for(int j=0;j<i;j++){
            if(code[i].equals(code[j])){
              ans = "No";
                flg = true;
                break;
            }
        }
        if(flg){
            break;
        }
    }
    System.out.println(ans);
	}
}

Measured memory_bytes: 23764
# すぬけくんは N 本の棒を持っています。 
# i 番目の棒の長さは li です。
# すぬけくんは K 本の棒を選んでつなげて、ヘビのおもちゃを作りたいです。
# ヘビのおもちゃの長さは選んだ棒たちの長さの総和で表されます。
# ヘビのおもちゃの長さとしてありうる長さのうち、最大値を求めなさい。

# 持っている棒の本数、つなげる棒の本数を取得
line_1 = gets.chomp.split
n = line_1[0].to_i
k = line_1[1].to_i

# 全ての棒の情報を取得
line_2 = gets.chomp.split
rods = Array.new
n.times do |i|
  rods << line_2[i].to_i
end

# 棒を長さ順（昇順）に並び替える
rods.sort!

# つなげてできるヘビのおもちゃの長さを格納する変数を宣言
snake = 0

# 棒をつなげる
k.times do |i|
  snake += rods[n - i - 1]
end

# 結果を出力
puts snake

Measured memory_bytes: 1788
def orderN(N,L,ices):
    upPeak = L - ices[0]
    downPeak = L - ices[0]
    peaks = []
    append = peaks.append
    for i in xrange(len(ices)):
        if i < N-1:
            if ices[i] < ices[i+1]:
                append(downPeak)
                downPeak = L - ices[i+1]
                upPeak += L - ices[i+1]
            else:
                append(upPeak)
                upPeak = L - ices[i+1]
                downPeak += L - ices[i+1]
        else:
            append(upPeak)
            append(downPeak)
    print(max(peaks))

N,L = map(int,raw_input().strip().split())
ices = [int(raw_input().strip()) for _ in xrange(N)]

orderN(N,L,ices)

Measured memory_bytes: 12448
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(mpr) printf(#mpr "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    int n, inp, sum = 0, MAX = 0;
    cin >> n;
    REP(i, n){
        cin >> inp;
        sum += inp;
        MAX = max(MAX, inp);
    }

    cout << sum-(MAX/2) << endl;
}


Measured memory_bytes: 256
def func(s,x):
    last=[0]*26
    score=0
    for i,v in enumerate(x,1):
        last[v]=i
        c=0
        for j in range(26):
            c+=s[j]*(i-last[j])
        score=score+s[i*26+v]-c
        print(score)
    return score
def main():
    d,*s=map(int,open(0).read().split())
    func(s,[t-1for t in s[-d:]])
main()

Measured memory_bytes: 68176
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuLCM solver = new AizuLCM();
        solver.solve(1, in, out);
        out.close();
    }

    static class AizuLCM {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            long p = 1L;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                p *= a[i];
            }

            int g = 0;
            int l = 0;
            if (n == 1) {
                g = a[0];
            } else {
                g = gcd(a[0], a[1]);
                l = (a[0] * a[1]) / g;

                for (int i = 2; i < n; i++) {
                    g = gcd(l, a[i]);
                    l = (l * a[i]) / g;
                }
            }

            out.printf("%d\n", l);
        }

        private int gcd(int x, int y) {
            while (y != 0) {
                int t = x % y;
                x = y;
                y = t;
            }

            return x;
        }

    }
}




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

int main()
{
    char c;
    cin  >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

const int MAX_N = 1000;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

int R, G, B;

void solve() {
  int num = 100 * R + 10 * G + B;
  if (num % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

int main() {
  cin >> R >> G >> B;

  solve();

  return 0;
}


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

using namespace std;

char m[100][100];

int ans[100][100];

int main()
{
    int h, w; cin >> h >> w;

    for (int i = 0; i < h; ++i) scanf("%s", m[i]);

    memset(ans, -1, sizeof(ans));

    for (int i = 0; i < h; ++i) {
        for (int j = w - 1; j >= 0; --j) {
            for (int k = j; k >= 0; --k) {
                if (m[i][k] == 'c') {
                    ans[i][j] = j - k;
                    break;
                }
            }
        }
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) printf(j == 0 ? "%d" : " %d", ans[i][j]);
        printf("\n");
    }
}

Measured memory_bytes: 1232
#include <stdio.h>

int count[10001], array[2000000], out[2000000];
void Counting_Sort(int in[], int out[], int len, int max){
    int i, j;
    for (i = 0;i < len;i++) count[in[i]]++;
    count[0]--;
    for (i = 1;i <= max;i++) count[i] += count[i - 1];
    for (i = len - 1;i >= 0; i--) {
        out[count[in[i]]] = in[i];
        count[in[i]]--;
    }
    return;
}

int main(){
    int n, i;
    scanf("%d", &n);
    for (i = 0;i < n;i++)  scanf("%d", array + i);
    Counting_Sort(array, out, n, 10000);
    
    for (i = 0;i < n - 1;i++) printf("%d ", out[i]);
    printf("%d\n", out[i]);
    
    return 0;
}

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

int main()
 {
    string s;
    cin>>s;
    int count(0),len,i(0);
    len = s.length();
    while(i < len){
    	if(s[i] != s[i+1]){	i++; count++;}
    	else{
    		if(len-i >= 3)
    		{count += 2;
    		i += 3;}
    		else	{count++; i += 2;}
    	}
    }
    cout<<count<<endl;
	return 0;
}


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

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

    long long sum_i = 0;
    long long i = 0;
    while (sum_i < x)
    {
        i += 1l;
        sum_i += i;
    }

    cout << i << endl;
}

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

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <string> s(n);
  vector <vector <int> > g(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < n; j++) {
      if (s[i][j] == '1') {
        g[i].push_back(j);
      }
    }
  }
  int ans = -1;
  for (int i = 0; i < n; i++) {
    queue <int> q;
    q.push(i);
    vector <int> dist(n, -1);
    dist[i] = 0;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int to : g[v]) {
        if (dist[to] == -1) {
          dist[to] = dist[v] + 1;
          q.push(to);
        }
      }
    }
    bool bad = false;
    for (int i = 0; i < n; i++) {
      for (int to : g[i]) {
        if (abs(dist[i] - dist[to]) != 1) {
          bad = true;
        }
      }
    }
    if (!bad) {
      ans = max(ans, *max_element(dist.begin(), dist.end()) + 1);
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

struct P{
	double x;
	double y;
	double z;
	double r;
};

const double inf = 999999;

double calc(double s, double t)
{
	return (s-t)*(s-t);
}

double func(P s, P t)
{
	double r = s.r + t.r;
	double d = sqrt(calc(s.x, t.x) + calc(s.y, t.y) + calc(s.z, t.z));
	
	return ((r >= d)? 0.0: (d-r));
}

double prim(double a[101][101], int n)
{
	double cost[101], r = 0.0;
	bool vis[101];
	fill(cost, cost+n, inf);
	fill(vis, vis+n, true);
	cost[0] = 0.0;
	
	while(1){
		int v = -1;
		for(int i = 0; i < n; i++){
			if(vis[i] && (v == -1 || cost[i] < cost[v])){
				v = i;
			}
		}
		
		if(v == -1){
			break;
		}
		vis[v] = false;
		r += cost[v];
		
		for(int i = 0; i < n; i++){
			cost[i] = min(cost[i], a[v][i]);
		}
	}
	
	return r;
}

int main()
{
	int n;
	P pt[101];
	double a[101][101];
	while(cin>>n && n){
		fill(&a[0][0], &a[n][n], inf);
		for(int i = 0; i < n; i++){
			cin >> pt[i].x >> pt[i].y >> pt[i].z >> pt[i].r;
			a[i][i] = 0;
		}
		
		for(int i = 0; i < n; i++){
			for(int j = i+1; j < n; j++){
				a[i][j] = a[j][i] = func(pt[i], pt[j]);
			}
		}
		
		printf("%.3f\n", prim(a, n));
	}
	
	return 0;
}

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

namespace 練習１
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = new int[]{ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

            var y = int.Parse(Console.ReadLine());

            Console.WriteLine(x[y-1] + "");
        }
    }
}

Measured memory_bytes: 13140
from bisect import*
class SqrtSet:
    def __init__(self,block_limit=201):
        self.key=[]
        self.child=[[]]
        self.block_limit=block_limit
    def search_lower(self,key):
        if not key:return None
        ret=None
        i=bisect_left(self.key,key)
        if i:ret=self.key[i-1]
        block=self.child[i]
        i=bisect_left(block,key)
        if i:ret=block[i-1]
        return ret
    def search_higher(self,key):
        if not key:return None
        ret=None
        i=bisect(self.key,key)
        if i<len(self.key):ret=self.key[i]
        block=self.child[i]
        i=bisect(block,key)
        if i<len(block):ret=block[i]
        return ret
    def insert(self,key):
        i=bisect(self.key,key)
        block=self.child[i]
        insort(block,key)
        if len(block)==self.block_limit:
            sep=self.block_limit//2
            self.key.insert(i,block[sep])
            self.child.insert(i+1,block[sep+1:])
            self.child[i]=block[:sep]
def main():
    n,*a=map(int,open(0).read().split())
    l=[0]*n
    for i,v in enumerate(a,1):l[v-1]=i
    t=SqrtSet()
    t.insert(0)
    t.insert(n+1)
    c=0
    for i,v in enumerate(l,1):
        c+=(t.search_higher(v)-v)*(v-t.search_lower(v))*i
        t.insert(v)
    print(c)
main()

Measured memory_bytes: 25884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;

int main(){
    ll n,q;
    cin>>n>>q;
    vector<tuple<ll,ll,ll>> event;
    rep0(i,n){
        ll s,t,x;
        cin>>s>>t>>x;
        event.push_back(make_tuple(s-x,1,x));
        event.push_back(make_tuple(t-x,-1,x));
    }
    rep0(j,q){
        ll d;
        cin>>d;
        event.push_back(make_tuple(d,longinf,longinf));
    }
    sort(event.begin(),event.end());
    set<ll> st;
    vector<ll> ans;
    for(auto e:event){
        auto a=get<1>(e);
        if(a==1){
            auto x=get<2>(e);
            st.insert(x);
        }
        else if(a==-1){
            auto x=get<2>(e);
            st.erase(x);
        }
        else{
            auto d=get<0>(e);
            if(st.size()){
                auto x=*(st.begin());
                ans.push_back(x);
            }
            else{
                ans.push_back(-1);
            }
        }
    }
    for(auto a:ans){
        cout<<a<<endl;
    }
    return 0;
}

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

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> d(n);
    d[0] = 0;
    rep(i,n){
        int a;
        cin >> a;
        d[i+1] = d[i] + a;
    }
    int ans = 0;
    rep(i,n+1){
        if(d[i] <= x){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3580
(defun solver ()
  (let* ((n (read)) (scores (make-array n :fill-pointer 0)) (total 0))
  (loop repeat n do
  (let ((si (read)))
  (vector-push si scores) (incf total si)))
  (sort scores #'<)
  (if (/= (mod total 10) 0)
      (format t "~A~%" total)
      (progn (loop for i from 0 below n do
                (let ((temp (- total (aref scores i))))
                (unless (zerop (mod temp 10)) (return (format t "~A" temp))))
                finally (format t "0~%"))))))

(solver)

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

long long int calc(vector<int>D) {

	long long int ret = 0, count = 0;
	for(auto x : D) {
		if(x == 1) {
			ret += count;
		} else if(x == 0) {
			count = 0;
		} else {
			count++;
		}
	}
	return ret;
}

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

	vector<int>D;
	D.emplace_back(0);
	char prev = 'A';
	for(auto c : S) {
		if(c == 'A') {
			if(prev == 'B') {
				D.emplace_back(0);
			}
			D.emplace_back(2);
		} else if(c == 'B') {
			if(prev == 'B') {
				D.emplace_back(0);
			}
		} else {
			if(prev == 'B') {
				D.emplace_back(1);
			} else {
				D.emplace_back(0);
			}
		}
		prev = c;
	}
	D.emplace_back(0);
	cout << calc(D) << endl;
}

Measured memory_bytes: 2168
#include<stdio.h>
#include<math.h>

int main(){
    double X;
    double dep = 100;
    double itr = 0.01;
    int cnt = 0;

    scanf("%lf", &X);

    while(1){
        cnt++;
        dep += (floor)(dep * itr);
        if(dep >= X){
            break;
        }
    }

    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 1744
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

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

	int ans = 1;
	int max = arr[0];
	for (int i = 1; i < n; i++)
	{
		if (arr[i] >= max)
		{
			max = arr[i];
			ans++;
		}
	}

	cout << ans << endl;
}


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

int main() {
  int x;
  for (int i = 0; i < 5; i++) {
    cin >> x;
    
    if (x != 0)
      continue;
    
    else if (x == 0)
      cout << i + 1 << endl;
  }
}


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

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

	int correctCount = 0;

	for (int i = 0; i < 3; i++)
	{
		if (s[i] == t[i])
			correctCount++;
	}

	cout << correctCount;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    L = sorted(list(readnums()))
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            if L[i] == L[j]:
                continue
            for k in range(j + 1, N):
                if L[i] == L[k] or L[j] == L[k]:
                    continue
                if L[i] + L[j] > L[k]:
                    ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9200
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

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


//#define int ll

class BBounding {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int N, x;
    cin >> N >> x;
    rep(i,0,N){
        int t;
        cin >> t;
        x -= t;
        if(x < 0){
            cout << i + 1 << endl;
            return;
        }
    }
    cout << N + 1 << endl;
}
};


#undef int
int main() {
	BBounding solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        for (int i=0; i<5; i++) {
        	  a[i] = sc.nextInt();
        }
        if (a[2]+a[4] > a[0] || a[2]-a[4] < 0 || a[3]+a[4] > a[1] || a[3]-a[4] < 0) {
        	  System.out.println("No");
        } else {
        	  System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 26388
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 200500000000000
#define MOD 1000000007
#define N 100005
#define M 1000005
#define LOG 18
#define KOK 4000000
using namespace std;

int main() {

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

	char s[N];

	scanf("%s",s+1);

	int n=strlen(s+1);

	int ans=n;

	for(int i=1;i<=n;i++) {

		if(s[i]=='0') continue ;

		int bas=i;

		while(i+1<=n && s[i+1]=='1') i++;

		int l=bas-1<=0?i:bas-1;
		int r=i+1>n?n-bas+1:n-i;

		umin(ans,max(max(l,r),min(n-bas+1,i)));

	}

	printf("%d",ans);

}


Measured memory_bytes: 384
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();

        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

const M: usize = 1000000007;
const INV2: usize = 500000004;

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();

    let s = a.iter().fold(0, |acc, x| (acc + x) % M);
    let ss = a.iter().map(|aa| aa * aa).fold(0, |acc, x| (acc + x) % M);

    println!("{}", (s * s - ss + M) % M * INV2 % M);
}

Measured memory_bytes: 5784