akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define irep(i, n) for (ll i = n-1; i >= 0; i--)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll T;
    cin >> T;
    rep(_, T) {
        ll N;
        cin >> N;
        vll K(N), L(N), R(N);
        vvll VL(N+1), VR(N+1);
        ll ans = 0;
        rep(i, N) {
            cin >> K[i] >> L[i] >> R[i];
            K[i]--;
            if(L[i] > R[i]) {
                ans += R[i];
                VL[K[i]].push_back(L[i]-R[i]);
            }
            else {
                ans += L[i];
                VR[K[i]].push_back(R[i]-L[i]);
            }
        }

        priority_queue<ll, vll, greater<ll>> pq1;
        rep(i, N) {
            for(auto x : VL[i]) pq1.push(x);
            while(i+1 < pq1.size()) {
                pq1.pop();
            }
        }
        while(!pq1.empty()) {
            ans += pq1.top();
            debug(pq1.top())
            pq1.pop();
        }

        priority_queue<ll, vll, greater<ll>> pq2;
        irep(i, N) {
            for(auto x : VR[i]) pq2.push(x);
            while(N-1-i < pq2.size()) {
                pq2.pop();
            }
        }
        while(!pq2.empty()) {
            ans += pq2.top();
            debug(pq2.top())
            pq2.pop();
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 24272
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    int n;
    vi v(n);
    vi c(n);
    cin >> n;
    REP(i, n)
    {
        cin >> v[i];
    }
    REP(i, n)
    {
        cin >> c[i];
    }

    int ans = 0;
    REP(i, n)
    {
        if(v[i] > c[i])
        {
            ans += v[i] - c[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>

#pragma warning(disable: 4996)

#define MOD 100000

#define MAX_M 2000
#define MAX_S 3000

int N, M, S;

int dp[2][MAX_M + 1][MAX_S + 1];

int main()
{
	while (true)
	{
		scanf("%d", &N);
		scanf("%d", &M);
		scanf("%d", &S);

		if (N == 0 && M == 0 && S == 0) { break; }

		for (int i = 0; i < M; i++)
		{
			for (int j = 0; j < S; j++)
			{
				if (i == j && i != 0 && j != 0)
				{
					dp[1][i][j] = 1;
				}
				else
				{
					dp[1][i][j] = 0;
				}
			}
		}

		int A = N * N;

		for (int n = 2; n <= A; n++)
		{
			for (int i = 0; i < M; i++)
			{
				dp[n % 2][i][0] = 0;
			}

			for (int j = 0; j < S; j++)
			{
				dp[n % 2][0][j] = 0;
			}

			for (int i = 1; i <= M; i++)
			{
				for (int j = 1; j <= S; j++)
				{
					if (n % 2 == 0)
					{
						dp[0][i][j] = (dp[0][i - 1][j - 1] + (j >= i ? dp[1][i - 1][j - i] : 0)) % MOD;
					}
					else
					{
						dp[1][i][j] = (dp[1][i - 1][j - 1] + (j >= i ? dp[0][i - 1][j - i] : 0)) % MOD;
					}
				}
			}
		}

		int sum = 0;

		for (int i = 1; i <= M; i++)
		{
			if (A % 2 == 0)
			{
				sum += dp[0][i][S];
			}
			else
			{
				sum += dp[1][i][S];
			}

			sum %= MOD;
		}

		printf("%d\n", sum);
	}

	return 0;
}

Measured memory_bytes: 49504
// Problem: C - Marks
// Contest: AtCoder - M-SOLUTIONS Programming Contest 2020
// URL: https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_c
// 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 <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> arr(n);
	for(auto& e : arr) cin >> e;
	int start = 0;
	int stop = k;
	while(stop < n)
	{
		if(arr[start] < arr[stop]) cout <<"Yes\n";
		else cout <<"No\n";
		start++;
		stop++;
	}
	return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>

using namespace std;

typedef pair<int, int> P;

int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};

// ??¶???????????????????§???????
struct status{
	int count, to;
	int p[10][10];
	status(int c=0, int t=0, status *old=NULL){	//???????????????????????§??¨???????????????????????§???????????????????????????
		if( old ) *this = *old;		// ??¨?????????(memcpy()???????\???§?????????????°???????)
		else fill(p[0], p[0]+10*10, 0);	//?????????????????????????????????????????????????????§
		count = c;
		to = t;
	}
};

int main(){
	int h, w, c;
	while(cin>>h>>w>>c, h|w|c){
		// ???????????§?????°??????????????¨??????????????°???????????§??????
		stack<status> st;
		int ans = 0;
		
		// ??????????????????
		status in;
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				cin >> in.p[i][j];
			}
		}
		in.to = in.p[1][1];
		in.p[1][1] = 8;
		
		// ??±???????????¢?´¢
		st.push( in );
		while( !st.empty() ){
			status s = st.top(); st.pop();
			// s.to??????????????´
			vector< P > check;	//stack??§???????????£??????ans?????°???????????????????????????vector????????´
			for(int i=1; i<=h; i++){	// (1,1)??¨??????????????¨????????¢???
				for(int j=1; j<=w; j++){
					if( s.p[i][j] == 8 )
						check.push_back( make_pair(i, j) );
				}
			}
			for( int i=0; i<check.size(); i++ ){	// ??£??\??¨???????????????
				int y = check[i].first, x = check[i].second;
				for(int k=0; k<4; k++){
					if( s.p[ y+vy[k] ][ x+vx[k] ] == s.to ){
						s.p[ y+vy[k] ][ x+vx[k] ] = 8;
						check.push_back( make_pair( y+vy[k], x+vx[k] ) );
					}
				}
			}
			// ?¬?????????????????????????
			if( s.count == 5 ){		// ?????????
				ans = max( ans, (int)check.size() );	//?????§???????????´??°
			}else if( s.count == 4 ){
				st.push( status(s.count+1, c, &s) );
			}else{
				for(int i=1; i<=6; i++){
					if( i != s.to ){
						st.push( status(s.count+1, i, &s) );
					}
				}
			}
		}
		
		// ??????
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
/*
Author : N_o_o_B
Created : April 11 2020 15:03:52 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    ll n,k;
    cin >> n >> k;
    n %= k;
    cout << min(n,k-n) << endl;



    time_taken();
    return 0;
}

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

int main(int argc, char *argv[])
{
  string inp;
  int sum = 700;
  cin >> inp;
  for (int i = 0; i < inp.size(); ++i) {
    if(inp[i] == 'o'){
      sum += 100;
    }
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n, combo = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int a, b;
        cin >> a >> b;
        if (a == b)
        {
            combo++;
        }
        else
        {
            combo = 0;
        }
        if (combo == 3)
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}


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

int main() {
  string S;
  int f=1,N;
  cin>>N;
  for (int i = 0; i < N; i++) {
    cin>>S;
    if (S=="Y") f=0;
  }
 if(f==0) cout<<"Four"<<endl;
 else cout<<"Three"<<endl;
}


Measured memory_bytes: 256
main = do
  xs <- map read . words <$> getLine
  print $ solve2 xs
solve2 (a : b : c : d : _)
    | b_c <= 0 || a_d >= 0 = 0
    | a_c <= 0 && b_d >= 0 = d - c
    | a_c >= 0 && b_d <= 0 = b - a
    | a_c >= 0 && b_d >= 0 = d - a
    | a_c <= 0 && b_d <= 0 = b - c
  where
    a_c = a - c
    b_d = b - d
    b_c = b - c
    a_d = a - d


Measured memory_bytes: 508
import queue
h,w=map(int,input().split())
INF=10**9
s=[[-1]* w for _ in range(h)]
b=0
for i in range(h):
	x=input()
	for j in range(w):
		if x[j]==".":
			s[i][j] = INF
		else:
			b+=1

q=queue.Queue()
s[0][0]=0
q.put((0,0))

def test(x,y,t):
	if 0<=x<h and 0<=y<w:
		u=s[x][y]
		if t<u:
			s[x][y]=t
			q.put((x,y))

while not q.empty():
	x,y=q.get()
	t=s[x][y]
	test(x+1,y,t+1)
	test(x-1,y,t+1)
	test(x,y+1,t+1)
	test(x,y-1,t+1)

x=s[h-1][w-1]
print(-1 if x==INF else h*w-b-x-1)

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

int main(void) {
	int n, a, b,ten,one,sum = 0,hundred,sen,man;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		man = i / 10000;
		sen = (i - man * 10000) / 1000;
		hundred = (i-man*10000-sen*1000) / 100;
		ten = (i-man*10000-sen*1000-hundred*100) / 10;
		one = (i - man * 10000 - sen * 1000 - hundred * 100 - ten * 10);
		if (one + ten+hundred+sen+man >= a && one + ten + hundred + sen + man <= b) {
			sum += i;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var forecast = Console.ReadLine();
            var result = Console.ReadLine();
            var count = 0;
            for (int i = 0; i < forecast.Length; i++)
            {
                if (forecast[i] == result[i])
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>  // std::fill
#include <iostream>
#include <string>
#include <vector>

int main(void) {
    using namespace std;
    string s;
    cin >> s;

    vector<int> ans(s.length());
    fill(ans.begin(), ans.end(), 0);

    int r_count = 1;  // RLの子のうち，Rのみを考える
    for (int i = 1; i < s.length(); ++i) {
        if (s.at(i) == 'R') {
            r_count++;
        } else if (r_count) {  // 左にRがr_count個連なるL

            // RLのLから偶数マス離れたR
            ans.at(i) = r_count / 2;
            // RLのRから偶数マス離れたR
            ans.at(i - 1) = (r_count + 1) / 2;

            // 次のRLの子を数えるので0にする
            r_count = 0;
        }
    }

    int l_count = 1;  // RLの子のうち，Lのみを考える
    for (int i = s.length() - 2; i >= 0; --i) {
        if (s.at(i) == 'L') {
            l_count++;
        } else if (l_count) {  // 右にLがl_count個連なるR

            // RLのRから偶数マス離れたL
            ans.at(i) += l_count / 2;
            // RLのLから偶数マス離れたL
            ans.at(i + 1) += (l_count + 1) / 2;

            // 次のRLの子を数えるので0にする
            l_count = 0;
        }
    }

    for (int i = 0; i < ans.size(); ++i) {
        cout << ans.at(i) << (i + 1 != ans.size() ? ' ' : '\n');
    }

    return 0;
}

Measured memory_bytes: 1024
<?php
$N = intval(trim(fgets(STDIN)));
$A = explode(' ', trim(fgets(STDIN)));
sort($A);
$res = 0;
$cnt = 0;
$maxi = 100000000000;
for ($i = 0; $i < $N; $i++) {
  $res += abs($A[$i]);
   $maxi = min($maxi, abs($A[$i]));
  if ($A[$i] <= 0) {
    $cnt++;
  }
}
if ($cnt % 2) $res -= 2 * $maxi;
echo $res;


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

bool isupper(char c) {
  return 'A' <= c && c <= 'Z';
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  string S, b = "";
  cin >> S;
  if (S[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }
  REP(i, S.size()) {
    if (isupper(S[i])) {
      if (i == 1 || i == S.size()-1) {
        cout << "WA" << endl;
        return 0;
      }
      b += S[i];
    }
  }
  if (b == "AC") {
    cout << "AC" << endl;
    return 0;
  } else {
    cout << "WA" << endl;
  }
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 h,w;
    cin >> h >> w;
    char s[h][w];
    REP(i,h)REP(j,w)cin >> s[i][j];
    vector<vector<int32>> cnt(h, vector<int32>(w, 0));
    REP(i,h){
        int32 x = 0;
        REP(j,w){
            if(s[i][j] == '.'){
                x++;
            }else{
                x = 0;
            }
            cnt[i][j] += x;
        }
    }
    REP(i,h){
        int32 x = 0;
        FORR(j,w-1,0){
            if(s[i][j] == '.'){
                x++;
            }else{
                x = 0;
            }
            cnt[i][j] += x;
        }
    }
    REP(j,w){
        int32 x = 0;
        REP(i,h){
            if(s[i][j] == '.'){
                x++;
            }else{
                x = 0;
            }
            cnt[i][j] += x;
        }
    }
    REP(j,w){
        int32 x = 0;
        FORR(i,h-1,0){
            if(s[i][j] == '.'){
                x++;
            }else{
                x = 0;
            }
            cnt[i][j] += x;
        }
    }
    int32 res = 1;
    REP(i,h)REP(j,w){
        res = max(cnt[i][j]-3, res);
    }
    ANS(res);
    return 0;
}

Measured memory_bytes: 37504
n = int(input())
x = [list(map(int, input().split())) for i in range(n)]
def kaijo(a):
    s = 1
    for i in range(2,a+1):
        s = s * i
    return(s)
l = []
for i in range(n):
    for j in range(n):
        if not i == j:
            l.append(((x[i][0]-x[j][0])**2+(x[i][1]-x[j][1])**2)**0.5)
print(sum(l)*kaijo(n-1)/kaijo(n))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
    //mint(2).pow(n); 2^n
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[10005][105][2];//1 未満


ll F(ll d, ll k){
  while(k<0)k+=d;
  return k;
}
int main() {
  string k;
  ll d;
  cin>>k>>d;
  vector<ll>s(k.size());
  rep(i,k.size())s[i]=k[i]-'0';
  rep(i,10005)rep(q,105)rep(j,2)dp[i][q][j]=0;
  dp[0][0][0]=1;

  rep(i,k.size())rep(j,d){

  //  if ((j-s[i])<0){
      //s[i]-=10;

  //  dp[i+1][j][0]+=dp[i][j-s[i]+d][0];
//


      dp[i+1][j][0]+=dp[i][F(d,j-s[i])][0];


     rep(q,10){
    //   cout<<j-k+d<<' '<<dp[i][j-k+d][1]<<endl;
      // if ((j-k)<0) dp[i+1][j][1]+=dp[i][j-k+d][1];
        dp[i+1][j][1]+=dp[i][F(d,j-q)][1];
    //   cout<<dp[i+1][j][1]<<'q'<<q<<endl;
      }
      rep(q,s[i]){
      //  if ((j-q)<0) dp[i+1][j][1]+=dp[i][j-q+d][0];
         dp[i+1][j][1]+=dp[i][F(d,j-q)][0];
      //   cout<<dp[i+1][j][1]<<'q'<<q<<endl;

       }


       //cout<<dp[i+1][j][0]<<' '<<dp[i+1][j][1]<<'i'<<i<<'j'<<j<<endl;
}

mint ans=dp[k.size()][0][1];
ans+=dp[k.size()][0][0];
ans-=1;
cout<<ans.x;
}


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

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int M = reader.nextInt();
		int D = reader.nextInt();
		int ans = 0;
		for (int m=1; m<=M; m++) {
		    for (int d=1; d<=D; d++) {
		        int d1  = d%10;
		        int d10 = (d-d1)/10;
		        if (d1 >= 2 && d10 >= 2 && d1*d10 == m) {
		            ans++;
		        }
		    }
		}
		System.out.println(ans);
	}
	
	public static void solver(int N, int[] H) {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 20944
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int f(int n,int d,int x){
  if(d>n){
    return 0;
  }
  int ans=0;
  vector<int> ds{3, 5, 7};
  for(int i=0; i<3; i++){
    int next_x = d*ds[i] + x;
    if(next_x > n){
      break;
    }
    map<int, int> mp;
    int tmp=next_x;
    while(tmp){
      mp[tmp%10]++;
      tmp /= 10;
    }
    bool can=true;
    for(int j=0; j<3; j++){
      if(mp.find(ds[j]) == mp.end()){
        can =false;
        break;
      }
    }
    if(can){
      ans++;
    }
    ans += f(n,d*10, next_x);
  }
  return ans;
}


int main(){
  int N;
  cin >> N;
  cout << f(N, 1, 0);
  return 0;
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s):
    if 'LOCAL' in os.environ:
        print(s)

def main():
    global PX, nodes
    if 'BIG' in os.environ:
        N = 2* 10** 5
        Q = 2 * 10 ** 5
        AB = [[i, i + 1] for i in range(1, N)]
        PX = [[i, 10] for i in range(Q)]
    else:
        N, Q = LI()
        #  AB = []
        nodes = [[] for _ in range(N+1)]
        PX = [0] * (N+1)
        for i in range(N-1):
            a, b = LI()
            #  AB += (a, b)
            nodes[a].append(b)
            nodes[b].append(a)

        for i in range(Q):
            p, x = LI()
            PX[p] += x
        dfs(1, -1)
        print(' '.join(map(lambda x: str(x), PX[1:])))
        #  for i in PX[1:]:
        #      print(i, end=' ')
        #  ans = [0 for _ in range(N)]

def dfs(parent, parent_parent):
    for node in nodes[parent]:
        if node != parent_parent:
            PX[node] += PX[parent]
            dfs(node, parent)

if __name__ == '__main__':
    main()


Measured memory_bytes: 236048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
    int n;
    cin >> n;
    unordered_set<int> s;
    rep(i, n) {
        int x;
        cin >> x;
        if (s.count(x)) s.erase(x);
        else s.insert(x);
    }
    cout << (int)s.size() << endl;
}

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

#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}

ll mod(ll a, ll b) {return (a % b + b) % b;}

ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}

using namespace std;

int main() 
{	
	fast;
	ll a,b,n;
	cin>>a>>b>>n;
	ll t = min(b-1,n);
	ll tt = (a*t) / b;
	ll ttt = a * (t/b);
	cout << tt - ttt << endl;
 	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    int n;
    int *a;
    a = new int[MAX];
    
    int mi = INTINF;
    int mi_i = 0;
    cin >> n;
    rep(i, n){
        cin >> a[i];
        if(mi>a[i]){
            mi = a[i];
            mi_i = i;
        }
    }
    
    queue<int> q;
    q.push(mi);
    int tmp_mi = INTINF;
    rep(i, n){
        if(i != mi_i){
            a[i] %= mi;
            if(a[i]){
                q.push(a[i]);
                tmp_mi = min(tmp_mi, a[i]);
            }
        }
    }
    mi = min(mi, tmp_mi);
    
    while(q.size() > 1){
        queue<int> q2;
        tmp_mi = INTINF;
        while(!q.empty()){
            int foo = q.front(); q.pop();
            foo %= mi;
            if(foo){
                q2.push(foo);
                tmp_mi = min(tmp_mi, foo);
            }
        }
        q2.push(mi);
        mi = tmp_mi;
        q = q2;
    }
    
    cout << q.front() << endl;
    
    return 0;
}


Measured memory_bytes: 1024
//بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    string s;
    cin >> n >> q >> s;
    int a[n];
    a[0] = 0;
    for(int i = 1; i < n; i++) a[i] = a[i-1] + (s[i] == 'C' && s[i-1] == 'A');
    while(q--){
        int l, r;
        cin >> l >> r;
        int o;
        if(l == 1) o = a[r-1];
        else{
            o = a[r-1] - a[l-2];
            if(s[l-1] == 'C' && s[l-2] == 'A') o--;
        }
        cout << o << endl;
    }
}


Measured memory_bytes: 1488
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,K,ans=0;
  string S;
  cin>>N>>K>>S;
  
  for(int i=0; i<S.size()-1; ++i){
    if(S.at(i)==S.at(i+1)) ans++;
  }
  
  cout<<min(ans+2*K,N-1)<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int counta=100;
    int countz=0;
    for(int i=0; i<s.size(); i++){
        if(s.at(i)=='A'){
        counta=i;
        break;
        }
    }
    for(int i=counta; i<s.size(); i++){
        if(s.at(i)=='Z')countz=i;
    }
    if(countz-counta>0)cout<<countz-counta+1<<endl;
    else cout<<0<<endl;
}



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


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


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(30);

    ll x, y; cin >> x >> y;
    int ans = 0;
    while(x <= y) {
        x*=2;
        ++ans;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
MOD=10**9+7
$ans=Hash.new(0)
def div_prime(x)
    2.upto((N**0.5).to_i+1) do|i|
      while (x%i).zero?
          $ans[i]+=1
          x/=i
      end
    end
    $ans[x]+=1 if x!=1
end
1.upto(N) do|x|
  div_prime(x)
end
puts $ans.inject(1){|res,x| res*=x[1]+1;res%=MOD}

Measured memory_bytes: 14548
day_count = int(input())
decline = list(map(int,input().split()))
score_list = []
schedule = [0] * 26
for i in range(day_count):
    score_list.append(list(map(int,input().split())))

result = 0


for i in range(day_count):
    temp = int(input()) - 1
    
    result += score_list[i][temp]
    
    for j in range(len(schedule)):
        if j != temp:
            schedule[j] += 1
            result -= schedule[j] * decline[j] 
        else:
            schedule[j] = 0
    
    print(result)
    

Measured memory_bytes: 9396
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

lin n;
string s;

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

    lin mn = 0;

    loop(i, 1, n)
    {
        if(s[i] == 'E')
            mn++;
    }

    lin current = mn;

    loop(i, 1, n)
    {
        if(s[i - 1] == 'W')
            current++;

        if(s[i] == 'E')
            current--;

        mn = min(current, mn);
    }

    cout << mn << endl;

    return 0;
}


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

#define ll long long

typedef vector <int> Vi;

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

    int v[n];
    for (int i = 0; i < n; i++) scanf("%d", &v[i]);
    sort(v, v+n);

    long double r = v[0];
    for (int i = 1; i < n; i++)r = (r + v[i])/2;

    cout << r << endl;
}


Measured memory_bytes: 256
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

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

int main(int argc, char const *argv[])
{
    ll n;cin >> n;
    set<ll> s;
    for(ll i=1;i*i<=n-1;i++){
        if((n-1)%i==0){
            if(i!=1)s.insert(i);
            if(i*i!=n-1)s.insert((n-1)/i);
        }
    } 
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ll m=n;
            while(i!=1 && m && m%i==0){
                m/=i;
            } 
            if(m%i==1 && i!=1)s.insert(i);
            m=n;
            while(m && m%(n/i)==0){
                m/=(n/i);
            }
            if(m%(n/i)==1)s.insert(n/i);
        }
    }
    cout << s.size() << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  vector<bool> f(104, false);
  int x, n;
  cin >> x >> n;
  rep(i, n){
    int p;
    cin >> p;
    f.at(p) = true;
  }
  vector<int> a;
  rep(i, f.size()){
    if(f.at(i) == false) a.push_back(i);
  }
  auto itr = lower_bound(a.begin(), a.end(), x);
  if(itr != a.begin()){
    auto itm = itr;
    itm--;
    if(itr == a.end() || abs(*itm - x) <= abs(*itr - x)) itr = itm;
  }
  cout << *itr << endl;
  return 0;
}

Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> score = new ArrayList<Integer>();
        while(sc.hasNext()){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if(m == -1 && f == -1 && r == -1){
                break;
            }else{
                score.add(m);
                score.add(f);
                score.add(r);
            }
        }
        for(int i = 0; i < score.size() / 3; i++){
            int m = score.get(i * 3);
            int f = score.get(i * 3 + 1);
            int r = score.get(i * 3 + 2);
            if(m == -1 || f == -1){
                System.out.println("F");
            }else if(m + f >= 80){
                System.out.println("A");
            }else if(m + f >= 65){
                System.out.println("B");
            }else if(m + f >= 50){
                System.out.println("C");
            }else if(m + f >= 30){
                if(r >= 50){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
            }else{
                System.out.println("F");
            }
        }
    }
}


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

// in-short-use macros

#define all(c) (c).begin(),(c).end()
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010



//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n,a,b;
    cin>>n;
    cin>>a>>b;
    bool ans=false;
    for(int i=a;i<=b;i++)
    {
        if(i%n==0)
            ans=true;
    }
    if(ans)
        cout<<"OK\n";
    else
        cout<<"NG\n";


    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<double> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}

	sort(v.begin(), v.end());
	for (int i = 0; i < N - 1; i++) {
		double tmp = (v.at(i) + v.at(i + 1)) / 2;
		v.at(i + 1) = tmp;
	}

	cout << v.at(N - 1) << endl;
}

Measured memory_bytes: 256
n=input()
import math
x=int(math.sqrt(n))
if x*x==n:
    print 0,
    print 0,
    print x,
    print 0,
    print 0,
    print x
    exit()
a=int(math.ceil(math.sqrt(n)))
d=a
cnt=1
while a*d-n<0:
    if cnt&1:
        a+=1
    else:
        d+=1
    cnt+=1
bc=a*d-n
i=1
while i*i<=bc:
    if bc%i==0:
        if bc/i<=10**9 and i<=10**9:
            b=i
            c=bc/b
            print 0,0,a,b,c,d
            exit()


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
#define N 100005
#define M 65
int n;
int a[N];
int p[M];
int cnt[M];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
//		cout<<i<<" : ";
		for(int j=0;j<=60;j++)
		{
			if(a[i]&(1LL<<j)) cnt[j]++/*,cout<<j<<" "*/;
		}
//		cout<<"\n";
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=60;j++)
		{
			if(a[i]&(1LL<<j))
			{
				if(cnt[j]&1)
				{
					a[i]^=(1LL<<j);
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=60;j>=0;j--)
		{
			if(a[i]&(1LL<<j))
			{
				if(p[j]==0)
				{
					p[j]=a[i]; break;
				}
				else a[i]^=p[j];
			}
		}
	}
	int ans=0;
	for(int i=60;i>=0;i--)
	{
		if((ans^p[i])>ans) ans^=p[i];
	}
	ans*=2;
	for(int i=0;i<=60;i++)
	{
		if(cnt[i]&1) ans+=(1LL<<i);
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



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

n, m, p = map(int, input().split())
edge = []
for _ in range(m):
  a, b, c = map(int, input().split())
  edge.append((a, b, c-p))
dist = [-float("inf")]*(n+1)
dist[1] = 0
for i in range(n):
  for a, b, c in edge:
    if dist[b] < dist[a] + c:
      dist[b] = dist[a] + c
ans = max(dist[n], 0)
for i in range(n):
  for a, b, c in edge:
    if dist[b] != float("inf") and dist[b] < dist[a] + c:
      dist[b] = float("inf")
if dist[n] == float("inf"):
  ans = -1
print(ans)

Measured memory_bytes: 74608
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

	class Program
	{
		static void Main(string[] args)
		{
			var inputNum = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			var N = inputNum[0];
			var K = inputNum[1];

			var max = N;
			var min = K;
			if(N > K)
			{
				max = N;
				min = K;
			}

			var test = max % min;
			var test2 = Math.Abs(test - min);

			if(test > test2)
			{
				Console.WriteLine(test2);
			}
			else
			{
				Console.WriteLine(test);
			}

			/*
						var answer = Gcd(N, K);

						if (answer == K)
						{
							Console.WriteLine(0);
						}
						else
						{
							Console.WriteLine(answer);
						}
			*/
		}
	}
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long

int N;
vector<ll> A;

int solve(){
	int count=0;
	int ans=0;
	sort(A.begin(), A.end());
	ll now = A[0];
	count++;
	for(int i = 1; i < N; i++){
		if(now == A[i]){
			count++;
		}else{
			ans += count%2;
			now = A[i];
			count = 1;
		}
	}
	ans += count%2;
	cout << ans << endl;
	return 0;
}

int main(){
	cin >> N;
	A.resize(N);
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 1024
use proconio::input;

fn main() {
    input! {
        n: u32,
        k: usize,
    }
    let mut ps = Vec::new();
    for _ in 0..n {
        input! {
            p: u32,
        };
        ps.push(p);
    }

    ps.sort();
    println!("{}", ps.iter().take(k).sum::<u32>());
}


Measured memory_bytes: 2196
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll  dp[207][207];

void warshall_floyd(int n) { // nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
}

ll func(vector<ll> X){
    ll dis=0;
    rep(i,X.size()-1){
        dis+=dp[X[i]][X[i+1]];
    }
    return dis;
}

int main(){
    ll N,M,R,A,B,L;
    vector<ll> r;
    cin >> N >> M >> R;
    rep(i,R){
        ll K;
        cin >> K;
        r.pb(K-1);
    }
    rep(i,N){
        rep(j,N){
            if(i==j){
                dp[i][j]=0;
            }
            else{
                dp[i][j]=INF;
            }
        }
    }
    rep(i,M){
        cin >> A >> B >> L;
        dp[A-1][B-1]=L;
        dp[B-1][A-1]=L;
    }

    warshall_floyd(N);

    ll  T = INF;
  sort(ALL(r));
    do{ 
        T =  min(T,func(r));
    } while (next_permutation(r.begin(), r.end()));
    cout << T << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  double t,x,ans;
  cin >> t >> x;
  printf("%lf\n", t / x);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

typedef long long ll;

ll a[200000];
ll sum[200000], n, s;

// ?????????????????????x??\?????§3????????????????????¨?????§?????????
bool solve(ll x) {
	REP(i, n) {
		bool flag = true;
		int pos = i;
		REP(j, 2) {
			pos = lower_bound(sum + i, sum + i + n + 1, sum[pos] + x) - sum;
			if (pos > i + n) { flag = false; break; }
		}
		if (flag && s - (sum[pos] - sum[i]) >= x) return true;	
	}
	
	return false;
}

int main() {
	cin >> n;
	
	REP(i, n) {
		scanf("%lld", &a[i]);
		a[n + i] = a[i];
		s += a[i];
	}
	sum[0] = a[0];
	FOR(i, 1, 2*n) sum[i] = sum[i - 1] + a[i];
	
	ll l = -1, r = n * 1000000000;
	while (r - l > 1) {
		ll m = (l + r) / 2;
		if (solve(m)) l = m;
		else r = m;
	}
	
	cout << l << endl;
	
	return 0;
}

Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, a, b, c, d;
  cin >> x;

  a = x / 1000;
  b = (x - a * 1000) / 100;
  c = (x - a * 1000 - b * 100) / 10;
  d = x - a * 1000 - b * 100 - c * 10;

  if ( a == b && b == c) {
    cout << "Yes" << endl;
  }
  else if ( c == d && b == c) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
count = 0
for i in range(0,n):
   for j in range(i+1,n):
      for k in range(j+1,n):
        sel = sorted([l[i],l[j],l[k]])
        if sel[0]+sel[1]>sel[2] and sel[0]!=sel[1] and sel[0]!=sel[2] and sel[1]!=sel[2]: count += 1
print(count)


Measured memory_bytes: 74180
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <boost/tuple/tuple.hpp>
#include <boost/foreach.hpp>
#include <cmath>

using std::string;
using std::vector;
using std::cout;
using std::endl;
string left(const string &s, int length)
{
  if(s.size() < length)
    return s;
  return s.substr(s.size() - length,length);
}

bool check(int tdelta, int xdelta, int ydelta)
{
  tdelta -= fabs(xdelta) + fabs(ydelta);
  if(tdelta < 0)
    return false;
  return tdelta % 2 == 0;
}


int main(){
  string s;
  std::cin >> s;
  const int N = atoi(s.c_str());
  vector<int> Ts,Xs,Ys;
  for(int i = 0; i < N; i++) {
    std::cin >> s;
    Ts.push_back(atoi(s.c_str()));
    std::cin >> s;
    Xs.push_back(atoi(s.c_str()));
    std::cin >> s;
    Ys.push_back(atoi(s.c_str()));
  }
  int t,x,y;
  t = x = y = 0;
  bool ans = true;
  for(int i = 0; i < N; i++)
  {
    if(!check(Ts[i] - t,Xs[i] - x, Ys[i] - y)){
      ans = false;
      break;
    }
  }
  if(!ans)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
    
  return 0;
}

Measured memory_bytes: 1644