akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

struct XORShift {
    unsigned int x, y, z, w, t;

    XORShift(int seed) {
        mt19937 rnd(seed);
        x = rnd();
        y = rnd();
        z = rnd();
        w = rnd();
        t = 1;
    }

    int rand() {
        t = x ^ (x << 11);
        x = y;
        y = z;
        z = w;
        w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
        return w & 0x7fffffff;
    }
} rnd(rand());

const int N = 26;
const int D = 365;
const double TIMELIMIT = 1.95;
int d;
int c[N];
int s[D][N];

struct STATE {
    int contests[D];
    /*
    int pre[D][N];
    int nxt[D][N];
    */
    int score;
};

STATE state;

void init(STATE& state) {
    state.score = 0;
    int last[N] = {};
    rep(i, D) {
        int mx = -INF;
        int select;
        rep(j, N) {
            if(s[i][j] > mx){
                mx = s[i][j];
                select = j;
            }
        }
        state.contests[i] = select;
        state.score += mx;
        last[select] = i + 1;
        rep(j, N) {
            state.score -= c[j] * (i + 1 - last[j]);
        }
    }
    /*
    fill(state.pre, state.pre + D, 0);
    fill(state.nxt, state.nxt + D, D + 1);
    fill(last, last + N, 0);
    rep(i, D) {
        rep(j, N) {
            state.pre[i][j] = last[j];
        }
        last[state.contests[i]] = i + 1;
    }
    fill(last, last + N, D + 1);
    rep(i, D) {
        rep(j, N) {
            state.pre[D - 1 - i][j] = last[j];
        }
        last[state.contests[D - 1 - i]] = D - i;
    }
    */
}

int cnt = 0;
void SA() {
    init(state);
    double starttemp = 9000.0, endtemp = 1.0;
    int startclock = clock();
    while (true) {
        cnt++;
        int nowclock = clock();
        if (nowclock - startclock > TIMELIMIT * CLOCKS_PER_SEC) break;
        STATE newstate = state;
        int d = rnd.rand() % D, cc = rnd.rand() % N;
        newstate.score = 0;
        newstate.contests[d] = cc;
        int last[N] = {};
        rep(i, D) {
            newstate.score += s[i][newstate.contests[i]];
            last[newstate.contests[i]] = i + 1;
            rep(j, N) {
                newstate.score -= c[j] * (i + 1 - last[j]);
            }
        }
        double temp = starttemp + (endtemp - starttemp) *
                                      (nowclock - startclock) /
                                      (TIMELIMIT * CLOCKS_PER_SEC);
        if (exp((newstate.score - state.score) / temp) >
            (rnd.rand() % INF) / (double)INF) {
            state = newstate;
        }
    }
}

signed main() {
    int t;
    cin >> t;
    rep(i, N) {
        cin >> c[i];
    }
    rep(i, D) {
        rep(j, N) {
            cin >> s[i][j];
        }
    }
    SA();
    rep(i, D) {
        cout << state.contests[i] + 1 << endl;
    }
    /*
    cout << "score : " << state.score << endl;
    cout << "cnt : " << cnt << endl;
    */
    return 0;
}

Measured memory_bytes: 4312
from itertools import count, takewhile, dropwhile

def dfs(n, max9, max6, d={0:0}):
  if n in d: return d[n]
  
  max9 = next(dropwhile(lambda x: x>n, (max9 / 9**i for i in count())))
  max6 = next(dropwhile(lambda x: x>n, (max6 / 6**i for i in count())))
  d[n] = min(dfs(n-max9, max9, max6), dfs(n-max6, max9, max6)) + 1
  return d[n]

n = int(input())

max9 = max(takewhile(lambda x: x<=n, (9**i for i in count())))
max6 = max(takewhile(lambda x: x<=n, (6**i for i in count())))

print(dfs(n, max9, max6))

Measured memory_bytes: 3064
from itertools import product
n, m, x = map(int, input().split())
books = [[int(j) for j in input().split()] for i in range(n)]
min_cost = float('inf')
for bit in product([0, 1], repeat=n):
    cost = 0
    skill = [0] * m
    for i, b in enumerate(bit):
        if b == 1:
            cost += books[i][0]
            for j in range(m):
                skill[j] += books[i][j + 1]
    if x <= min(i for i in skill):
        min_cost = min(min_cost, cost)
print(min_cost if min_cost != float('inf') else -1)

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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int N; cin >> N;
    int a[N];
    int ans=0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(a[i]%2==1&&i%2==0){
            ans++;
        }
    }
    cout << ans << endl;
}

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

class UnionFind {
private:
  int sz;
  vector<int> par, size_;
public:
  UnionFind() {}
  UnionFind(int n) : sz(n), par(sz), size_(sz, 1) {
    iota(par.begin(), par.end(), 0);
  }
  int root(int x) {
    if (par.at(x) == x) return x;
    else return par.at(x) = root(par.at(x));
  }
  void unit(int x,int y) {
    x = root(x), y = root(y);
    if (x == y) return;
    if (size_.at(x) < size_.at(y)) swap(x, y);
    par.at(y) = x;
    size_.at(x) += size_.at(y);
  }
  int size(int x) {
    x = root(x);
    return size_.at(x);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
    P.at(i)--;
  }
  UnionFind UF(N);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    UF.unit(--x, --y);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (UF.root(P.at(i)) == UF.root(i)) ans++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1408
class PriorityQueue
  MIN = -(1 << 60)

  attr_reader :size

  def initialize(capacity = nil, &block)
    @size = 0
    @heap = capacity.nil? ? Array.new : Array.new(capacity)
    @key = block || :itself.to_proc
  end

  def empty?
    size == 0
  end

  def push(x)
    i = @size
    @size += 1
    while i > 0
      parent = (i - 1) / 2
      break if (@key.call(@heap[parent]) <=> @key.call(x)) >= 0
      @heap[i] = @heap[parent]
      i = parent
    end
    @heap[i] = x
    nil
  end

  def pop
    return nil if @size <= 0
    ret = @heap[0]
    x = @heap[@size - 1]
    @size -= 1
    i = 0
    while i * 2 + 1 < @size
      l = i * 2 + 1
      r = i * 2 + 2
      largest = l
      largest = r \
        if r < @size && (@key.call(@heap[r]) <=> @key.call(@heap[largest])) > 0
      break if (@key.call(x) <=> @key.call(@heap[largest])) >= 0
      @heap[i] = @heap[largest]
      i = largest
    end
    @heap[i] = x
    ret
  end

  def top
    return nil if @size <= 0
    @heap[0]
  end

  def to_a
    @heap.take(@size)
  end
end

N, M = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

pq = PriorityQueue.new { |(a, _)| a }
as.each do |a|
  pq.push([a, a.to_f])
end

rest_count = M
while rest_count > 0
  a, raw = pq.pop
  pq.push([(raw / 2).to_i, raw / 2])
  rest_count -= 1
end
ans = pq.to_a.reduce(0) { |acc, (a, _)| acc + a }
puts ans


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

int main () {
#ifdef TooLazy
    freopen("in.txt", "r", stdin);
#endif // TooLazy

    string s;
    cin >> s;
    int n = s.size();
    cout << s[0] << n-2 << s[n-1] << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define INF INT_MAX
#define N 100005
#define K 101
int n, k;
vector<int> arr;
int dp[N][K];
int solve(int idx, int cur_k){
    int res;
    if(idx == n-1)
        return dp[idx][cur_k] = abs(arr[idx]-arr[idx-cur_k]);
    if(cur_k == k)
        return dp[idx][cur_k] = solve(idx, 0)+abs(arr[idx]-arr[idx-cur_k]);
    if(dp[idx][cur_k] != -1)
        return  dp[idx][cur_k];
    res = solve(idx+1, cur_k+1);
    if(cur_k > 0)
        res = min(res, solve(idx, 0)+abs(arr[idx]-arr[idx-cur_k]));
    return dp[idx][cur_k] = res;
}
int main()
{
    cin >> n >> k;
    memset(dp, -1, sizeof(dp[0][0]) * N * K);
    for(int i=0; i<n; ++i){
        int num;
        cin >> num;
        arr.push_back(num);
    }
    cout << solve(0, 0);
    return 0;
}

Measured memory_bytes: 49528
#include<cstdio>
int main(void){
	int n;
	int a,b;
	int s;
	while (scanf("%d", &n) != EOF){
		s = 0;
		for (int i = 0; i < 19; i++){
			if (n - 18 <= i&&i <= n){
				if (i < 9)a = i + 1;
				else a = 19 - i;
				if (n < i + 9)b = n - i + 1;
				else b = 19 + i - n;
				s = (a*b) + s;
			}
		}
		printf("%d\n", s);
	}
	return 0;
}

Measured memory_bytes: 2596
// 問題: H*Wのタイルが与えられる。タイルは綺麗か汚れているかのいずれか。
//       綺麗なタイルのみでできる最大の長方形の最大値を求める
// 解法: http://algorithms.blog55.fc2.com/blog-entry-133.html
//       http://algorithms.blog55.fc2.com/blog-entry-132.html
//       まず各要素について上に向かって 1 が何個連続しているかを示すテーブル T を作る
//       次に、T の各行をヒストグラムの入力と見なしヒストグラムの最大長方形の面積を求めるアルゴリズムを適用

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair

int largest_square(const int H, const int W, const vector<vector<int>>& cells) {
    // 上に綺麗なタイルが連続する数
    // 番兵として、右端は汚れたタイルがあるものとする
    vector<vector<int>> table(H, vector<int>(W+1));
    REP(w, W) {
        REP(h, H) {
            auto val = cells[h][w];
            if (val == 1) table[h][w] = 0;
            else {
                if (h == 0) table[h][w] = 1;
                else table[h][w] = table[h-1][w] + 1;
            }
        }
    }

    // REP(h, H) {
    //     REP(w, W+1) {
    //         cerr << table[h][w] << " ";
    //     }
    //     cerr << endl;
    // }

    int ans = 0;
    // 各行ごとに、ヒストグラムの最大長方形の面積を求めるアルゴリズムを適用
    REP(h, H) {
        // <ヒストグラムの高さ, index>
        stack<pair<int, int>> s;
        REP(w, W+1) {
            auto height = table[h][w];
            if (s.empty()) s.push(mp(height, w));
            else if (s.top().first < height) s.push(mp(height, w));
            else if (s.top().first > height) {
                int last_idx = w;
                while(!s.empty() && s.top().first > height) {
                    auto area = (w - s.top().second) * s.top().first;
                    ans = max(area, ans);
                    last_idx = s.top().second;
                    s.pop();
                }
                s.push(mp(height, last_idx));
            }
        }
    }
    return ans;
}


int main() {
    int H, W;
    cin >> H >> W;

    vector<vector<int>> cells(H, vector<int>(W));
    REP(h, H) {
        REP(w, W) {
            cin >> cells[h][w];
        }
    }

    cout << largest_square(H, W, cells) << endl;

    return 0;
}



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

using namespace std;

#define ll long long

int main() {
#ifdef __apple__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    string s;
    cin >> s;
    int n = s.size();
    map<char, int> q;
    for (int i = 0; i < n; ++i)
        ++q[s[i]];
    ll ans = n * 1ll * (n - 1) / 2 + 1;
    for (auto it : q)
        ans -= it.second * 1ll * (it.second - 1) / 2;
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// 標準入力からデータを読み込む準備
Scanner sc = new Scanner(System.in);
// 2つの文字の固まりを整数値と想定して読み込む 
int a = sc.nextInt();
int b = sc.nextInt();
if (a < b) {
System.out.println("a < b"); } else {
	if(a>b){
		System.out.println("a > b");
	}else{
		System.out.println("a == b");
	}
}// ... 以降を書き足そう!
} 
}


Measured memory_bytes: 26264
from itertools import accumulate
from math import ceil,floor
N,X=map(int,input().split())
A=[int(i) for i in input().split()]
A=A[::-1]
P=list(accumulate([0]+A))
ans=10**20
def E(i,x):
    if i==1:
        return 5*x
    else:
        return (2*i+1)*x
for k in range(1,N+1):
    a=0
    l_0=floor(N/k)
    l_1=ceil(N/k)
    for l in range(1,l_0+1):
        a+=E(l,P[l*k]-P[(l-1)*k])
    a+=E(l_1,P[N]-P[l_0*k])
    ans=min(ans,(N+k)*X+a)
print(ans)

Measured memory_bytes: 101200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    string ans;
    while(1){
        N--;
        ans+='a'+N%26;
        
        if(N/26==0) break;
        else N/=26;
    }

    reverse(ToEnd(ans));

    cout<<ans<<endl;
}

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

vector<string> s;

int main(){
  int N;
  long len=1;
  long count=0;
  string in;

  cin >> N;
  for(int i=0; i<N; i++){
    cin >> in;
    sort(in.begin(),in.begin()+in.size());
    s.push_back(in);
  }
  sort(s.begin(),s.end());
  for(int i=0; i<N-1; i++){
    if(s[i]==s[i+1]) len++;
    else{
      count += len*(len-1)/2;
      len=1;
    }
  }
  count += len*(len-1)/2;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 5748
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    long long n,a,b,x[100000],sum=0;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++)cin>>x[i];
    for(int i=1;i<n;i++)sum+=min(((x[i]-x[i-1])*a),b);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <climits>
using namespace std;
const int nmax=105;
vector<int> v[nmax];
int levmx,dm;
int lev[nmax],levold[nmax];
long long mx[nmax];
long long ret,mn;
int n,i,root,a,b,start,s1,s2,newroot;
void dfs(int x)
{
    int sons=0;
    if(lev[x]>levmx)
        levmx=lev[x];
    for(int i=0;i<v[x].size();i++)
        if(!lev[v[x][i]])
    {
        lev[v[x][i]]=lev[x]+1;
        dfs(v[x][i]);
        sons++;
        mx[lev[x]]=max(mx[lev[x]],1LL*sons);
    }
}
void solve(int A,int B)
{
     for(i=1;i<=n;i++)
           lev[i]=0,mx[i]=0;
    lev[A]=lev[B]=1;
    dfs(A);dfs(B);
    ret=2;
    for(i=1;i<=n;i++)
        if(mx[i])
         ret*=mx[i];
    mn=min(mn,ret);
}
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n;
    if(n==2)
    {
        cout<<"1 2";
        return 0;
    }
    for(i=1;i<=n-1;i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dm=0;lev[1]=1;
    dfs(1);
    for(i=1;i<=n;i++)
    {
        if(lev[i]>lev[root])
           root=i;

    }
    for(i=1;i<=n;i++)
        lev[i]=0,mx[i]=0;
    lev[root]=1;
    dfs(root);
    for(i=1;i<=n;i++)
    {
        if(lev[i]>dm)
           dm=lev[i],newroot=i;
        levold[i]=lev[i];
    }
    for(i=1;i<=n;i++)
        lev[i]=0,mx[i]=0;
    lev[newroot]=1;
    dfs(newroot);
    mn=LLONG_MAX;
    if(dm%2)
    {
        ret=1;
        for(i=1;i<=n;i++)
          if(lev[i]==(dm+1)/2&&levold[i]==(dm+1)/2)
             start=i;
         for(i=1;i<=n;i++)
           lev[i]=0,mx[i]=0;
        lev[start]=1;
        dfs(start);
        for(i=1;i<=n;i++)
         if(mx[i])
           ret*=mx[i];
           mn=ret;
        for(int it=0;it<v[start].size();it++)
            solve(start,v[start][it]);
    }
    else
    {
        ret=2;
        for(i=1;i<=n;i++)
            if(lev[i]==dm/2&&levold[i]==dm/2+1)
        {
            s1=i;
        }
        else
        {
            if(lev[i]==dm/2+1&&levold[i]==dm/2)
                s2=i;
        }
        solve(s1,s2);
    }

    cout<<(dm+1)/2<<' '<<mn;
    return 0;
}

Measured memory_bytes: 256
def main():
    seq = [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]
    k = int(input()) - 1
    print(seq[k])


if __name__ == '__main__':
    main()



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

#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 0
#endif
using namespace std;

template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << ": " << arg1 << endl;
}

template<typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = (int) 5e5 + 2;
int ar[NN];
int n, m;

bool check(int x){
    int cnt = 0;
    for (int i = 0; i < n; i++){
        cnt += (ar[i] + x - 1) / x - 1;
    }
    return cnt <= m;
}


integer main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> ar[i];
    int low = 1, high = 1e9;
    while (low < high){
        int mid = (high + low) / 2;
        if (check(mid)){
            high = mid;
        } else {
            low = mid + 1;
        }
    }
    cout << high << endl;


}


Measured memory_bytes: 5104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < a.length; i++){
            a[i] = sc.nextInt();
        }
        for(int i = n-1; i > 0; i--){
            System.out.printf("%d ",a[i]);
        }
        System.out.printf("%d\n",a[0]);
        sc.close();
    }
}


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

int n,m;
int dp[3005][3005];
pair<int,int> p[3005][3005];
bool mark[3005][3005];
char s[3005], t[3005];

int f(int i, int j) {
	if(i == n or j == m) return 0;
	if(mark[i][j]) return dp[i][j];
	mark[i][j] = true;
	
	int ret =  f(i+1, j);
	p[i][j] = mp(i+1, j);
	
	int aux = f(i, j+1);
	if(aux > ret) ret = aux, p[i][j] = mp(i, j+1);

	if(s[i] == t[j]) {
		aux = f(i+1, j+1) + 1;
		if(aux > ret) ret = aux, p[i][j] = mp(i+1, j+1);
	}
	return dp[i][j] = ret;
}

void print(int i, int j) {
	if(i + 1 == p[i][j].ff and j + 1 == p[i][j].ss)
		printf("%c", s[i]);
	if(p[i][j] == mp(0,0)) return;
	print(p[i][j].ff, p[i][j].ss);
}

int main() {
	scanf(" %s %s", s, t);
	n = strlen(s);
	m = strlen(t);

	f(0,0);
	print(0,0);
	printf("\n");
    
    return 0;
}

Measured memory_bytes: 115328
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>H>>W;
    rep(i,H){
        cin>>S;
        rep(j,2) cout<<S<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>v[100005];
int vis[100005];
const int mod=1e9+7;
int main(){
	int n,k;
	cin>>n>>k;
	int a,b;
	for(int i=0;i<n-1;i++){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	queue<pair<int,int> >q;
	ll ans=k;
	q.push({1,0});
	while(!q.empty()){
		int u=q.front().first,dep=q.front().second+1;
		q.pop();
		int cnt=0;
		vis[u]=1;
		for(int i=0;i<v[u].size();i++){
			b=v[u][i];
			if(vis[b])
				continue;
			if(dep==1){
				ans=ans*(k-(cnt++)-1)%mod;
			}
			else ans=ans*(k-(cnt++)-2)%mod;
			q.push({b,dep});
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 7288
while True:
    a,b=map(int,input().split())
    if a==0 and b==0 :
        break
    if a<b: (a,b)=(b,a)
    k=1
    while True :
        B=a%b
        if B==0:
            break
        k+=1
        a=b
        b=B
    print(b,k)


Measured memory_bytes: 5604
def call(n:int):
    out_c = ''
    for i in range(1,n+1):
        if (i%3 == 0):
            out_c = '{} {}'.format(out_c,i)
        else:
            x = i
            while(x>0):
                if (x%10 == 3):
                    out_c = '{} {}'.format(out_c,i)
                    break
                x = int(x/10)
    else:
        print(out_c)

s = input()
call(int(s))



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

using namespace std;

int main() {
  int N, K;
  long long ans = 0;
  cin >> N >> K;
  vector<int> acc(N + 1);
  unordered_map<int, int> now;
  now[0]++;
  for (int i = 1; i <= N; ++i) {
    int A;
    cin >> A;
    acc[i] = (acc[i - 1] + A - 1) % K;
    if (i >= K) now[acc[i - K]]--;
    ans += now[acc[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9288
#include <cstdio>

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  if((a+b)%3 == 0 || a%3 == 0 || b%3 == 0)
    printf("Possible\n");
  else
    printf("Impossible\n");
  return 0;
}

Measured memory_bytes: 128
// Problem : D - FT Robot
// Contest : AtCoder - AtCoder Regular Contest 087
// URL : https://atcoder.jp/contests/arc087/tasks/arc087_b
// Memory Limit : 512 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll func(vector<ll> &v,ll x)
{
	set<ll> s;
	s.insert(0);
	rep(i,0,v.size())
	{
		set<ll> r;
		for(auto j:s)
		{
			r.insert(j+v[i]);
			r.insert(j-v[i]);
		}
		//Only store the last value that can be obtained using all possible combinations
		swap(r,s);
	}
	return (s.find(x) != s.end());
}
void solve()
{
    string s;
    cin>>s;
    ll x,y;
    ll n=s.size();
    cin>>x>>y;
    vector<ll> X,Y;
    ll cnt=0,inx=1;
    rep(i,0,n)
    {
    	if(s[i]=='T')
    	{
    		if(inx==1)
    			X.pb(cnt);
    		else
    			Y.pb(cnt);
    		inx=inx^1;
    		cnt=0;
    	}
    	else
    		cnt++;
    }
    if(inx==1)
		X.pb(cnt);
	else
		Y.pb(cnt);
	//Initially move right X[0] times and erase it from the remaining moves in X-Direction
	x=x-X[0];
	X.erase(X.begin());
	if(func(X,x) and func(Y,y))
		cout<<"Yes";
	else
		cout<<"No";
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 640
n = int(input())
A = list(map(int, input().split()))
for j in range(n):
	d = A[j]
	i = j - 1
	while i >= 0 and A[i] > d:
		A[i+1] = A[i]
		i -= 1
	A[i+1] = d
	for i in range(n):
		if i:
			print(" ", end="")
		print(A[i], end="")
	print()



Measured memory_bytes: 6312
import itertools

N = int(input())
T = list(range(1,N+1))
S = list(itertools.permutations(T, N))
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]

for i in range(len(S)):
    if tuple(P) == S[i]:
        A = i
    if tuple(Q) == S[i]:
        B = i
print(abs(A-B))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
#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() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l.at(i);

  int ans = 0;
  rep(i, n) rep(j, n) rep(k, n) {
    if (i < j && j < k) {
      int x = l.at(i), y = l.at(j), z = l.at(k);
      if (x == y || y == z || z == x) continue;
      if (x + y <= z || y + z <= x || z + x <= y) continue;
      ++ans;
    }
  }

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

Measured memory_bytes: 3644
#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 a,b;
	cin >> a >>b;
	int ans = 0;
	int c=1;
	while(c<b){
		ans++;
		c += a-1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i -  1) * 10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}
 
struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(15);
  	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//


int N;
double A[200005];

int count_num_prime(ll x, int n) {
	int cnt = 0;
	while (x % n == 0) {
		cnt++;
		x /= n;
	} 
	return cnt;
}



int main() {
	cin >> N;
	rep (i, N) cin >> A[i];

	rep (i, N) {
		A[i] *= TEN(9);
		A[i] = (ll)(A[i] + 0.5);
	}

	V<P> hoge;
	VV<int> cnt_2_5(50, V<int>(30, 0));
	rep (i, N) {
		int cnt2 = count_num_prime(A[i], 2);
		int cnt5 = count_num_prime(A[i], 5);
		cnt_2_5[cnt2][cnt5]++;
		hoge.eb(cnt2, cnt5);
	}

	ll ans = 0;
	rep (i, N) {
		int nc2 = max(18 - hoge[i].fi, 0);
		int nc5 = max(18 - hoge[i].se, 0);
		rep2 (j, nc2, 50) rep2 (k, nc5, 30) {
			if (hoge[i].fi == j && hoge[i].se == k) {
				ans += (cnt_2_5[j][k] - 1);
			}
			else {
				ans += cnt_2_5[j][k];
			}
		}
	}

	cout << ans / 2 << endl;

	return 0;
}


Measured memory_bytes: 6964
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#define PB push_back
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define PIE (3.14159265358979323846)
#define MOD 1000000007;
using namespace std;

void checkStream() {
    #ifndef _DEBUFG
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
    #endif
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // checkStream();

    int r {}, c {}, n {};
    cin >> r >> c >> n;

    int step1 {}, step2 {};
    int ttl {};
    for (int i {}; i < r && ttl < n; ++i) {
        ttl += c;
        ++step1;
    }

    ttl = 0;
    for (int i {}; i < c && ttl < n; ++i) {
        ttl += r;
        ++step2;
    }
    cout<<min(step1, step2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}

int main(){
	int x;
	cin>>x;
	
	x-=400;
	x/=200;
	int ans=8-x;
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3620
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

fn main() {
    input! {
    h: usize,
    w: usize,
    t: Usize1
    }
    if w == 1 {
        println!("1");
        return
    }
    let p = 1_000_000_007;
    let mut dp = vec![vec![0; w]; h + 1];
    dp[0][0] = 1;
    for i in 0..h {
        for j in 0..1 << (w - 1) {
            let mut flag = true;
            let mut tmp = vec![0; w];
            for k in 0..(w - 2) {
                if j & 1 << k > 0 && j & 2 << k > 0 {
                    flag = false;
                    break;
                }
            }
            if flag {
                for k in 0..(w - 1) {
                    if j & 1 << k > 0 {
                        tmp[k] = dp[i][k + 1];
                        tmp[k + 1] = dp[i][k];
                    } else {
                        if tmp[k] == 0 {
                            tmp[k] = dp[i][k];
                        }
                        if k == w - 2 {
                            tmp[k + 1] = dp[i][k + 1];
                        }
                    }
                }
            }
            for k in 0..w {
                dp[i + 1][k] += tmp[k];
                dp[i + 1][k] %= p;
            }
        }
    }
    let ans = dp[h][t];
    println!("{}", ans);
}


Measured memory_bytes: 2152
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n, s=0; cin >> n;
    int m = n;
    while(m){
        s += m%10;
        m /= 10;
    }
    cout << (n%s ? "No" : "Yes" ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
 
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
 
#define csh(a,n) memset(a,n,sizeof(a));
int main(){
	map<string,int>mp;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string a;
		cin>>a;
		mp[a]++;
	}
	cin>>n;
	for(int i=0;i<n;i++){
		string a;
		cin>>a;
		mp[a]--;
	}
	int maxi=0;
	for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++){
		if(it->second>maxi){
			maxi=it->second;
		}
	}
	cout<<maxi;
} 

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	static class SuffixComparator implements Comparator<Integer>{
		char[] Sarr;
		public SuffixComparator(String S) {
			this.Sarr = S.toCharArray();
		}
		@Override
		public int compare(Integer o1, Integer o2) {
			int i1 = o1;
			int i2 = o2;
			if(i1 == i2){
				return 0;
			}
			while(i1 < Sarr.length && i2 < Sarr.length){
				if(Sarr[i1] != Sarr[i2]){
					return Character.compare(Sarr[i1], Sarr[i2]);
				}
				i1++;
				i2++;				
			}
			if(i1 == Sarr.length){
				return -1;
			}
			if(i2 == Sarr.length){
				return 1;
			}
			return 0;
		}
	}
	static int longestPrefix(int s0 , int s1 , char[] carr){
		if(s0 > s1){
			return longestPrefix(s1, s0, carr);
		}
		int l = 0;
		int send = s1;
		while(s1 < carr.length && s0 < send){
			if(carr[s0] != carr[s1]){
				break;
			}
			++l;
			++s0;
			++s1;
		}
		return l;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		SuffixComparator comparator = new SuffixComparator(S);
		List<Integer> suffixes = new ArrayList<Integer>();
		for(int i = 0 ; i < N ; ++i){
			suffixes.add(i);
		}
		Collections.sort(suffixes, comparator);
		char carr[] = S.toCharArray();
		int max = 0;
		for(int i = 0 ; i < N - 1 ; ++i){
			int s0 = suffixes.get(i);
			// xxxyxxy
			// xxy
			// xxyxxy
			// a
			// aa
			// aaa
			// aaabaaa
			// aabaaa
			// abaaa
			// baaa
			
			// aaabaaa
			// xy
			// xyzxy
			// 
			// xyzzx
			// xyzzx
			// xyzzx
//			int s1 = suffixes.get(i + 1);
			int cur = 0;
			int k = 100;
			for(int j = i + 1 ; j < N ; j++){
				int s1 = suffixes.get(j);
				int l = longestPrefix(s0, s1, carr);
				if(cur >= l){
					break;
				}
				cur = Math.max(cur, l);
				if(j + k < N){
					int s2 = suffixes.get(j + k);
					int l2 = longestPrefix(s0, s2, carr);
					if(l < l2){
						j = j + k;
						cur = Math.max(cur, l2);
					}					
				}
			}
			max = Math.max(max, cur);
//			int l = longestPrefix(s0, s1, carr);
//			max = Math.max(max, l);
//			System.out.println(S.substring(s0)+" "+S.substring(s1)+" "+s0+" "+s1+" "+l);
			// 18
			// strangeorangebrang
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 24016
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <class T> int first_ans(T &vec)
{
    int ans = 0;
    int n = vec.size();

    for (int a = 0; a < n - 1; a++)
        ans ^= vec[a];
    return ans;
}

int main()
{
    int n;
    cin >> n;
    vector<int> arr(n);
    for (auto &e : arr)
        cin >> e;
    vector<int> ans(n);

    for (int a = n - 1; a >= 0; a--)
    {
        if (a == n - 1)
            ans[a] = first_ans(arr);
        else
        {
            ans[a] = arr[a + 1] ^ arr[a] ^ ans[a + 1];
        }
    }

    for (auto &e : ans)
        cout << e << " ";
    return 0;
}

Measured memory_bytes: 4332
n = int(input())
a = sorted([int(_) for _ in input().split(' ')])
a.append(0)

d = set()
answer = 0

for i in range(n):
    if not(a[i] in d):
        if a[i] != a[i + 1]:
            answer += 1
        for j in range(a[i], 1000001, a[i]):
            d.add(j)

print(answer)


Measured memory_bytes: 86620
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define mod (1e9 + 7)
#define pb push_back
#define ll long long int
using namespace std;
typedef pair<int,int> pii;

int main(){
  ll h,w;
  cin>>h>>w;
  if(h==1 ||w==1) cout<<1<<endl;
  else if(h%2==0 || w%2==0) cout<<h*w/2<<endl;
  else cout<<(h*w)/2 + 1<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys
n=1000000
pr=[1]*n
pr[0],pr[1]=0,0
for i in xrange(2,int(n**0.5)+1):
    if pr[i]==1:
        for j in xrange(i**2,n,i):
            pr[j]=0
for i in xrange(2,n):
    pr[i]+=pr[i-1]
for line in sys.stdin:
    print pr[int(line)]

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


int main() {
    int N;
    cin >> N;
    if(N%2==0){
        cout << N/2 << endl;
    }else{
        cout << (N/2)+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int i,a,b;
  int min=1001,max=-1;
  cin>>a;
  for(i=0;i<a;i++)
  {
    cin>>b;
    if(max<b)
    {
      max=b;
    }


    if(min>b)
      min=b;
  }
  cout<<max-min<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		System.out.println(Math.max(0,C - (A - B)));
	}
}

Measured memory_bytes: 21844
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();

    let mut s: Vec<char> = buf.trim().chars().collect();

    s.sort();

    let res = if s[0] == s[1] && s[1] != s[2] && s[2] == s[3] {
        "Yes"
    } else {
        "No"
    };

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


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main
{
	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) 
	{
		int shortest;
		int blocks;
		
		while(true)
		{
			shortest = scan.nextInt();
			blocks = scan.nextInt();
			
			if(shortest == 0 && blocks == 0)
			{
				return;
			}
			else
			{
				new DataSet(shortest, blocks);
			}
		}
	}
	
	static class DataSet
	{
		boolean[] yearMark = new boolean[8000000];
		int year = 0;
		
		public DataSet(int s, int b)
		{
			int gap = s;
			
			year = s;
			for(int tree = 0; tree < b; tree++)
			{
				for(int jumper = year; jumper < 8000000; jumper+= gap)
				{
					yearMark[jumper] = true;
				}
				
				//find false
				while(yearMark[year] == true)
				{
					year += 1;

				}
				//year is now first false, ready to plant next tree
				gap = year;
			}
			
			System.out.println(year);
		}
	}
}



Measured memory_bytes: 146324
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  long long l[N+1];
  l[0] = 2;
  l[1] = 1;

  for (int i = 2; i < N+1; i++){
    l[i] = l[i-1] + l[i-2];
  }
   
  printf("%lld\n", l[N]);
}


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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1000000000;
using Graph = vector<vector<int>>;
// typedef pair<int, int> pair;

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

  if (a > b) {
    for (int i = 0; i < a; i++) {
      s += to_string(b);
    }
  } else {
    for (int i = 0; i < b; i++) {
      s += to_string(a);
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var ans = new int[10050];
            for (int i = 1; i <= 105; i++)
            {
                for (int j = 1; j <= 105; j++)
                {
                    for (int k = 1; k <= 105; k++)
                    {
                        var v = i * i + j * j + k * k + i * j + j * k + k * i;
                        if (v < 10050)
                            ans[v] += 1;
                    }
                }
            }
            for (int i = 0; i < N; i++)
            {
                WriteLine(ans[i + 1]);
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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



void solveb(){
    int n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int count=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(arr[i]!=arr[j])
                for(int k=j+1;k<n;k++){
                if(arr[i]+arr[j]>arr[k]&&arr[i]!=arr[k]&&arr[j]!=arr[k])count++;
            }
        }
    }
    cout<<count;
}
void solvec(){
    ll x,k,d;
    cin>>x>>k>>d;
    if(x-k*d>0){
        cout<<x-k*d;
    }
    else{
        if(x%d==0){
            ll minvalpositive=x%d;
            ll toreach=x-minvalpositive;
            ll movestoreach=toreach/d;
            if((k-movestoreach)%2==0){
                cout<<minvalpositive;
            }
            else{
                cout<<abs(minvalpositive-d);
            }
        }
        else{
            ll minvalpositive=x%d;
            ll toreach=x-minvalpositive;
            ll movestoreach=toreach/d;
            if((k-movestoreach)%2==0){
                cout<<minvalpositive;
            }
            else{
                cout<<abs(minvalpositive-d);
            }
        }
    }
}
void solved(){

}
void solvee(){

}
void solvef(){

}
int main()
{
    ll t=1;
    //cin>>t;
    while(t--){
        solveb();
    }
}


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

using namespace std;

#define endl '\n'

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

const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
const int maxn = 100000 + 10;

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

#ifdef MARX
	freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);
#endif

	int64 n, x;
	cin >> n >> x;
	int64 answer = n;

	int64 a = x, b = n - x;

	while (true){
		if (b % a == 0){
			answer += 2 * b - a;
			break;
		}
		else{
			answer += 2 * a * (b / a);
			b %= a;
			swap(a, b);
		}
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<long long> A(N);
    for (auto &i: A) cin >> i;
    long long sumall = 0, sumeven = 0;
    for (int i = 0; i < N; i++) sumall += A[i];
    for (int i = 1; i < N; i+=2) sumeven += A[i];
    cerr << sumall << " " << sumeven << endl;
    auto x = sumall - sumeven * 2;
    cout << x;
    for (int i = 1; i < N; i++)
    {
        x = A[i - 1] * 2 - x;
        cout << " "<< x;
    }
    cout << endl;
    return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll K, N, A[int(2e5+5)];

int main(){
  cin >> K >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  ll ans = A[0] + K - A[N-1];
  for (int i = 0; i < N; i++){
    ans = max(ans, A[i+1] - A[i]);
  }
  cout << K - ans << endl;

  return 0;
}



Measured memory_bytes: 5172
N = int(input())

limit2time = []

for i in range(N):
    time, limit = map(int, input().split())

    limit2time.append((limit, time))

limit2time  = sorted(limit2time, key=lambda x: x[0])

# print(limit2time)
cur = 0
for item in limit2time:
    # print(item)
    key, time = item
    if cur + time > key:
        print("No")
        break
    cur += time
else:
    print("Yes")

Measured memory_bytes: 38940
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n],b[n];
  bool flag=false;
  int c=0;
  for(int i=0;i<n;i++)
  {
      cin>>a[i]>>b[i];
      if(a[i]==b[i])
            c++;
        else
            c=0;

      if(c>=3 && flag==false)
      {
          flag=true;

      }
  }
  if(flag==false)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}


Measured memory_bytes: 3596
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

n = int(input())

v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0

for i in range(n):
    if v[i]-c[i] > 0:
        ans += v[i]-c[i]

print(ans)









Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n:f64 = read();
    let x:f64 = read();
    let t:usize = read();
    println!("{}", (n/x).ceil() as usize * t);
}


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

char c[] = {'R', 'L', 'U', 'D'};


string add(int id, int m){
  string ret = "";
  for(int i = 0; i < m; i++){
    ret += c[id];
  }
  return ret;
}

int main(){
  int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy;
  int dx = gx - sx, dy = gy - sy;
  if(dx < 0) {
    dx = -dx;
    swap(c[0],c[1]);
  }
  if(dy < 0) {
    dy = -dy;
    swap(c[2],c[3]);
  }
  string ans = "";
  ans += add(0, dx);
  ans += add(2, dy);
  ans += add(1, dx);
  ans += add(3, dy+1);
  
  ans += add(0, dx+1);
  ans += add(2, dy+1);
  ans += c[1];
  ans += c[2];
  ans += add(1, dx+1);
  ans += add(3, dy+1);
  ans += c[0];
  
  cout << ans << endl;
}

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

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

        final int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        Arrays.sort(a);

        final int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
        }
        Arrays.sort(b);
        final long[] bCount = new long[n];
        for (int i = 0; i < n; i++) {
            bCount[i] = binarySearch(a, 0, n - 1, b[i]) + 1;
            if (i != 0) {
                bCount[i] += bCount[i - 1];
            }
        }

        long counter = 0;
        for (int i = 0; i < n; i++) {
            final int c = scanner.nextInt();
            final int bi = binarySearch(b, 0, n - 1, c);
            if (bi == -1) {
                continue;
            }
            counter += bCount[bi];
        }

        System.out.println(counter);
    }

    // targetと比較して真に小さい最大の値を探す
    private static int binarySearch(final int[] array, final int begin, final int end, final int target) {
        if (end - begin <= 1) {
            if (array[end] < target) {
                return end;
            }
            if (array[begin] < target) {
                return begin;
            }
            return begin - 1;
        }
        final int mid = (begin + end) / 2;
        if (target > array[mid]) {
            return binarySearch(array, mid, end, target);
        } else {
            return binarySearch(array, begin, mid, target);
        }
    }
}


Measured memory_bytes: 91908
"""s = input()
if eval(s.replace(" ",">")): print("Alice")
elif eval(s.replace(" ","<")):print("Bob")
else: print("Draw")
"""
a,b = map(int,input().split())
if a == b: print("Draw")
elif (a > b and b!= 1) or a == 1:
  print("Alice")
else: 
  print("Bob")


Measured memory_bytes: 38256