akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
struct ed{int a,b,c;};
using P=pair<int,int>;

#include <vector>
#include <queue>
using namespace std;


struct dijkstra
{
  using P=pair<int,int>;
  priority_queue<P,vector<P>,greater<P>> q;
  vector<vector<P>>edge;
  vector<int>dist;
  int sz;
  dijkstra(int size){
    sz=size;
    edge.resize(size);
  }
  inline void reset(){
    dist.assign(sz,-1);
    q=priority_queue<P,vector<P>,greater<P>>();
  }
  void ae(int to,int from,int cost){
    edge[to].push_back({cost,from});
  }
  int cal(int start,int end){
    reset();
    q.push({0,start});
    while(!q.empty()){
      P tp=q.top();q.pop();
      if(dist[tp.second]!=-1)continue;
      dist[tp.second]=tp.first;
      for(P nn:edge[tp.second])
      {
        if(dist[nn.second]!=-1)continue;
        q.push({nn.first+tp.first,nn.second});
      }
    }
    return dist[end];
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<map<int, int>>num(n);
  vector<ed>es(m);
  rep(i,m)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;c--;
    es[i]={a,b,c};
    num[a][c];
    num[b][c];
  }
  int cnt=0;
  rep(i,n)
  {
    int tn=cnt++;
    for(auto &p:num[i])p.second=cnt++;
    num[i][-1]=tn;
  }
  dijkstra dj(cnt);
  rep(i,n)
  {
    int t=num[i][-1];
    for(auto p:num[i])
    {
      if(p.first==-1)continue;
      int tn=p.second;
      dj.ae(t,tn,1);
      dj.ae(tn,t,0);
    }
  }
  rep(i,m)
  {
    int to=num[es[i].a][es[i].c],from=num[es[i].b][es[i].c];
    dj.ae(to,from,0);
    dj.ae(from,to,0);
  }
  int start=num[0][-1],end=num[n-1][-1];
  cout<<dj.cal(start,end)<<endl;

  return 0;

}


Measured memory_bytes: 64116
#include <bits/stdc++.h>
// e.g. sort(all(a), [](int a1, int a2) { return a1 < a2; });
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool ok = true;
  // 回文である
  rep(i,n/2) {
    if (s[i] != s[n-1-i]) {
      ok = false;
    }
  }
  // s[0] から s[(n-1)/2] までが回文
  // i: 0~ (n-1)/2 - 1
  rep(i, n/4) {
    // auto a = s[i];
    // auto b = s[(n-1)/2-1-i];
    if (s[i] != s[(n-1)/2-1-i]) {
      ok = false;
    }
  }

  rep(i, n/4) {
    // auto a = s[i + (n+3) / 2 - 1];
    // auto b = s[n - 1 - i];
    if (s[i + (n+3) / 2 - 1] != s[n - 1 - i]) {
      ok = false;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
h,w = gets.split.map(&:to_i)
a = h.times.map{gets.chomp.split('')}

remove_h = []
a.each_with_index do |l, i|
  remove_h.push(i) if l.all?{|v| v == '.'}
end

remove_w = []
w.times do |i|
  flag = true
  a.each do |l|
    if l[i] == '#'
      flag = false
    end
  end
  if flag
    remove_w.push(i)
  end
end

a.each_with_index do |l,i|
  next if remove_h.include?(i)
  (0..(w-1)).each do |j|
    next if remove_w.include?(j)
    print l[j]
  end
  puts ''
end

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

int table[200005];
int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    rep(i,N){
        cin >> a[i+1];
    }
    vector<int> b(N+1);
    vector<int> ans;
    for(int i = N; i > 0 ; i--){
        int sum = 0;
        for(int j = i*2; j <= N; j += i){
            sum ^= b[j];
        }
        b[i] = sum ^ a[i];
        if(b[i])ans.push_back(i);
    }
    cout << ans.size() << endl;
    for(auto e : ans){
        cout << e << " ";
    }
    cout << endl;
    return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int L[M], R[M];
    rep(i, M){
        cin >> L[i] >> R[i];
    }

    int L_max = 1, R_min = N;
    rep(i, M){
        L_max = max(L_max, L[i]);
        R_min = min(R_min, R[i]);
    }
    // printf("%d\n", R_min - L_max+1);
    printf("%d\n", max(R_min - L_max+1, 0));
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
vector<llint> vec, avec;

void get(llint n)
{
	vec.clear();
	for(llint i = 2; i*i <= n; i++){
		if(n % i == 0){
			vec.push_back(i);
			if(i*i != n) vec.push_back(n/i);
		}
	}
	vec.push_back(n);
}

bool calc(llint k)
{
	llint t = n;
	while(k <= t){
		if(t % k == 0) t /= k;
		else t %= k;
	}
	return t == 1;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	llint ans = 0;
	get(n);
	for(int i = 0; i < vec.size(); i++){
		if(calc(vec[i])) ans++;
	}
	
	if(n > 2){
		get(n-1);
		for(int i = 0; i < vec.size(); i++){
			if(calc(vec[i])) ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

    int n;
    cin >> n;
    int arr[n];
    int brr[n];
    for (int i = 0; i < n - 1; i++)
    {
        cin >> brr[i];
    }
    arr[n - 1] = brr[n - 2];
    for (int i = n - 2; i > 0; i--)
    {
        arr[i] = min(brr[i - 1], brr[i]);
    }
    int sum = 0;
    arr[0] = brr[0];
    for (int i = 0; i < n; i++)
    {
        sum += arr[i];
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

#include <iostream>
using namespace std;

int main(){
  int n;
  int ans = 0;
  while(cin>>n){
    if(n==0)break;
    ans=0;
    for(int i=1;i<n;i++){
      int sum=0;
        for(int j=i;j<n;j++){
	  sum+=j;
	  if(sum==n)ans++;
	  if(sum>=n)break;
        }
	//cout<<"sum: "<<i<<" "<<sum<<endl;
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3060
s = list(input())
c = 0

if s[0]==s[1]:
    c+=1
if s[0]==s[2]:
    c+=1
if s[0]==s[3]:
    c+=1
if s[1]==s[2]:
    c+=1
if s[1]==s[3]:
    c+=1
if s[2]==s[3]:
    c+=1

if c == 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] arr = new int[n];
        for(int i=0 ; i<n ;++i){
            arr[i] = scanner.nextInt();
        }
        int[] dp = new int[n];
        for(int i = 1 ; i<=k&&i<n;++i){
            dp[i] = Math.abs(arr[i]-arr[0]);
        }
        for(int i=k+1 ; i<n;++i){
            int minValue = Integer.MAX_VALUE;
            for(int j = k ; j>0 ; --j){
                int temp =dp[i-j]+Math.abs(arr[i]-arr[i-j]);
                if(temp<minValue){
                    minValue = temp;
                }
            }
            dp[i] = minValue;
        }
        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 59732
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int solve(vector<int> a,vector<int> b){
  if(a.size()!=b.size()) return 1048576;
  SORT(a);
  SORT(b);
  int answer=0;
  REP(i,a.size()) answer+=abs(a[i]-b[i]);
  return answer;
}
int main(void)
{
  int n,m;
  cin >> n >> m;
  vector<int> bi(n),ru(m);
  REP(i,n) cin >> bi[i];
  REP(i,m) cin >> ru[i];
  vector<int> bii,ru0i,ru1i;
  REP(i,n) if(bi[i]) bii.push_back(i);
  int tmp=0;
  bool flag=true;
  REP(i,m-1) ru[i+1]+=ru[i];
  REP(i,m){
    for(flag=!flag;tmp<ru[i];++tmp)
      if(flag) ru0i.push_back(tmp);
      else ru1i.push_back(tmp);
  }
  cout << min(solve(bii,ru0i),solve(bii,ru1i)) << endl;
  return 0;
}

Measured memory_bytes: 3168
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String s = stdIn.next();
		String t = stdIn.next();
		
		boolean flag = false;
		String a = "";
		
		for(int i = 0; i < s.length(); i++) {
			a = s.substring(i,s.length())+s.substring(0,i);
			if(a.equals(t)){
				flag = true;
			}
		}
		
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		
	}

}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final int MOD = 998244353;
        final var sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        final int S = Integer.parseInt(sc.next());
        final int[] A = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            A[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        final int[] dp = new int[S + 1];
        dp[0] = 1;
        for (int i = 1; i<= N; i++) {
            for (int k = S; k >= 0; k--) {
                dp[k] += dp[k];
                if (dp[k] >= MOD) dp[k] -= MOD;
                if (k - A[i] >= 0) {
                    dp[k] += dp[k - A[i]];
                    if (dp[k] >= MOD) dp[k] -= MOD;
                }
            }
        }
        System.out.println(dp[S]);
    }
}


Measured memory_bytes: 39476
def c_100_to_105():
    X = int(input())

    if 1 <= X <= 99:
        return '0'
    if 100 <= X <= 105:
        return '1'
    can_pay = [False] * (X + 1)  # [i]: i円の買い物ができるなら True
    for i in range(100, 106):
        can_pay[i] = True
    for i in range(106, X + 1):
        for j in range(100, 106):
            if i - j >= 0 and can_pay[i - j]:
                can_pay[i] = True
                break
        else:
            can_pay[i] = False
    return '1' if can_pay[X] else '0'

print(c_100_to_105())

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

int main()
{
  int i,j,c,a,b;;
  char number[100];

  i = 0;
  while((c = getchar()) != EOF) {
    if(c == ' ') {
      a = atoi(number);
      for(j = 0; j < i; j++) {
	number[j] = '\0';
      }
      i = 0;
    }
    number[i] = c;
    i++;
  }
  b = atoi(number);

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

Measured memory_bytes: 524
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        long n = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long r = Long.parseLong(sc.next());
        
        long br=b+r;
        if(br >0){
                
            long sum=(n/br);
            sum *= b;
            long rest=n%br;
            if(rest>b) sum+=b;
            else sum+=rest;
            
            
            //String s = sc.next();
            System.out.println(sum);
        }else{
            System.out.println(0);
        }
    }
    
}

Measured memory_bytes: 22868
import sys
#sys.exit()
#sorted( ,reverse=True)
N = int(input())
#S,T = map(int, input().split())
H = list(map(int, input().split()))
#print(N)
#print(S,T)
#print(A)
ans = 0
max = H[0]
for h in H:
    if h >= max:
        ans += 1
        max = h
print(ans)
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int h,w,k;cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans=INF;
    rep(bit,1<<(h-1)){
        int g=0;
        vector<int> id(h);
        rep(i,h){
            id[i]=g;
            if(bit>>i&1){
                g++;
            }
        }
        g++;
        int cnt=g-1;
        vector<vector<int>> use(g,vector<int>(w));
        rep(i,h){
            rep(j,w){
                use[id[i]][j]+=(s[i][j]=='1');
            }
        }
        vector<int> now(g);
        auto add=[&](int j){
            rep(i,g) now[i]+=use[i][j];
            rep(i,g){
                if(now[i]>k){
                    return false;
                }
            }
            return true;
        };
        rep(j,w){
            if(!add(j)){
                cnt++;
                now=vector<int>(g);
                if(!add(j)){
                    cnt=INF;
                    break;
                }
            }
        }
        chmin(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin>>s;
    int n=s.size();
    int c=0;
    for(int i=0;i<(n-1)/2;i++)
    {
        if(s[i]==s[(n-1)/2-1-i]&&s[i]==s[(n-1)/2+1+i]&&s[i]==s[n-1-i])
            continue;
        else
        {
            c++;
            break;
        }
    }
    if(c==0)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
    return 0;
}


Measured memory_bytes: 256
//ギブアップ 2019/11/8
//key 二分探索
#include<iostream>
#include<algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
int n;
ll k;
std::cin >> n>>k;
std::vector<int> a(n);
std::vector<int> f(n);

for (int i = 0; i < n; i++)std::cin >> a[i];
for (int i = 0; i < n; i++)std::cin >> f[i];

sort(a.begin(),a.end());
sort(f.begin(),f.end(),std::greater<int>());

ll l=-1,r=1e12;
ll  c;
ll  s;
while (1+l<r) {
      c=(l+r)/2;
      s=0;
      for (int i = 0; i < n; ++i) {
        s+=max(a[i]-c/f[i],(ll)0);
      }
      if(s<=k)r=c;else l=c;
}

std::cout << r << '\n';

return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  map<int, int> same;
  set<int> b;
  rep(i, n) {
    same[a[i]]++;
    b.insert(a[i]);
  }

  ll total = 0;
  map<int, ll> comb;
  for (int i : b) {
    comb[i] = (ll)same[i] * (same[i] - 1) / 2;
    total += comb[i];
  }

  rep(i, n) {
    int c = a[i];
    ll ans = total - comb[c];
    ans += (ll)(same[c] - 1) * (same[c] - 2) / 2;
    cout << ans << endl;
  }
  return 0;
}

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

#define testcases int t; cin>>t; while(t--)
#define int long long
const int MOD =  1e9 + 7;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int32_t main()
{

	FASTIO;

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

	for (int & i : v) cin >> i;

	sort(v.begin(), v.end());

	int ptr = n - 2;
	int cnt = 0;

	int ans = v[n - 1];

	for (int i = n - 3; i >= 0; i--)
	{
		if (cnt == 2) {
			cnt = 0;
			ptr--;
		}

		ans += v[ptr];
		cnt++;
	}

	cout << ans;


}

Measured memory_bytes: 4788
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
    }

    let v: i32 = a - b * 2;
    if v <= 0 {
        println!("{}", 0);
    } else {
        println!("{}", v);
    }
}



Measured memory_bytes: 4352
#import sys
#from collections import deque
#from collections import defaultdict
#import math
#sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
a = set(a)
mod = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1):
        if i in a:
                continue
        if i == 1:
                dp[i] = 1
                continue
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[n]%mod)

Measured memory_bytes: 56664
n=input()
a=[c for c in n]
li=['+','-']

def ans(a,li):
    for p in li:
        for q in li:
            for r in li:
                ans=a[0]+p+a[1]+q+a[2]+r+a[3]
                if eval(ans)==7:
                    return ans+'=7'

print(ans(a,li))

Measured memory_bytes: 3060
#include<math.h>
int n,bld[1001],x[1001],y[1001],path[1001],start,goal;
dijkstra(){
	double c[1001],t;
	int f[1001]={0}, i, nearest;
	memset(path,0,sizeof(path));
	for(i=1;i<=n;i++)
		c[i]=1e9;
	nearest=start;
	c[start]=0;
	while(nearest){
		f[nearest]=1;
		for(i=1;i<=n;i++){
			t=hypot(x[nearest]-x[i],y[nearest]-y[i]);
			if(t<=50){
				t+=c[nearest];
				if(t<c[i]){
					c[i]=t;
					path[i]=nearest;
				}
			}
		}
		nearest=0;
		for(i=1;i<=n;i++){
			if(!f[i] && (!nearest || c[i]<c[nearest]))
				nearest=i;
		}
	}
}
P(i){
	if(i!=start)
		P(path[i]);
	printf("%d%c",bld[i],i==goal?'\n':' ');
}
main(){
	int i,m;
	for(;scanf("%d",&n),n;){
		for(i=1;i<=n;i++)
			scanf("%d%d%d",bld+i,x+i,y+i);
		scanf("%d",&m);
		for(;m--;){
			scanf("%d%d",&start,&goal);
			for(i=1;bld[i]!=start;i++);
			start=i;
			for(i=1;bld[i]!=goal;i++);
			goal=i;
			dijkstra();
			if(path[goal])
				P(goal);
			else
				puts("NA");
		}
	}
	exit(0);
}

Measured memory_bytes: 0
n = int(raw_input())
t = [int(i) for i in raw_input().split(" ")]
b = [int(i) for i in raw_input().split(" ")]

mina = None
tot = sum(t) + sum(b)
tn = sum(t) - t[0]
bn = 0
for s in range(n):
 if mina == None or mina > tn + bn:
  mina = tn + bn
 if s == n-1:
  break
 tn -= t[s+1]
 bn += b[s]

print tot - mina

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
const int N=1e5+100;
int n,m,dg[N],vi[N],fb;
int tot,first[N],nxt[N*2],point[N*2];
bool ok;
vector <int> f;
inline void add_edge(int x,int y)
{
	tot++;
	nxt[tot]=first[x];
	first[x]=tot;
	point[tot]=y;
}
void dfs(int x,int fa)
{
	if (f[0]==x && fa!=0) ok=1;
	if (ok) return;
	for (int i=first[x];i!=-1;i=nxt[i])
	{
		int u=point[i];
		if (u==fa || u==f[1]) continue;
		dfs(u,x);
	}
}
signed main()
{
	tot=-1;
	memset(first,-1,sizeof(first));
	memset(nxt,-1,sizeof(nxt));
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add_edge(u,v);add_edge(v,u);
		dg[u]++;dg[v]++;
	}
	bool bl=1;
	for (int i=1;i<=n;i++)
	{
		if (dg[i]&1)
		{
			bl=0;
			break;
		}
	}
	if (!bl)
	{
		printf("No\n");
		return 0;
	}
	int MAX=0,cnt=0;
	for (int i=1;i<=n;i++) MAX=max(MAX,dg[i]);
	for (int i=1;i<=n;i++) if (dg[i]==MAX) cnt++;
	if (MAX<4 || (MAX==4 && cnt<2))
	{
		printf("No\n");
		return 0;
	}
	if (MAX>4 || (MAX==4 && cnt>2))
	{
		printf("Yes\n");
		return 0;
	}
	for (int i=1;i<=n;i++) if (dg[i]==MAX) f.push_back(i);
	ok=0;
	dfs(f[0],0);
	if (ok) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 7032
import heapq
def main():
    N,M=map( int, input().split())
    A=list( map( int, input().split()))
    A = list(map(lambda x: x*(-1), A))
    heapq.heapify(A)
    for _ in range(M):
        u = heapq.heappop(A)
        heapq.heappush(A,int(u/2))
    print(-sum(A))


    

if __name__ == '__main__':
    main()


Measured memory_bytes: 14180
from collections import *

n = int(input())
a = list(map(int, input().split()))

filtered_a = sorted([i for i in Counter(a).most_common() if i[1] >= 2], reverse=True)

print(  0 if len(filtered_a) < 2
        else filtered_a[0][0] ** 2 if filtered_a[0][1] >= 4
        else filtered_a[0][0] * filtered_a[1][0])

Measured memory_bytes: 21540
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
#include<functional>
using namespace std;
using P = pair<int, int>;
using PP = pair<pair<int, int>, int>;

const int N_MAX = 302;
const P INF = P(N_MAX, 0);

int n, m;
int l;
vector<P> edge[N_MAX];
P d[N_MAX][N_MAX];


P total_charge(P before, int cost){
    if (before.second + cost <= l)return P(before.first, before.second + cost);
    else return P(before.first + 1, cost);
}

void dijkstra(int s){
    priority_queue<PP, vector<PP>, greater<PP>> Que;

    for(int i = 1; i <= n; i++)d[s][i] = INF;
    d[s][s] = P(0, 0);
    Que.push(PP(P(0, 0), s));

    while(!Que.empty()){
        PP p = Que.top(); Que.pop();
        int v = p.second;
        if (d[s][v] < p.first)continue;
        for(auto e: edge[v]){
            P throughE = total_charge(d[s][v], e.second);
            if (throughE < d[s][e.first]){
                d[s][e.first] = throughE;
                Que.push(PP(d[s][e.first], e.first));
            }
        }
    }
}

int main(){
    cin >> n >> m >> l;
    for(int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        if (c <= l){
            edge[a].emplace_back(b, c);
            edge[b].emplace_back(a, c);
        }
    }
    int q;
    cin >> q;
    vector<P> query(q);
    for(int i = 0; i < q; i++){
        cin >> query[i].first >> query[i].second;
    }

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

    for(auto p: query){
        if (d[p.first][p.second] < INF)cout << d[p.first][p.second].first << endl;
        else cout << -1 << endl;
    }
}

Measured memory_bytes: 6220
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    vector<int>imos[5010];
    for(int i=0;i<=n+5;i++){
        imos[i].resize(i+5);
        for(int j=0;j<i+5;j++)
            imos[i][j]=0;
    }
    for(int i=0;i<m;i++){
        int a,b,x;
        scanf("%d%d%d",&a,&b,&x);
        imos[a][b]++;imos[a][b+1]--;
        imos[a+x+1][b]--;imos[a+x+2][b+1]++;
        imos[a+x+1][b+x+2]++;imos[a+x+2][b+x+2]--;
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=i+3;j++)
            imos[i][j]+=imos[i][j-1];

    for(int i=1;i<=n;i++)
        for(int j=1;j<=i+3;j++)
            imos[i][j]+=imos[i-1][j];

    for(int i=1;i<=n;i++)
        for(int j=1;j<=i+3;j++)
            imos[i][j]+=imos[i-1][j-1];

    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            cnt+=(imos[i][j])?1:0;
            //("%2d ",imos[i][j]);
        }
        //puts("");
    }
    printf("%d\n",cnt);
}

Measured memory_bytes: 50236
S = input()
for i,c in enumerate(S):
    if i % 2 == 0:
        if c != 'R' and c!= 'U' and c != 'D':
            print('No')
            exit()
    else:
        if c != 'L' and c!= 'U' and c != 'D':
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#define ll long long
#define N 500005
const int INF=0x3f3f3f3f;
const int mod=1e9 + 7;
using namespace std;
ll a[N];
int main(){
	int a, b, t;
	cin >> a >> b >> t;
	int sum = 0;
	while(t >= 0){
		t -= a;
		if(t >= 0) sum += b;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
s = input()
for i in range(len(s) - 2, 0, -1):
    target_s = s[:i]
    if len(target_s) % 2 != 0:
        continue
    if target_s[: int(len(target_s) / 2)] == target_s[int(len(target_s) / 2) :]:
        print(len(target_s))
        exit()


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

int main()
{

  long long a,b,x;
  cin>>a>>b>>x;

  long long c,d;
  c=a-a%x;
  d=b-b%x;

  long long ans=d/x-c/x;

  if(c==a)ans++;


  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args)  throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		boolean end = false;

		while (end == false) {
			// ??\?????????????????????
			String temp = br.readLine();
			String[] numbers = temp.split(" ");// ????????¨??????????????????
			int H = Integer.parseInt(numbers[0]);
			;// ??????
			int W = Integer.parseInt(numbers[1]);
			;// ???

			if (H >= 3 || W <= 100 && H > 0 && W > 0) {
				// ????§???¢??????????????????
				for (int i = 0; i < H; i++) {

					if (i == 0 || i == H - 1) {
						for (int j = 0; j < W; j++) {
							System.out.print("#");
						}
					} else {
						System.out.print("#");
						for (int j = 1; j < W - 1; j++) {
							System.out.print(".");
						}
						System.out.print("#");
					}

					System.out.println();// ?¬??????????
				}
				System.out.println();// ??????

			} else if (H == 0 && W == 0) {
				end = true;// HW?????????0??????????????????
			}
		}


	}
}

Measured memory_bytes: 30108
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  string s;
  int a = -1,b = 999999999;
  cin >> s;
  for (int i = 0;i < s.length();i++) {
    if (s[i] == 'A') {
      a = i;
      break;
    }
  }
  for (int i = s.length()-1;i >=0;i--) {
    if (s[i] == 'Z') {
      b = i;
      break;
    }
  }
  cout << b-a+1;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	int[] UF;
	int N,Q;

	public int find(int x){
		if(UF[x] == x)return x;
		return UF[x] = find(UF[x]);
	}

	public void unite(int x,int y){
		if(same(x,y))return;

		int a = find(x);
		int b = find(y);

		if(a < b){
			UF[b] = a;
		}else{
			UF[a] = b;
		}
	}

	public boolean same(int x,int y){

		if(find(x) == find(y))return true;
		return false;
	}

	public void solve() {
		N = nextInt();
		Q = nextInt();

		UF = new int[N];
		for(int i = 0;i < N;i++){
			UF[i] = i;
		}


		for(int i = 0;i < Q;i++){
			int c = nextInt();
			int x = nextInt();
			int y = nextInt();

			if(c == 0){
				unite(x,y);
			}else{
				if(same(x,y)){
					out.println(1);
				}else{
					out.println(0);
				}
			}
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 61288
#include<bits/stdc++.h>
using namespace std;
int arr[100005];
int main(){
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>arr[i];
	long long l=2,r=2;
	for(int i=n-1;i>=0&&l<=r;i--){
		long long x=(l+arr[i]-1)/arr[i],y=r/arr[i];
		l=x*arr[i],r=(y+1)*arr[i]-1;
	}
	if(l>r)cout<<"-1";else cout<<l<<" "<<r;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int x,n,l[105],cnt,d[105];
int main()
{
    cin>>n>>x;
    for(int i=0;i<n;i++)cin>>l[i];
    int i=0;
    for(int j=0;j<n+1;j++){
        d[i+1]=l[i]+d[i];
        if(d[i+1]>x)break;
        i++,cnt++;
    }
    cout<<(cnt==n+1?cnt:cnt+1)<<endl;
}

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

int main() {

	int A, B,a,m,p,max;
	cin >> A;
	cin >> B;
	a = A * B;
	m = A - B;
	p = A + B;


	if (a <= m) {
		max = m;
	}
	else {
		max = a;
	}
	if (a <= p) {
		if (max <= p) {
			max = p;
		}
		
	}
	else {
		if (max <= a) {
			max = a;
		}
	}
	if (p <= m) {
		if (max <= m) {
			max = m;
		}
	}
	else {
		if (max <= p) {
			max = p;
		}
	}

	cout << max;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		// input
		int min = 1;
		int max = scan.nextInt();
		int num = scan.nextInt();
		for (int i = 0; i < num; i++) {
			int left = scan.nextInt();
			int right = scan.nextInt();
			if (left > min) {
				min = left;
			}
			if (right < max) {
				max = right;
			}
		}

		// answer
		if (max - min < 0) {
			System.out.println(0);
		} else {
			System.out.println(max - min + 1);
		}

	}
}


Measured memory_bytes: 61712
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 


int main() {
  int n; cin >> n;
  vi a(n);
  rep(i,n ) cin >> a[i];
  set<int> tani, yama;
  if (a[0] < a[1]) tani.insert(0);
  if (a[n-1] > a[n-2]) yama.insert(n-1);
  for (int i=1; i<n-1; i++) {
    if (a[i] <= a[1+i] && a[i] <= a[i-1] && (a[i+1] != a[i] || a[i] != a[i-1])) tani.insert(i);
    if (a[i] >= a[i+1] && a[i] >= a[i-1]&& (a[i+1] != a[i] || a[i] != a[i-1])) yama.insert(i);
  }
  ll ans = 1000;
  ll rest = 1000;
  ll stock = 0;
  rep(i,n) {
    if (tani.find(i) != tani.end()) {
      ll maxBuy = rest / a[i];
      rest -= maxBuy * a[i];
      stock += maxBuy;
    } 
    if (yama.find(i) != yama.end()) {
      rest += stock * a[i];
      stock = 0;
      chmax(ans, rest);
    }
  }
  printf("%lld\n", ans);
  return 0;
}

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

constexpr double EPS = 1e-8;

double b[12];

bool solve(){
    double x;
    cin >> x;
    if(x < 0) return false;
    string ans = "";
    for(int i=0;i<12;i++){
        if(x > b[i] - EPS){
            x -= b[i];
            ans += '1';
        }else{
            ans += '0';
        }
        if(i == 7) ans += '.';
    }
    if(x < EPS){
        cout << ans << endl;
    }else{
        cout << "NA" << endl;
    }
    return true;
}

int main(){
    b[0] = 1<<7;
    for(int i=0;i<11;i++){
        b[i+1] = b[i]/2;
    }
    while(solve());
    return 0;
}



Measured memory_bytes: 3160
# -*- coding: utf-8 -*-

s = raw_input()
flg = 1
slen = len(s)
while(flg):
    s = s[:slen-2]
    slen = len(s)
    m = slen/2
    if(s[:m]==s[m:]):
        print(2*m)
        flg = 0

Measured memory_bytes: 2568
import scala.io.StdIn

object Main {
  def main(args: Array[String]){
    val input = StdIn.readLine().split(" ").map(_.toInt)
    val x = input(0)
    val y = input(1)
    println(s"${x * y} ${2 * x + 2 * y}")
  }
}


Measured memory_bytes: 43632
import sys
n = int(input())
class Node:
  def __init__(self):
    self.p = -1 # parent
    self.l = -1 # left most child
    self.r = -1 # right sibling

T = [Node() for _ in range(n)]
D = [0]*n
sys.setrecursionlimit(1500)
def rec(u,p):
  D[u] = p
  if T[u].r != -1: rec(T[u].r,p+1)
  if T[u].l != -1: rec(T[u].l,p+1)

H = [0]*n
def rec1(u):
  r = l = 0
  if T[u].r != -1: r = rec1(T[u].r)+1
  if T[u].l != -1: l = rec1(T[u].l)+1
  H[u] = max(r,l)
  return H[u]
def sib(n):
  if T[n].p == -1:
    return -1
  if T[T[n].p].l == n:
    return T[T[n].p].r
  if T[T[n].p].r == n:
    return T[T[n].p].l
for i in range(n):
    v,l,r = map(int,input().split())
    T[v].r = r
    if r != -1:
      T[r].p = v
    T[v].l = l
    if l != -1:
      T[l].p = v
    #print(v,T[v].p,T[v].l,T[v].r)
#print("a1")
for i in range(n):
  #print(i,T[i].p,T[i].l,T[i].r)
  if T[i].p == -1 : r = i
#print("a2")
rec(r,0)
rec1(r)
#print("a3")
for i in range(n):
  #print(i,T[i].p,T[i].l,T[i].r)
  d = 0
  if T[i].l != -1:
    d += 1
  if T[i].r != -1:
    d += 1  
  if T[i].p == -1:
    kind = "root"
  elif d == 0: kind = "leaf"
  else: kind = "internal node"
  print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}"
        .format(i,T[i].p,sib(i),d,D[i],H[i],kind))


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
using data=pair<int,int>;

int max(int a,int b){
	if(a>b)return a;
	return b;
}

int min(int a,int b){
	if(a<b)return a;
	return b;
}

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
  int i,j,N,M,a,b,cnt=1;
  vector<data> ord;
  scanf("%d",&N);
  scanf("%d",&M);
  for(i=0;i<M;i++){
    scanf("%d",&a);
    scanf("%d",&b);
    ord.push_back(data(a,b));
  }
  sort(ord.begin(),ord.end());
  a=ord[0].first;
  b=ord[0].second;
  for(i=0;i<M;i++){
    if(ord[i].first==a)continue;
    a=ord[i].first;
    if(b>ord[i].second){
      b=ord[i].second;
      continue;
    }
    if(b>ord[i].first)continue;
    cnt++;
    b=ord[i].second;
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 1400
n = gets.to_i
peoples = []
n.times do
  a = gets.to_i
  tms = []
  a.times do
    tms.push(gets.split.map(&:to_i))
  end
  peoples.push(tms)
end

max = 0

[0, 1].repeated_permutation(n) do |bits|
  i = 0
  everyoneHonest = true
  bits.each do |bit|
    if bit == 1
      tms = peoples[i]
      tms.each do |tm|
        if bits[tm[0] - 1] != tm[1]
          everyoneHonest = false
          break
        end
      end
    end
    i += 1
  end
  if everyoneHonest
    max = [max, bits.count(1)].max
  end
end

print max

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	while(cin>>n && n!=0){
		vi sum(n);
		int s;
		rep(i,0,n){
			rep(j,0,5){
				cin>>s;
				sum[i]+=s;
			}
		}
		sort(all(sum));
		o(sum[n-1]<<" "<<sum[0]);
	}
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372037ll;

void solve()
  {
   string s,t;
   int ans = inf;
   cin>>s>>t;
   int n = s.size();
   loop(i,0,n)
    {
        int now = 0;
        loop(j,0,t.size())
        {
         if(i+j >= n)
           {
            now = inf;
            break;
           }
         if(s[i+j] != t[j])
           now++;
        }
        ans = min(ans,now);
    }
    cout<<ans;
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 

     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

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

using namespace std;

using ll = long long;

const long long MOD = 1e9+7;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}


class Mll
{
    public:
    ll x;

    Mll() : x(0){}
    Mll(ll x=0) : x((x%MOD+MOD)%MOD){}

    Mll operator-() const
    {
        return Mll(-x);
    }

    Mll& operator+=(const Mll& A)
    {
        if((x += A.x) >= MOD) x -= MOD;
        return *this;
    }
    Mll& operator-=(const Mll& A)
    {
        if((x += MOD - A.x) >= MOD) x -= MOD;
        return *this;
    }
    Mll& operator*=(const Mll& A)
    {
        (x *= A.x) %= MOD;
        return *this;
    }
    
    Mll operator+(const Mll& A)
    {
        Mll res(*this);
        return res+=A;
    }
    Mll operator-(const Mll& A)
    {
        Mll res(*this);
        return res-=A;
    }
    Mll operator*(const Mll& A)
    {
        Mll res(*this);
        return res*=A;
    }
    
    Mll pow(ll t) const // t乗
    {
        if(t==0) return 1;
        Mll A = pow(t>>1);
        A *= A;
        if(t&1) A *= *this;
        return A;
    }

    // for prime mod
    Mll inv() const
    {
        return pow(MOD-2);
    }
    Mll& operator/=(const Mll& A)
    {
        return (*this) *= A.inv();
    }
    Mll operator/(const Mll& A) const
    {
        Mll res(*this);
        return res/=A;
    }

    friend ostream& operator<<(ostream& os, const Mll& M)
    {
        os << M.x;
        return os;
    }
};

vector<Mll> ALLIN_MLL(ll N)
{
    vector<ll> numbers_ll(N);
    ALLIN1_NUMBER(numbers_ll);

    vector<Mll> numbers_Mll;
    for(ll i=0;i<N;i++)
    {
        Mll add(numbers_ll[i]);
        numbers_Mll.push_back(add);
    }

    return numbers_Mll;
}

ll ceil(ll dividend, ll divisor)
{
    return (dividend + divisor - 1) / divisor;
}

class UnionFind
{
    public:
    vector<ll> par;

    UnionFind(ll n) : par(n,-1){}

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

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

    void unite(ll x, ll y)
    {
        x = root(x); y = root(y);
        if(x==y) return;
        if(par[x] > par[y]) swap(x,y);
        par[x] += par[y];
        par[y] = x;
    }

    ll size(ll i)
    {
        return -par[root(i)];
    }
};


static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

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

    vector<ll> L(N);
    ALLIN1_NUMBER(L);

    ll counter = 0;

    for(ll i=0;i<N-2;i++)
    {
        for(ll j=i+1;j<N-1;j++)
        {
            for(ll k=j+1;k<N;k++)
            {
                if(L[i]+L[j]>L[k] && L[i]+L[k]>L[j] && L[j]+L[k]>L[i] && L[i]!=L[j] && L[i]!=L[k] && L[j]!=L[k]) counter++;
            }
        }
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 3720
import std.format;
import std.stdio;
import std.string;

void main() {
  int n,k;
  string s = readln.strip;
  formattedRead(s, " %s %s", &n, &k);

  int ans = k;
  foreach (_ ; 1 .. n) {
    ans *= (k-1);
  }

  writeln(ans);
}


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

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

int main(){
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	
	int ans = 0;
	for(int i = 0; i <= a; ++i){
		for(int j = 0; j <= b; ++j){
			for(int k = 0; k <= c; ++k){
				int v = i * 500 + j * 100 + k * 50;
				if(x == v) ans++;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
//#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return (t*t)%mod;
    return (t*t*a)%mod;
}

//library end

signed main(){
    string s;
    cin>>s;
    if(s=="AAA"||s=="BBB"){
        puts("No");
    }
    else{
        puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll l;
    cin >> l;
    double ans = l * l * l / 27.0; 
    cout.precision(10);
    cout << ans << endl;
}

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

int main(void){
    int n;
    cin>>n;
    map<int,int> mp;
    rep(i,n){
        int x;
        cin>>x;
        mp[x]++;
    }
    cout<<mp.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc    = new Scanner(System.in);
    static final int     MOD   = (int) 1E9 + 7;
    static final long    INF_L = (long) 4E18;

    public static void main(String[] args) {
        int N = nint();
        double[] p = ndoubles(N, 1, 0);
        double[][] dp = new double[2*N + 1][N + 1];
        
        dp[N][0] = 1;
        
        for (int n = 0; n < N; n++) {
            for (int diff = -N; diff <= N; diff++) {
                int idx = diff + N;
                
                if (diff != -N) {
                    dp[idx-1][n+1] += dp[idx][n] * (1-p[n+1]);
                }
                if (diff != N) {
                    dp[idx+1][n+1] += dp[idx][n] * p[n+1];
                }
            }
        }
        
        double ans = 0;
        for (int diff = 1; diff <= N; diff++) {
            int idx = diff + N;
            ans += dp[idx][N];
        }
        
        System.out.println(ans);
    }

    @Deprecated
    static int nint() {
        return sc.nextInt();
    }

    @Deprecated
    static int[] nints(int N) {
        return nints(N, 0, 0);
    }

    @Deprecated
    private static int[] nints(int N, int padL, int padR) {
        int[] a = new int[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nint();
        return a;
    }

    static long nlong() {
        return sc.nextLong();
    }

    static long[] nlongs(int N) {
        return nlongs(N, 0, 0);
    }

    static long[] nlongs(int N, int padL, int padR) {
        long[] a = new long[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nlong();
        return a;
    }

    static double ndouble() {
        return sc.nextDouble();
    }

    static double[] ndoubles(int N) {
        return ndoubles(N, 0, 0);
    }

    static double[] ndoubles(int N, int padL, int padR) {
        double[] d = new double[N + padL + padR];
        for (int i = 0; i < N; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    static String nstr() {
        return sc.next();
    }

    static char[] nchars() {
        return sc.next().toCharArray();
    }

    static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    static char[][] nchars2(int H, int W) {
        return nchars2(H, W, 0, 0);
    }

    static char[][] nchars2(int H, int W, int padLU, int padRD) {
        char[][] a2 = new char[H + padLU + padRD][W + padLU + padRD];
        for (int i = 0; i < H; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, W);
        return a2;
    }

    static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    static long abs(long a) {
        return Math.abs(a);
    }
}


Measured memory_bytes: 244080