akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#include <cassert>
#include <cstdio>
#include <complex>
#define int long long
using namespace std;
int n, x, y, counter;
vector<vector<int> > data;
vector<int> v;
bool dfs(int vertex, int last){
    if (vertex == n-1){
        v.push_back(vertex);
        return true;
    }
    for (int i=0; i < data[vertex].size(); i++){
        int to = data[vertex][i];
        if (last == to) continue;
        bool reds = dfs(to, vertex);
        if (reds){
            v.push_back(vertex);
            return true;
        }
    }
    return false;
}
void dfs2(int vertex, int last){
    counter++;
    for (int i=0; i < data[vertex].size() ;i++){
        int to = data[vertex][i];
        if (to == last) continue;
        if (vertex == x && to == y) continue;
        if (vertex == y && to == x) continue;
        dfs2(to, vertex);
    }
}
signed main()
{
    cin >> n;
    for (int i=0;i<n; i++){
        vector<int> help;
        data.push_back(help);
    }
    for (int i=0;i<n-1;i++){
        cin >> x >> y;
        data[x-1].push_back(y-1);
        data[y-1].push_back(x-1);
    }
    dfs(0, -1);
    vector<int> v1;
    for (int i=0; i < v.size(); i++){
        v1.push_back(v[v.size() - i - 1]);
    }
    int num = (v1.size() - 1) / 2;
    x = v1[num];
    y = v1[num+1];
    dfs2(0, -1);
    int ost = n - counter;
    if (counter - 1 >= ost){
        cout << "Fennec" << endl;
    }
    else cout << "Snuke" << endl;
    return 0;
}

Measured memory_bytes: 13552
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n, m;
  cin >> n >> m;
  vector<ll> wa(n, 0);
  vector<ll> ac(n, 0);
  rep(i, m) {
    ll p;
    string s;
    cin >> p >> s;
    p--;
    if (ac[p] == 0) {
      if (s == "AC")
        ac[p] = 1;
      else
        wa[p]++;
    }
  }
  ll sumwa = 0, sumac = 0;
  rep(i, n) if (ac[i]) sumwa += wa[i];
  rep(i, n) sumac += ac[i];
  cout << sumac << " " << sumwa << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int       N;
    long long Y;
    cin >> N >> Y;
    Y /= 1000;
    FOR(im, 0, N + 1) {
        FOR(gs, 0, N - im + 1) {
            int sen = N - im - gs;
            if (im * 10 + gs * 5 + sen == Y) {
                cout << im << " " << gs << " " << sen << endl;
                exit(0);
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    int N = 0;
    int count_before = 0;
    int count_after = 0;
    list<int> listA;
    int receive = 0;
    
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> receive;
        listA.push_back(receive);
    }
    
    count_before = listA.size();
    listA.sort();
    listA.unique();
    count_after = listA.size();

    if (count_before == count_after) {
        cout << "YES";
    }else{
        cout << "NO";
    }
    
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll W[2005][2005];

int main() {
    init();
    ll N, K;
    cin >> N >> K;
    rep(i, N){
        ll x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'B') x += K;
        x %= 2 * K, y %= 2 * K;
        W[x + 1][y + 1]++;
    }

    rep(i, 2 * K + 1) rep(j, 2 * K + 1) W[i][j + 1] += W[i][j];
    rep(i, 2 * K + 1) rep(j, 2 * K + 1) W[i + 1][j] += W[i][j];

    // rep(i, 2 * K + 1) verr(W[i], 2 * K + 1);

    ll ans = 0;
    rep(i, K) rep(j, K) {
        ll s1 = W[2 * K][2 * K] - W[i + K][2 * K] - W[2 * K][j + K] + W[i + K][j + K];
        ll s2 = W[2 * K][j] - W[i + K][j] + W[i][2 * K] - W[i][j + K];
        ll s3 = W[i + K][j + K] - W[i + K][j] - W[i][j + K] + 2 * W[i][j];
        ll s = s1 + s2 + s3;
        chmax(ans, max(N - s, s));
    }

    cout << ans << endl;
}

Measured memory_bytes: 34860
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c;
    d=10*a+b+c;
    if(d<10*b+a+c)d=10*b+a+c;
    if(d<10*c+b+a)d=10*c+b+a;
    cout << d << endl;
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

const int N = 1e5+5;
int a[N];

void fileIO()
{
        #ifndef ONLINE_JUDGE
        freopen("int.txt","r",stdin);
        freopen("out.txt","w",stdout);
        #endif
}
int main()
{
	IOS;
        //fileIO();
        int r,d,x;
        cin >> r>>d>>x;
        for(int i = 0; i < 10; i++)
        {
                x = r*x-d;
                cout << x << '\n';
        }
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long Y = sc.nextLong();
    
    for(int i=0; i <= N; i++) {
      for(int j = 0; j <= N - i; j++) {
        int l = N - i - j;
        int y = i*10000 + j*5000 + l*1000;
        
        if(y==Y){
          System.out.println(i + " " + j + " " + l );
          return;
        }
      }
    }
    System.out.println("-1 -1 -1");
  }
}
    

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

struct res{
    string name;
    int point;

    bool operator<(const res& right) const {
        return name == right.name ? point < right.point : name < right.name;
    }
};

int main() {
    int n = 0;

    cin >> n;

    vector<res> city;
    vector<res> city2;

    for (int i = 0; i < n; ++i) {
        res buf;
        cin >> buf.name >> buf.point;
        city.push_back(buf);
    }

    string min = "zzzzzzzzzz";
    int pmin = 100;
    int q = 0;
    int ans[n];
    for (int k = 0; k < n; ++k) {
        for (int j = 0; j < n; ++j) {
            if (min > city[j].name) {
                min = city[j].name;
                pmin = city[j].point;
                q = j + 1;
            } else if (min == city[j].name) {
                if (pmin < city[j].point) {
                    min = city[j].name;
                    pmin = city[j].point;
                    q = j + 1;
                }
            }
        }

        ans[k] = q;
        city[q-1].name = "zzzzzzzzzz";
        city[q-1].point = 0;
        q = 0;
        min = "zzzzzzzzzz";
    }


    for (int l = 0; l < n; ++l) {
        cout << ans[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int n = intRead();
        int[] num = SpIntRead(' ');
        Console.WriteLine(Math.Abs(num.Max() - num.Min()));
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }

}


Measured memory_bytes: 13396
#include<cstdio>
using namespace std;
inline int f(int n, int s, int t)
{
	if(!t)return n/s;
	return f(n-((n/s-t+s)/s)*s,s,(t+((n/s-t+s)/s)*(s-1))%(n/s-((n/s-t+s)/s)+1));
}
int main()
{
	int T, x=0, n, s;
	scanf("%d", &T);
	while(T--)
	{
		scanf("%d%d", &n, &s);
		x^=f(n-n%s, s, n%s);
	}
	printf(x?"Takahashi\n":"Aoki\n");
	return 0;
}

Measured memory_bytes: 1708
<?php
//------------------------------------------------
//変数を初期化
//------------------------------------------------
$flg=0;

//------------------------------------------------
//標準入力を取得
//------------------------------------------------
while($tmp=fgets(STDIN))
{
    $varInputData[]=trim($tmp);
}

//------------------------------------------------
//アンテナ間の距離Kを変数へ格納
//元の配列から削除
//------------------------------------------------
$intInputDataCounter=count($varInputData);
$intInputOutRange=$varInputData[$intInputDataCounter-1];
unset($varInputData[$intInputDataCounter-1]);

//------------------------------------------------
for($i=0;$i<$intInputDataCounter-1;$i++){
    for($j=0;$j<$intInputDataCounter-1;$j++){
        if($varInputData[$i] >= $varInputData[$j]){
            $intBetweenAntena[] = $varInputData[$i] - $varInputData[$j];
        }else{
            $intBetweenAntena[] = $varInputData[$j] - $varInputData[$i];
        }
    }
}

foreach($intBetweenAntena as $out){
    if($out > $intInputOutRange){
        exit(':(');
        break;
    }
}

echo 'Yay!';
?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  bitset<200000> X;
  cin>>N>>X;
  int M=X.count(),now1=0,now2=0;
  if(M>=2){
    for(int i=N-1;i>=0;i--)
      now1=(now1*2+X[i])%(M+1),now2=(now2*2+X[i])%(M-1);
    vector<int> v1(N),v2(N);
    v1[0]=1,v2[0]=1;
    for(int i=1;i<N;i++){
      v1[i]=v1[i-1]*2%(M+1);
      v2[i]=v2[i-1]*2%(M-1);
    }
    for(int i=0;i<N;i++){
      int n;
      if(X[N-1-i]==1)
        n=(now2-v2[N-1-i]+(M-1))%(M-1);
      else
        n=(now1+v1[N-1-i]+(M+1))%(M+1);
      int ans=1;
      for(int j=n;j>0;j%=__builtin_popcount(j))
        ans++;
      cout<<ans<<endl;
    }
  }else if(M==1){
    for(int i=N-1;i>=0;i--)
      now1=(now1*2+X[i])%(M+1);
    vector<int> v1(N);
    v1[0]=1;
    for(int i=1;i<N;i++)
      v1[i]=v1[i-1]*2%(M+1);
    for(int i=0;i<N;i++){
      if(X[N-1-i]==0){
        int n=(now1+v1[N-1-i])%(M+1);
        bitset<200000> A(n);
        int ans=1;
        for(int j=n;j>0;j%=__builtin_popcount(j))
          ans++;
        cout<<ans<<endl;
      }else
        cout<<0<<endl;
    }
  }else
    for(int i=0;i<N;i++)
      cout<<1<<endl;
}

Measured memory_bytes: 4684
import sys


def main() -> None:
    x = int(next_str())
    y = int(next_str())

    print(x + y // 2)


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> v;
  rep(i,N){
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(ALLOF(v));

  int ret = 0;
  int i = 0;
  while(i<N){
    int t = v[i]+K;
    ret++;
    int cnt = 0;
    while(i<N && v[i]<=t && cnt<C){ i++; cnt++; }
  }
  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 892
# -*- coding: utf-8 -*-
"""
Created on Wed Jan  2 21:37:24 2019

@author: Yamazaki Kenichi
"""

S = input()
ans = 999
for i in range(len(S)-2):
    temp = abs(753 - int(S[i:i+3]))
    ans = min(ans,temp)
    
print(ans)

Measured memory_bytes: 2940
k = int(input())
a=['1','2','3','4','5','6','7','8','9']

while 1:
    if k<=len(a):
        print(a[k-1])
        exit()
    b=[]
    for i in a:
        if i[-1]!='0':
            b.append(i+chr(ord(i[-1])-1))
        b.append(i+i[-1])
        if i[-1]!='9':
            b.append(i+chr(ord(i[-1])+1))
    k-=len(a)
    a=b.copy()

Measured memory_bytes: 16936
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string s; cin>>s;
    int k1 = 0;
    int k2 = 0;
    for(int i= 0;i<s.length();i++){
      if(i%2==0){
      	if(s[i] =='1') k1+=1;
        else k2+=1;
      }
      else{
      	if(s[i] == '0')k1+=1;
        else k2+=1;
      }
    }
    cout<<min(k1,k2);
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

ll n, a, b;
ll h[100005];

bool check(ll num){
	ll used = 0;
	rep(i, n){
		//do another binary search
		ll l = 0, r = num - used; //how many turns on this one
		while(l < r){
			ll mid = (l + r) / 2;
			if(h[i] - ((a * mid) + (b * (num - mid))) <= 0) r = mid;
			else l = mid + 1;
		}
		if((h[i] - ((a * l) + (b * (num - l)))) > 0) return 0;
		used += l;
		//debug2(i, used);
		//debug2(h[i], (a * l) + (b * (num - l)));
	}
	return 1;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n >> a >> b;
	rep(i, n) cin >> h[i];
	sort(h, h + n);
	reverse(h, h + n);
	ll l = 1, r = 1e10;
	while(l < r){
		ll mid = (l + r) / 2;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
x1, y1, x2, y2 = list(map(int, input().split()))

dx, dy = x2 - x1, y2 - y1

x3, y3 = x2 - dy, y2 + dx
x4, y4 = x1 - dy, y1 + dx
print(x3, y3, x4, y4)


Measured memory_bytes: 2940
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-06-27 20:01:19
 * @LastEditTime: 2020-06-27 20:01:55
 * @FilePath: \VSC\C++\Public\AC abc172 A.cpp
 */ 
#include<bits/stdc++.h>
using namespace std;

signed main(){
    int x;
    scanf("%d",&x);
    printf("%d\n",x+x*x+x*x*x);
    return 0;
}

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

using ll = long long;
using ld = long double;

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());


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

class DWizardInMaze {
public:
  
  void solve(std::istream& cin, std::ostream& cout) {
    int n, m;
    cin >> n >> m;
    pair<int, int> s, e;
    cin >> s.first >> s.second;
    cin >> e.first >> e.second;
    s.first--, s.second--;
    e.first--, e.second--;
    
    vector<string> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    vector<vector<int>> vis(n, vector<int>(m, 0));
    auto ok = [&](int x, int y) -> bool {
      if (x >= 0 and y >= 0 and x < n and y < m) return a[x][y] == '.';
      return false;
    };
    deque<pair<int, int>> q;
    vis[s.first][s.second] = 1;
    q.emplace_back(s.first, s.second);
    while (!q.empty()) {
      auto[x, y] = q.front();
      q.pop_front();
      for (int i = 0; i < 4; ++i) {
        int xx = x + dx[i];
        int yy = y + dy[i];
        if (ok(xx, yy) && (!vis[xx][yy] || vis[x][y] < vis[xx][yy])) {
          vis[xx][yy] = vis[x][y];
          q.emplace_front(xx, yy);
        }
      }
      for (int i = x - 2; i <= x + 2; ++i) {
        for (int j = y - 2; j <= y + 2; ++j) {
          if (ok(i, j) && !vis[i][j]) {
            vis[i][j] = vis[x][y] + 1;
            q.emplace_back(i, j);
          }
        }
      }
    }
    int ans = vis[e.first][e.second];
    cout << (ans ? ans - 1 : -1) << '\n';
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	DWizardInMaze solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 8684
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define MCLR(a) memset((a), -1 ,sizeof(a))
#define SZ(a) (sizeof(a))
#define FILL(a,v) fill((int*)a,(int*)(a+(SZ(a)/SZ(*(a)))),v)
bool cheak(int x, int y, int xMax, int yMax){return x >= 0 && y >= 0 && xMax > x && yMax > y;}
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 10007;
const int INF = 2147483647;

int main()
{
	int h,w;

	while (cin >> h >> w && h){
		int len = h*h + w*w;

		int th = 151, tw = 151;
		for (int i = 1; i <= 151; i++){
			for (int j = 1; j < i; j++){
				int nlen = i*i + j*j;
				int tlen = th*th+tw*tw;
				if (len  < nlen || (len  == nlen && h < j))
				if (nlen < tlen || (nlen == tlen && j < th)){
					th = j, tw = i;
				}
			}
		}

		cout << th << " " << tw << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = 2147483647;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << min(
        abs((a*b*(c/2)) - a*b*(c-c/2)),
        min(
            abs((a*c*(b/2)) - a*c*(b-b/2)),
            abs((b*c*(a/2)) - b*c*(a-a/2))
       )
    ) << endl;

    return 0;
}



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

int main()
{
  long long int h,point,jud;
  for(;;){
    cin>>h;
    if(!h) break;
    vector<int> line1(11,0);
    vector<int> line2(11,0);
    vector<int> line3(11,0);
    vector<int> line4(11,0);
    vector<int> line5(11,0);
    for(int i=h-1;i>=0;i--)
      cin>>line1[i]>>line2[i]>>line3[i]>>line4[i]>>line5[i];
    point=0;
    for(;;){
      jud=0;
      for(int i=h-1;i>=0;i--){
	if(line1[i]==line2[i]&&line1[i]==line3[i]&&line1[i]!=line4[i]&&line1[i]){
	  point+=line1[i]*3;
	  line1.erase(line1.begin()+i);
	  line2.erase(line2.begin()+i);
	  line3.erase(line3.begin()+i);
	} else if(line2[i]==line3[i]&&line2[i]==line4[i]&&line2[i]!=line5[i]&&line2[i]!=line1[i]&&line2[i]){
	  point+=line2[i]*3;
	  line2.erase(line2.begin()+i);
	  line3.erase(line3.begin()+i);
	  line4.erase(line4.begin()+i);
	} else if(line3[i]==line4[i]&&line3[i]==line5[i]&&line3[i]!=line2[i]&&line3[i]){
	  point+=line3[i]*3;
	  line3.erase(line3.begin()+i);
	  line4.erase(line4.begin()+i);
	  line5.erase(line5.begin()+i);    
	} else if(line1[i]==line2[i]&&line1[i]==line3[i]&&line1[i]==line4[i]&&line1[i]!=line5[i]&&line1[i]){
	  point+=line1[i]*4;
	  line1.erase(line1.begin()+i);
	  line2.erase(line2.begin()+i);
	  line3.erase(line3.begin()+i);
	  line4.erase(line4.begin()+i);
	} else if(line2[i]==line3[i]&&line2[i]==line4[i]&&line2[i]==line5[i]&&line2[i]!=line1[i]&&line2[i]){
	  point+=line2[i]*4;
	  line2.erase(line2.begin()+i);
	  line3.erase(line3.begin()+i);
	  line4.erase(line4.begin()+i);
	  line5.erase(line5.begin()+i);
	} else if(line1[i]==line2[i]&&line1[i]==line3[i]&&line1[i]==line4[i]&&line1[i]==line5[i]&&line1[i]){
	  point+=line1[i]*5;
	  line1.erase(line1.begin()+i);
	  line2.erase(line2.begin()+i);
	  line3.erase(line3.begin()+i);
	  line4.erase(line4.begin()+i);
	  line5.erase(line5.begin()+i);
	} else {
	  jud++;
	}
      }
      if(jud==h) break;
    }
    cout<<point<<endl;
  }
}


Measured memory_bytes: 1216
x1, y1, x2, y2 = map( int, input().split())

x = x1 - x2
y = y1 - y2
#a1 = y / x
#a2 = -1 / a1
#l = sqrt(x ** 2 + y ** 2)

x3 = x2 + y
y3 = y2 - x
x4 = x3 + x
y4 = y3 + y

print( x3, y3, x4, y4)

Measured memory_bytes: 2940
#include<cstdio>
int x,a,b,c,ans;
int main()
{
	//a:500 b:100 c:50
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(500*i+100*j+50*k==x)
					ans++;
	printf("%d\n",ans);
}

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

using namespace std;

#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 rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
        cout << a * b << endl;
    } else cout << -1 << endl;
    
    return 0;
}



Measured memory_bytes: 256
import bisect
n = int(input())
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(int(i))
        i += 1
    if n > 1: table.append(int(n))
    table.sort()
    return table
ans = 0
d = prime_decomposition(n)
for i in list(set(d)):
    index_l = bisect.bisect_left(d, i)
    index_r = bisect.bisect_right(d, i)
    i = 1
    res = index_r-index_l
    while True:
        res -= i
        ans += 1
        if res == 0:
            break
        if res < 0:
            ans -= 1
            break
        i += 1
print(ans)



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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

char input(){
  char a;
  cin >> a;
  return a;
}

int main(){
  ll n,k,q;
  cin >> n >> k >> q;
  vector<ll> v(n,k-q);
  REP(i,q){
    ll a;
    cin >> a;
    v.at(a-1)++;
  }
  REP(i,n)cout << (v.at(i)>0?"Yes":"No") << endl;
}

Measured memory_bytes: 1408
#!/usr/bin/env python3
import sys
from fractions import gcd
input = sys.stdin.readline
 
class DisjointSparseTable:
    def __init__(self, a):
        # Identity element
        self.e = 0
        self.n = len(a)
        self.level = (len(a) - 1).bit_length()
        self.size = 2**self.level
        self.table = [[self.e] * self.size for _ in range(self.level)]
        # Set bottom first
        for i, item in enumerate(a):
            self.table[-1][i] = item
        self.build()
 
    def build(self):
        for i in range(1, self.level):
            step = 2**i
            lv = self.level - 1 - i
            for mid in range(step, self.n + step, step*2):
                if mid - step >= self.n:
                    continue
                # Forward
                val = self.e 
                for j in range(step):
                    val = gcd(self.table[-1][mid + j], val)
                    self.table[lv][mid + j] = val
                # Backward
                val = self.e
                for j in range(step):
                    val = gcd(self.table[-1][mid - 1 - j], val)
                    self.table[lv][mid - 1 - j] = val
 
    # Returns f[l:r)
    def query(self, l, r):
        if l == r:
            return self.e
        elif l == r - 1:
            return self.table[-1][l]
        lv = self.level - (l ^ r-1).bit_length()
        return gcd(self.table[lv][l], self.table[lv][r-1])
 
 
if __name__ == "__main__":
    n = int(input())
    a = [int(item) for item in input().split()]
    DST = DisjointSparseTable(a)
    ans = 0
    for i in range(0, n):
        ans = max(ans, gcd(DST.query(0, i), DST.query(i+1, n)))
    print(ans)

Measured memory_bytes: 30124
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        S: chars,
        T: chars,
    };
    let mut t_itr = T.iter();
    let mut result = true;
    for s in S{
        if let Some(t) = t_itr.next(){
            if &s != t{
                result = false;
                break;
            }
        }
    }
    if result{
        println!("Yes");
    }else{
        println!("No")
    }



}


Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    int t, x;
    cin >> t >> x;

    printf("%.10f\n", (double)t/x);

    return 0;

}

Measured memory_bytes: 256
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        c = [list(map(int, input().split())) for _ in range(3)]
        for a1 in range(101):
            for b1 in range(101 - a1):
                a2 = c[1][0] - b1
                a3 = c[2][0] - b1
                b2 = c[0][1] - a1
                b3 = c[0][2] - a1
                if c[0][0] == a1 + b1 and c[1][1] == a2 + b2 and c[1][2] == a2 + b3 and c[2][1] == a3 + b2 and c[2][2] == a3 + b3:
                    print('Yes')
                    exit()
        print('No')


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 38512
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

///////////////////////////////////////////////////

func main() {
	log.SetFlags(log.Lshortfile)
	scn := newScanner()
	N := scn.nextInt()
	M := scn.nextInt()
	// ２部グラフ判定(蟻本p94)
	b := true
	G := make([][]int, N)
	color := make([]int, N) // 頂点iの色(1 or -1)
	for i := 0; i < M; i++ {
		a := scn.nextInt() - 1
		b := scn.nextInt() - 1
		G[a] = append(G[a], b)
		G[b] = append(G[b], a)
	}
	var dfs func(int, int) bool
	dfs = func(v, c int) bool {
		color[v] = c
		for i := 0; i < len(G[v]); i++ {
			if color[G[v][i]] == c {
				return false
			}
			if color[G[v][i]] == 0 && !dfs(G[v][i], -c) {
				return false
			}
		}
		return true
	}
	for i := 0; i < N; i++ {
		if color[i] == 0 {
			if !dfs(i, 1) {
				b = false
			}
		}
	}
	if b {
		log.Println("二部グラフ")
		cnt := 0 // color 1　の数
		for i := 0; i < N; i++ {
			if color[i] == 1 {
				cnt++
			}
		}
		fmt.Println(cnt*(N-cnt) - M)
	} else {
		log.Println("完全グラフ")
		fmt.Println(N*(N-1)/2 - M)
	}
}

///////////////////////////////////////////////////
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) nextInt64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<vector<int>> to, co;
vector<int> node;
bool dfs(int now, int prev) {
  rep(i, to[now].size()) {
    if (to[now][i] == prev)
      continue;
    if (node[to[now][i]] == INF) {
      node[to[now][i]] = node[now]+co[now][i];
      if (!dfs(to[now][i], now))
        return false;
    } else if (node[to[now][i]] != node[now]+co[now][i])
      return false;
  }
  return true;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  to.resize(n);
  co.resize(n);
  rep(i, m) {
    int l, r, d;
    cin >> l >> r >> d;
    --l, --r;
    to[l].push_back(r);
    co[l].push_back(d);
    to[r].push_back(l);
    co[r].push_back(-d);
  }
  node.resize(n, INF);
  rep(i, n) {
    if (node[i] != INF)
      continue;
    node[i] = 0;
    if (!dfs(i, -1)) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 19088
#include <stdio.h>

const int Mod = 1000000007;

typedef struct List {
	struct List *next;
	long long v, l, r;
} list;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int main()
{
	int i, N, u, w;
	list *adj[200001] = {}, e[400001], *p;
	scanf("%d", &N);
	for (i = 0; i < N - 1; i++) {
		scanf("%d %d", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
	}

	long long ans = 0, tmp, pow[200001];
	for (i = 1, pow[0] = 1; i <= N; i++) pow[i] = pow[i-1] * 2 % Mod;
	
	int flag[200001] = {}, q[200001], head, tail;
	flag[1] = -1;
	q[0] = 1;
	for (head = 0, tail = 1; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			if (flag[w] == 0) {
				flag[w] = -1;
				q[tail++] = w;
			}
		}
	}
	for (head--; head >= 0; head--) {
		u = q[head];
		flag[u] = 1;
		tmp = pow[N-1] - 1;
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			if (flag[w] != -1) {
				flag[u] += flag[w];
				tmp += Mod - pow[flag[w]] + 1;
			}
		}
		tmp += Mod - pow[N-flag[u]] + 1;
		ans += tmp;
	}
	
	printf("%lld\n", div_mod(ans % Mod, pow[N], Mod));
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 18912
n, m, x = map(int, input().split())
c = [0] * n
a = [[0 for _ in range(m)] for i in range(n)]

for i in range(n):
    l = [int(_) for _ in input().split()]
    c[i]=l[0]
    for j in range(m):
        a[i][j] = l[j+1]

inf=float('inf')
ans=inf
for i in range(2 ** n):
    cost = 0
    d=[0]*m
    for j in range(n):
        if i >> j & 1:
            cost += c[j]
            for k in range(m):
                d[k] += a[j][k]

    ok = True
    for y in range(m):
        if d[y] < x:
            ok = False
    if ok:
        ans = min(ans, cost)
if ans == inf:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9216
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, s, *a = map(int, read().split())
dp = [0] * (s + 1)
dp[0] = 1
mod = 998244353
for aa in a:
    for j in range(s, -1, -1):
        ss = j + aa
        if ss <= s:
            dp[ss] += dp[j]
            dp[ss] %= mod
        dp[j] *= 2
        dp[j] %= mod
print(dp[-1])


Measured memory_bytes: 68452
import sys
from bisect import bisect_left, bisect_right, insort

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = list('-' + sr())
d = [[] for _ in range(26)]
for i in range(1, N+1):
    s = S[i]
    o = ord(s) - ord('a')
    d[o].append(i)

Q = ir()
for _ in range(Q):
    q, a, b = sr().split()
    if q == '1':
        a = int(a)
        if S[a] == b:
            continue
        prev = ord(S[a]) - ord('a')
        d[prev].pop(bisect_left(d[prev], a))
        next = ord(b) - ord('a')
        insort(d[next], a)
        S[a] = b
    else:
        a = int(a); b = int(b)
        ans = 0
        for alpha in range(26):
            if bisect_right(d[alpha], b) - bisect_left(d[alpha], a) >= 1:
                ans += 1
        print(ans)


Measured memory_bytes: 95708
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let n: i64 = s.trim().parse().unwrap();
	let f = factorize(n);
	let mut ans = 0;
	for (_, mut e) in f {
		let mut a = 1;
		while e >= a {
			e -= a;
			a += 1;
			ans += 1;
		}
	}
	println!("{}", ans);
}

fn factorize(mut n: i64) -> Vec<(i64, u32)> {
	let mut r = vec![];
	for i in 2.. {
		if i * i > n {
			break;
		}
		let mut e = 0;
		while n % i == 0 {
			e += 1;
			n /= i;
		}
		if e > 0 {
			r.push((i, e));
		}
	}
	if n != 1 {
		r.push((n, 1));
	}
	r
}


Measured memory_bytes: 2132
from collections import deque
import heapq

def dijkstra(s,g):
    color=[0]*n
    dis={}
    for i in xrange(n):
        dis[i]=float('inf')
    dis[s]=0
    heapq.heappush(pq,[0,s])
    while len(pq)!=0:
        t,u=heapq.heappop(pq)
        color[u]=2
        if dis[u]<t:
            continue
        for v,cost in g[u]:
            if color[v]!=2:
                if dis[u]+cost<dis[v]:
                    dis[v]=dis[u]+cost
                    color[v]=1
                    heapq.heappush(pq,[dis[v],v])
    return dis

n,m,c=map(int,raw_input().split())
g=[[] for _ in xrange(n)]
totalcost=0
for i in xrange(m):
    a,b,d=map(int,raw_input().split())
    g[a-1].append([b-1,d])
    g[b-1].append([a-1,d])
    totalcost+=d

pq=[]
dis=dijkstra(0,g)
dis=sorted(dis.items(), key=lambda x:x[1])

ans=float('inf')
visited=[0]*n
for u,x in dis:
    visited[u]=1
    for v,cost in g[u]:
        if visited[v]==1:
            totalcost-=cost
    ans=min(ans,totalcost+c*x)
print ans

Measured memory_bytes: 100004
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

ll solve(ll k){
  if(k < 10) return k;
  vvll dp(10, vll(10, 0));
  for(int i = 0; i < 10; i++) dp[0][i] = 1;
  ll s = 9;
  for(int i = 1; i < 10; i++){
    for(int j = 0; j < 10; j++){
      if(j == 0){
        dp[i][0] = dp[i-1][0] + dp[i-1][1];
        continue;
      }
      dp[i][j] = (j > 0) * dp[i-1][j-1] + dp[i-1][j] + (j < 9) * dp[i-1][j+1];
      if(s + dp[i][j] >= k){
        ll ans = 0;
        while(i+1){
          if(s + dp[i][j] >= k){
            ans = ans * 10 + j;
            if(j > 0) j--;
            i--;
          }
          else{
            s += dp[i][j];
            if(j < 9) j++;
          }
        }
        return ans;
      }
      s += dp[i][j];
    }
  }
  return 0;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  ll k; cin >> k;
  cout << solve(k) << endl;
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //




// --------- library end - //


int main(){

  ll N = il();
  vector<ll> ls;
  rep(i, N){
    ls.push_back(il());
  }
  // 昇順ソート
  sort(begin_end(ls));

  ll ans = 0;
  rep(i, N-2) REP(j, i+1, N-1) REP(k, j+1, N){
    // i : 0 ~ N-3
    // j : i+1 ~ N-2
    // k : j+1 ~ N-1
    ll li = ls[i];
    ll lj = ls[j];
    ll lk = ls[k];
    if (li == lj || lj == lk || li == lk) continue;
    if (lk >= li + lj) continue;
    ans++;
  }

  cout << ans << endk;
  

}

Measured memory_bytes: 3684
#include <stdio.h>
 
 #define N 8
 #define FREE 0
 #define NOT_FREE 1
 
 void putQueen(int);
 void PrintBoard(void);
 
 int Queen[N][N];
 int dpos[2*N-1];
 int dneg[2*N-1];
 int row[N];
 int col[N];
 
 int main(){
 
 int i;
 int n;
 int q_row;
 int q_col;
 
 scanf("%d",&n);
 
 for(i=0;i<n;i++){
 scanf("%d%d",&q_row,&q_col);
 Queen[q_row][q_col] = NOT_FREE;
 }
 
 putQueen(0);
 
   return 0;
}
void putQueen(int i){
 
 int j;
 
 if(i==N){
 PrintBoard();
 return;
 }
 
 for(j=0;j<N;j++){
 if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+N-1]==NOT_FREE) continue;
 
 row[i] = j;
 col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
 putQueen(i+1);
 
 col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
 }
 
}
void PrintBoard(void){
 
 int i;
 int j;
 
 for(i=0;i<N;i++){
  for(j=0;j<N;j++){
 
 if(Queen[i][j]==NOT_FREE){
    if(row[i]!=j) return;
    }
 
   }
  }
 
 for(i=0;i<N;i++){
  for(j=0;j<N;j++){
 
 if(row[i]==j){
  printf("Q");
   }
 
 else{
  printf(".");
   }
 
   }
  printf("\n");
   }
 }

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
 
int main() {
  int N;
  cin >> N;
  
  vi V = vi(N);
  REP(i, N) cin >> V.at(i);
  
  vi C = vi(N);
  REP(i, N) cin >> C.at(i);
  
  int r = 0;
  REP(i, N) {
    if (C.at(i) < V.at(i))
      r += V.at(i) - C.at(i);
  }
  
  cout << r << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <set>
typedef long long int64;
static const int MAXN = 1e5 + 4;

int n, a[MAXN * 3];
std::multiset<int> lf, rg;
int64 lf_sum[MAXN * 3], rg_sum[MAXN * 3];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n * 3; ++i) scanf("%d", &a[i]);

    int64 s;
    s = 0;
    for (int i = 0; i < n; ++i) lf.insert(a[i]), s += a[i];
    lf_sum[n - 1] = s;
    for (int i = 0; i < n; ++i) {
        if (a[i + n] > *lf.begin()) {
            s -= *lf.begin();
            lf.erase(lf.begin());
            s += a[i + n];
            lf.insert(a[i + n]);
        }
        lf_sum[i + n] = s;
    }

    s = 0;
    for (int i = 0; i < n; ++i) rg.insert(a[n * 3 - 1 - i]), s += a[n * 3 - 1 - i];
    rg_sum[n * 2] = s;
    for (int i = 0; i < n; ++i) {
        if (a[n * 2 - 1 - i] < *rg.rbegin()) {
            s -= *rg.rbegin();
            rg.erase(rg.find(*rg.rbegin()));
            s += a[n * 2 - 1 - i];
            rg.insert(a[n * 2 - 1 - i]);
        }
        rg_sum[n * 2 - 1 - i] = s;
    }

    int64 ans = -1LL << 62, cur = 0;
    for (int i = 0; i <= n; ++i)
        ans = std::max(ans, lf_sum[i + n - 1] - rg_sum[i + n]);

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 14976