akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int add(int x,int y){return x+y<mod?x+y:x+y-mod;}
int qpow(int x,int k)
{
    int r=1;
    while(k)
    {
        if(k&1)r=1ll*r*x%mod;
        k>>=1;x=1ll*x*x%mod;
    }
    return r;
}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int C[1010][1010];
int n,m,K;
struct data{
    int to,nxt;
}mp[220];
int head[55],cnt;
void link(int x,int y)
{
    mp[++cnt].to=y;
    mp[cnt].nxt=head[x];
    head[x]=cnt;
}

struct Edge{
    int x,y;
};
int dfn[55],clk;
int low[55];
Edge sta[1010];
int top;
int col[55],tcol;
int cp[110],ce[110];
void Tarjan(int x,int fa)
{
    low[x]=dfn[x]=++clk;
    int v,p,q;
    Edge cur;
    for(int i=head[x];i;i=mp[i].nxt)
    {
        if(mp[i].to==fa)continue;
        v=mp[i].to;
        if(!dfn[v])
        {
            sta[++top]=(Edge){x,v};
            Tarjan(v,x);
            low[x]=min(low[x],low[v]);
            if(low[v]>=dfn[x])
            {
                tcol++;
                while(233)
                {
                    cur=sta[top];top--;
                    ce[tcol]++;
                    p=cur.x;q=cur.y;
                    if(col[p]!=tcol)col[p]=tcol,cp[tcol]++;
                    if(col[q]!=tcol)col[q]=tcol,cp[tcol]++;
                    if(p==x&&q==v)break;
                }
            }
        }
        else if(dfn[v]<dfn[x])
            low[x]=min(low[x],dfn[v]),sta[++top]=(Edge){x,v};
    }
}
int main()
{
    for(int i=0;i<=1000;++i)
    {
        C[i][0]=1;
        for(int j=1;j<=i;++j)
            C[i][j]=add(C[i-1][j],C[i-1][j-1]);
    }
    scanf("%d%d%d",&n,&m,&K);
    int xx,yy;
    for(int i=1;i<=m;++i)
    {
        scanf("%d%d",&xx,&yy);
        link(xx,yy);
        link(yy,xx);
    }
    for(int i=1;i<=n;++i)
        if(!dfn[i])top=0,Tarjan(i,0);

    int ans=1,ta;
    int siz;
    for(int i=1;i<=tcol;++i)
    {
//        cout<<"i: "<<i<<" ce: "<<ce[i]<<" cp: "<<cp[i]<<endl;
        if(ce[i]==1)ans=1ll*ans*K%mod;
        else if(ce[i]==cp[i])
        {
            siz=ce[i];
            ta=0;
            for(int j=1;j<=siz;++j)
                ta=add(ta,qpow(K,gcd(siz,j)));
            ta=1ll*ta*qpow(siz,mod-2)%mod;
//            cout<<"ta: "<<ta<<endl;
            ans=1ll*ans*ta%mod;
        }
        else ans=1ll*ans*C[ce[i]+K-1][K-1]%mod;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4352
#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 n,m;
  cin >> n >> m;
  vector<int32> cnt(n,0);
  vector<bool> ac(n,false);
  REP(i,m){
    int32 p;
    string s;
    cin >> p >> s;
    p--;
    if(s == "WA"){
      if(!ac[p]){
        cnt[p]++;
      }
    }else{
      ac[p] = true;
    }
  }
  int32 x = 0,y = 0;
  REP(i,n){
    if(ac[i]){
      x++;
      y += cnt[i];
    }
  }
  cout << x << " " << y << endl;
  return 0;
}

Measured memory_bytes: 1024
#[macro_use]
pub mod basic_stdin {
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    use std::io::stdin;
    use std::io::Read;

    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}

}

#[macro_export]
macro_rules! test_function {
    (func = $func:expr, $($input:expr => $output:expr),* $(,)*) => {
        $(
            assert_eq!($func(std::io::Cursor::new($input)) , $output);
        )*
    };
}

#[macro_export]
macro_rules! input_macro {
    (string = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    (reader = $s:expr, $($r:tt)*) => {
        let reader = std::io::BufReader::new($s);
        let mut bytes = std::io::Read::bytes(reader);
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

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

fn main() {
    let stdin = std::io::stdin();
    let ret = solve(stdin.lock());

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

fn solve<T: std::io::Read>(reader: T) -> u64 {
    input_macro! {
        reader = reader,
        a: u64,
        b: u64,
    }

    let n = b - a - 1;

    n * (n + 1) / 2 - a
}

#[cfg(test)]
mod tests {

    #[test]
    fn test_solve_function() {
        atcorder::test_function! {
            func = super::solve,
            "8 13" => 2,
            "1 6" => 9,
            "54 65" => 1,
        }
    }
}


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

int main(){
  int N;
  int AC=0, WA=0, TLE=0, RE=0;
  cin >> N;
  string result;
  for(int i=0;i<N;i++){
    cin >> result;
    if(result == "AC"){
      AC++;
    }else if(result == "WA"){
      WA++;
    }else if(result == "TLE"){
      TLE++;
    }else if(result == "RE"){
      RE++;
    }
  }
  cout << "AC" << " " << "x " << AC << endl;
  cout << "WA" << " " << "x " << WA << endl;
  cout << "TLE" << " " << "x " << TLE << endl;
  cout << "RE" << " " << "x " << RE << endl;
}

Measured memory_bytes: 3620
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void print(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
void printl(vector<int> v){rep(i,0,v.size()){cout<<v[i]<<endl;}}


signed main (){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b and b==c){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
    



}


/*
*/


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(void){
  int N,M;
  cin >> N >> M;
  long long a = 0;
  map<long long,long long> amari;
  amari[0]++;
  for(int i = 1; N >= i; i++){
    int tmp;cin>>tmp;
    a += tmp;
    amari[a%M]++;
  }
  long long kekka = 0;
  for(auto i = amari.begin(); amari.end() != i; i++){
    kekka += (i->second * (i->second - 1))/2;
  }
  cout <<  kekka << endl;
}

Measured memory_bytes: 4224
using System;
using System.Collections.Generic;

namespace abc171
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var aList = ReadNumList();
            var aTable = new Dictionary<long, long>();
            foreach (var a in aList)
            {
                if (aTable.ContainsKey(a))
                {
                    ++aTable[a];
                }
                else
                {
                    aTable.Add(a, 1);
                }
            }

            var firstTotal = Total(aTable);
            var currentTotal = firstTotal;

            var q = int.Parse(Console.ReadLine());
            var queryList = new List<KeyValuePair<long, long>>();
            for (var i = 0; i < q; ++i)
            {
                var bc = Console.ReadLine().Split(' ');
                var kv = new KeyValuePair<long, long>(long.Parse(bc[0]), long.Parse(bc[1]));
                queryList.Add(kv);
            }

            for (var i = 0; i < q; ++i)
            {
                var b = queryList[i].Key;
                var c = queryList[i].Value;
                var diff = 0L;
                if (aTable.ContainsKey(b))
                {
                    diff = (c - b) * aTable[b];
                    if (aTable.ContainsKey(c))
                    {
                        aTable[c] += aTable[b];
                    }
                    else
                    {
                        aTable[c] = aTable[b];
                    }
                    aTable.Remove(b);
                    currentTotal += diff;
                }
                Console.WriteLine(currentTotal);
            }
        }
        static int[] ReadNumList()
        {
            var line = Console.ReadLine().Split(' ');
            var numList = new int[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = int.Parse(line[i]);
            }
            return numList;
        }
        static long Total(Dictionary<long, long> aTable)
        {
            var total = 0L;
            foreach (var kv in aTable)
            {
                total += kv.Key * kv.Value;
            }
            return total;
        }
    }
}


Measured memory_bytes: 48212
x, y, A, B, C = map(int, input().split(' '))

a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))

a.sort(reverse=True)
b.sort(reverse=True)

a = a[:x]
b = b[:y]

d = a + b + c
d.sort(reverse=True)

print(sum(d[:x+y]))

Measured memory_bytes: 23328
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long

using namespace std;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()

const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}

int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	int n; cin >> n;
	int t[n+5]; memset(t,0,sizeof t);
	int a[n+5]; memset(a,0,sizeof a);
	rep(i,1,n) cin >> t[i] >> a[i];
	int T = 1, A = 1, kol = 1;
	rep(i,1,n) {
		kol = max((T+t[i]-1)/t[i],(A+a[i]-1)/a[i]);
		T = kol*t[i], A = kol*a[i];
	}
	cout << T+A << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
//using System.Collections.Generic;
public class ProCon
{
    public static void Main(){     
        string[] line1 =　Console.ReadLine().Split(' ');
        string[] vote =　Console.ReadLine().Split(' ');

        int N = int.Parse(line1[0]);
        int M = int.Parse(line1[1]);
        int totalItem = int.Parse(line1[0]);
        float totalVote = 0;

        for(int i = 0; i < N; i++)
        {
            totalVote = totalVote + int.Parse(vote[i]);
        }

        float threshold = totalVote / (4 * M);

        int popularItem = 0;
        for(int i = 0; i < totalItem; i++)
        {
            if(!(int.Parse(vote[i]) < threshold))
            {
                popularItem++;
            }
        }
        if(popularItem >= int.Parse(line1[1])) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
const unsigned int M = 1000000007; 
#define all(v) (v).begin(), (v).end()
#define rall(v) v.rbegin(),v.rend()
#define  pb push_back
#define mpp make_pair
#define int  long long
#define N 100002
#define endl "\n"
#define fr(i,n) for(int i=0;i<n;i++)
int power(int x,int y){int res=1;while(y>0){if(y&1)res=x*res; y=y>>1;x=x*x;}return res;}
int power(int x,int y,int mod){int res=1;while(y>0){if(y&1)res=x*res%mod; y=y>>1;x=x*x%mod;}return res;}

using namespace std;


void nik()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
}




 signed main()
{
//nik();

int t=1;
//cin>>t;

while(t--)
{	
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];
		a[0]=a[1];
	int dp[n+1]={0};
	for(int i=2;i<=n;i++)
	{
		dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
	}

	cout<<dp[n]<<endl;

}
 return 0;
}



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

int main() {

    string s;
    cin >> s;

    vector<bool> arr(4, 0);

    for(int i=0;i<s.size(); i++) {

        if(s[i] == 'N') arr[0] = true;
        else if(s[i] == 'S')arr[1] = true;
        else if(s[i] == 'E')arr[2] = true;
        else if(s[i] == 'W')arr[3] = true;

    }

    if((arr[0] && arr[1]) || (!arr[0] && !arr[1])) {

        if((arr[2] && arr[3]) || (!arr[2] && !arr[3])) {
            cout << "Yes\n";
            return 0;
        }

    }

    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.trim().split(" ");
  var data = input.map((n) => parseInt(n, 10));
 
  data = data.filter((v, i) => {
    return data.indexOf(v) === i;
  });
  console.log(data.length);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>

using namespace std;

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

    int a, b, c, d, e, k;

    vector<int> dist_ant(4);

    cin >> a >> b >> c >> d >> e >> k;

    int max_dist = e-a;
    
    if(max_dist > k){
        cout << string(":(") << endl;
    }else{
        cout << string("Yay!") << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll a, b;
  cin >> a >> b;
  if((a+b)%2==0){
    print((a + b) / 2);
  }
  else{
    print((a + b + 1) / 2);
  }
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

struct X
{
	int a,b;
	X(int a, int b): a(a),b(b){}
};

signed main() {
	int h,n;
	std::cin >> h >> n;
	std::vector<X> m;
	rep(i,n) {
		int a,b;
		std::cin >> a >> b;
		m.emplace_back(a,b);
	}
	// std::vector<std::vector<int> > dp(n,std::vector<int>(h+1,INF));
	const int INF=1e9;
	std::vector<int> dp(h+1,INF);
	dp[0]=0;
	rep(i,n) {
		rep(j,h) {
			if(j+m[i].a <= h) dp[j+m[i].a] = std::min(dp[j+m[i].a],dp[j]+m[i].b);
		}
	}
	debug(dp);
	std::vector<int> dpmin(h+1,INF);
	int mn = INF;
	for(int i=h;i>=0;i--) {
		mn=std::min(dp[i],mn);
		dpmin[i] = mn;
	}
	debug(dpmin);
	int ans = dpmin[h];
	rep(i,n) {
		ans = std::min(ans, dpmin[std::max(h-m[i].a,0ll)]+m[i].b);
	}
	print(ans);

	return 0;
}


Measured memory_bytes: 384
# include <iostream>
# include <vector>

void trace(std::vector<int> v) {
	for (std::vector<int>::iterator i = v.begin(); i != v.end(); ++i){
		if (i != v.end() - 1)
			std::cout << *i << " ";
		else
			std::cout << *i << std::endl;
	}
}


int main(){

	int n;
	std::cin >> n;

	std::vector<int> a;
	a.resize(n, 0);

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

	int c = 0;
	for (int i = 0; i < n; i++) {
		int min = i;
		bool need_swap = false;
		for (int j = i; j < n; j++) {
			if (a[j] < a[min]) {
				min = j;
				need_swap = true;
			}

		}
		int t = a[i];
		a[i] = a[min];
		a[min] = t;
		if (need_swap)
			c++;
	}

	trace(a);
	std::cout << c << std::endl;




	return 0;
}

Measured memory_bytes: 3160
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    X = int(inputs[0])
    NUM = 1000000
    items = [100, 101, 102, 103, 104, 105]
    r = X

    not_fin = True

    while r >= 100:
        amari = r % 100
        if r == 0:
            return 1
        if amari == 0:
            return 1

        matubi = amari % 10
        if amari >= 5:
            r -= 105
        else:
            r -= items[matubi]
    if r == 0:
        return 1
    return 0


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 38488
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main()
{
    long long N;
    cin >> N;
    vector<long long> A(N);
    map<long long, long long> dic;
    for (long long i = 0; i < N; ++i)
    {
        long long a;
        cin >> a;
        A[i] = a;
        ++dic[a];
    }

    long long sum = 0;
    for (auto it = dic.begin(); it != dic.end(); ++it)
    {
        long long num = it->second;
        sum += (num *(num - 1)) / 2;
    }

    for (long long i = 0; i < N; ++i)
    {
        long long subsum = sum;
        long long ind = A[i];
        long long num = (dic[ind] * (dic[ind] - 1)) / 2;
        subsum -= num;
        if (dic[ind] > 1)
        {
            subsum += ((dic[ind] - 1) * (dic[ind] - 2)) / 2;
        }
        cout << subsum << endl;
    }
    return 0;
}


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

using namespace std;

int dig[10];

bool ok(int n){
    int rem = -1;
    while(n){
        rem = n % 10;
        if(dig[rem]){
            return false;
        }
        n /= 10;
    }
    return true;
}

int main() {
    int n , k; cin>>n>>k;
    for(int i = 0 ; i < k; ++i){
        int x; cin>>x;
        dig[x]++;
    }
    for(int num = n ;;++num){
        if(ok(num)){
            cout<<num<<"\n";
            return 0;

        }
    }

    
}

Measured memory_bytes: 256
object Main extends App {
  val H, W = MyPredef1.nextInt()
  val pict = Array.fill(H)(MyPredef1.next)

  for (i <- 0 until H) {
    for (j <- 0 until W) {
      if(check(i, j)) {
        println("No")
        sys.exit()
      }
    }
  }

  println("Yes")

  def check(i: Int, j: Int): Boolean = {
    if (pict(i)(j) == '.') return false

    val up = if (i == 0) '.' else pict(i - 1)(j)
    val under = if (i == H - 1) '.' else pict(i + 1)(j)
    val left = if (j == 0)'.' else pict(i)(j - 1)
    val right = if (j == W - 1)'.' else pict(i)(j + 1)

    if (up == '.' & under == '.' & left == '.' & right == '.') true
    else false
  }

}

object MyPredef1 {
  @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }
  @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }

  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}

Measured memory_bytes: 25376
def main():
  n, m = input_list()
  a = 1900*m + 100*(n-m)
  print(a*(2**m))
    
  
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
import collections
from functools import reduce
main()

Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
int main(void){
    int n,x; cin>>n>>x;
    vector <int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]=abs(p[i]-x);
    }
    int ans=p[0];
    for(int i=1;i<n;i++){
         ans=gcd(ans,p[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
import sys

def getPrimes():
    primes = [2, 3]
    for n in range(5, 55555, 2):
        isprime = True
        for i in range(1, len(primes)):
            if primes[i] ** 2 > n:
                break
            if n % primes[i] == 0:
                isprime = False
                break
        if isprime:
            primes.append(n)
    return primes

n = int(raw_input())

primes = getPrimes()
primes5n1 = [p for p in primes if p%5 == 1]
print ' '.join(map(str, primes5n1[:n]))


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

long min(long D[],long n){
  long i,min;
  min = D[0];
  for(i =0 ;i < n; i++){
    if(min > D[i]) min = D[i];
  }
  return min;
}

long gcd(long a,long b)
{
 
  long r, tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  return b;
}


int main(){
  
  long N,X;
  scanf("%ld%ld",&N,&X);
  
  long i,x[N];
  for(i = 0; i < N; i++){
    scanf("%ld",&x[i]);
  }
  
  long D[N - 1];
  if(N == 1) D[0] = abs(X - x[0]);
  else
    for(i = 0; i < N - 1; i++){
    D[i] = gcd(abs(X - x[i]),abs(X - x[i + 1]));
    }
  
  long d;
  d = min(D,N - 1);
  
  printf("%ld",d);
  
  return 0;
  
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

    string s;
    cin >> s;

    using ll = long long;

    const ll mod = 1000000007;

    static ll dp[3001][3001];

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

    for (int i = 1; i < n; i++) {
        if (s[i-1] == '<') {
            dp[i][n - i] = 0;
            for (int j = n - i - 1; j >= 0; --j) {
                dp[i][j] = (dp[i - 1][j + 1] + dp[i][j + 1]) % mod;
            }
        } else {
            dp[i][0] = dp[i-1][0];
            for (int j = 1; j < n - i; j++) {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
            }
        }
    }

    cout << dp[n - 1][0] << endl;
}


Measured memory_bytes: 70016
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-17 00:12:29
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-18 00:42:22
 */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef pair<int,int> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
const int maxn =200000;
int f[maxn+10];
int find(int x)
{
    if(f[x]==x) return x;
    else
    {
        f[x]=find(f[x]);
        return f[x];
    } 
}
int N;
ll M;
ll Q;
vector<pii> p1;
vector<pii> p2;
signed main()
{
    for(int i=0;i<=maxn;i++)
    f[i]=i;
    read(N),read(M),read(Q);
    ll pos=0;
    for(int i=1;i<=Q;i++)
    {
        int x,y,k;
        read(x),read(y),read(k);
        if(k==0) p1.push_back(make_pair(x,y));else p2.push_back(make_pair(x,y));
        if(k==0){
        int f1=find(x);
        int f2=find(y);
        if(f1!=f2) {
        pos++;
        f[f1]=f2;}
        }
    }
    ll cnt=0;
    if(M==N-1)
    {
        if(p2.size()!=0){
        cout<<"No";return 0;}
        else {cout<<"Yes";return 0;}
    }
    for(int i=0;i<N;i++)
    if(find(i)==i) cnt++;
    ll que=0;
    for(auto p:p2)
    {
        if(find(p.second)==find(p.first))
        {
            cout<<"No";
            return 0;
        }
    }
    if(cnt<=2)
    {
        
        if(p2.size()!=0)
        {
            cout<<"No";
            return 0;
        }
        else
        {
            if(cnt==1) {cout<<"No"; return 0;}
            if(cnt==2&&M>pos+1){cout<<"No"; return 0;}
            cout<<"Yes";
            return 0;
        }
    }
    else
    {
        ll ans=(1ll*cnt*(cnt-1))/2;
        
        if(((M-1ll*pos)>ans))
        {
            cout<<"No";
            return 0;
        }
        else
        {
            cout<<"Yes";
            return 0;
        }
        
    }
}


Measured memory_bytes: 4980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		SomeSums solver = new SomeSums();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class SomeSums {

		private int n;
		private int a;
		private int b;
		private Scanner scanner;
		private int output;

		public SomeSums() {
			scanner = new Scanner(System.in);
			output = 0;
		}

		public void readInput() {
			n = scanner.nextInt();
			a = scanner.nextInt();
			b = scanner.nextInt();
		}

		public void solve() {
			int t,sum;
			for(int i=1; i<=n;i++) {
				t = i;
				sum = 0;
				while(t!=0) {
					sum += t%10;
					t /= 10;
				}
				if(sum>=a && sum <= b) {
					output += i;
				}
			}
		}

		public void writeOutput() {
			System.out.println(output);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int n; cin >> n;
    int a[n+1],b[n];
    for(int i = 0; i < n+1; i++){
        cin >> a[i];
    }
    long long ans = 0;
    for(int i = 0; i < n; i++){
        cin >> b[i];
        if (a[i]+a[i+1] <= b[i]){
            ans += a[i]+a[i+1];
            a[i] = 0;
            a[i+1] = 0;
        } else if (a[i]+a[i+1] >= b[i]){
            if (a[i] >= b[i]){
                a[i] -= b[i];
                ans += b[i];
            } else {
                ans += b[i];
                b[i] -= a[i];
                a[i] = 0;
                a[i+1] -= b[i];
            }
        }
    }
    cout << ans << endl;
}
  



Measured memory_bytes: 1024
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	b , c = tin()
	#s = input()
	print(b*c)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 61980
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  vector<int> A(32);
  A={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int a;
  cin >> a;
  cout << A[a-1] << endl;
}

Measured memory_bytes: 256
def hoge(S):
    cum = 0
    mi = 0
    for s in S:
        cum += 1 if s == '(' else -1
        mi = min(mi, cum)
    return (-mi, cum - mi)

N = int(input())
S = [hoge(input()) for _ in range(N)]

plus = []
minus = []

for l, r in S:
    if l <= r:
        plus.append((l, r))
    else:
        minus.append((l, r))

plus.sort(key=lambda a: a[0])
minus.sort(key=lambda a: a[1], reverse=True)
M = 0
for l, r in (plus + minus):
    M -= l
    if M < 0:
        print('No')
        exit()
    M += r

print('Yes' if M == 0 else 'No')


Measured memory_bytes: 163308
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main() {
    int N, M, Q, l, r;
    cin >> N >> M >> Q;
    vector<vector<int> > a(N+1, vector<int>(N+1));
    for (int i = 0; i < M; ++i) {
        cin >> l >> r;
        a[l][r]++;
    }

    // 二次元累積和
    vector<vector<int> > s(N+2, vector<int>(N+2, 0));
    for (int i = 1; i <= N; ++i)
        for (int j = 1; j <= N; ++j)
            s[i+1][j+1] = s[i][j+1] + s[i+1][j] - s[i][j] + a[i][j];

    // クエリ [x1, x2) × [y1, y2) の長方形区域の和
    for (int q = 0; q < Q; ++q) {
        int x, y;
        cin >> x >> y;
        cout << s[y+1][y+1] - s[x][y+1] - s[y+1][x] + s[x][x] << endl;
    }
}

Measured memory_bytes: 5588
n=int(input())
a_list = list(map(int,input().split()))
q=int(input())
b_c_list=[list(map(int,input().split())) for _ in range(q)]

sum_ans = sum(a_list)

count_list = [0] * 100001
for i in range(n):
    count_list[a_list[i]] += 1

for j in range(len(b_c_list)):
    from_j = b_c_list[j][0]
    to_j = b_c_list[j][1]
    # 和を求める
    sum_diff = (to_j - from_j) * count_list[from_j]
    sum_ans += sum_diff
    print(sum_ans)
    # 変換
    count_list[to_j] += count_list[from_j]
    count_list[from_j] = 0    

Measured memory_bytes: 32084
N,X,M = map(int, input().split())

ans = X
N -= 1
prev = X
used = [0]*M

while N:
    new = pow(prev, 2, M)
    if used[new] == 1:
        cnt = 1
        num = new
        while new != prev:
            num += pow(new, 2, M)
            new = pow(new, 2, M)
            cnt += 1
        ans += (N//cnt)*num
        N %= cnt
        break
    used[new] = 1
    ans += new
    prev = new
    N -= 1

while N:
    new = pow(prev, 2, M)
    ans += new
    prev = new
    N -= 1
print(ans)

Measured memory_bytes: 66192
# 数直線上にいるAさんとBさんとCさんがトランシーバーで会話をしようとしています。
# Aさんはa[m] 地点、Bさんはb[m] 地点、Cさんはc[m] 地点にいます。
# 二人の人間は、距離がd [m]以内のとき直接会話が出来ます。
# AさんとCさんが直接的、あるいは間接的に会話ができるか判定してください。
# ただしAさんとCさんが間接的に会話ができるとは、AさんとBさんが直接会話でき、
# かつBさんとCさんが直接会話できることを指します。

a,b,c,d = map(int,input().split())

# 絶対値を返す関数：abs(x)
Between_a_to_c = abs( a - c )
Between_a_to_b = abs( a - b )
Between_b_to_c = abs( b - c )

# 条件分岐
if not Between_a_to_c > d:
    print('Yes')
elif not Between_a_to_b > d:
    if not Between_b_to_c > d:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 9176
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, m, a, b;
	cin >> n >> m;

	vector<int> roads(n, 0);
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		roads[a-1]++;
		roads[b-1]++;
	}

	for (auto e : roads) {
		cout << e << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));


		  try{


			  String ab;
              
			  double r;
			
			  double pi=3.141592653589;
			  
              double menseki=0;
              double ensyuu=0;
			  
			  ab = input.readLine();
		      r= Double.parseDouble(ab);
		      menseki=r*r*pi;
		      ensyuu=2*r*pi;


			  System.out.printf("%1$.5f %2$.5f", menseki,ensyuu);
             }catch(IOException e) {   System.out.println("Exception : " + e);
		    }

	}
}

Measured memory_bytes: 24644
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))

N = read_int()[0]
AB = [read_int() for _ in range(N)]

def solve():
    AB.sort(key=lambda x: x[1])
    ans = True
    res = 0
    for i in range(N):
        res += AB[i][0]
        if res > AB[i][1]:
            ans = False
            break
    return "Yes" if ans else "No"

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 53748
N, M = tuple(map(int, input().split()))
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for y in range(M):
            for x in range(M):
                if A[i+y][j+x] != B[y][x]:
                    flag = False
        if flag:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  int x = 0;
  int y = 0;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == 'A') {
      x = i;
      break;
    }
  }
  for (int i = a.size(); i >= 0; i--) {
    if (a[i] == 'Z') {
      y = i;
      break;
    }
  }
  cout << y-x+1 << endl;
}

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

using namespace std;

int main()
{
  long long n;
  long long ans = 0;
  scanf("%lld", &n);
  
  if (n % 2) {
    printf("0\n");
    return 0;
  }
  
  n /= 2;
  
  while (n) {
    ans += n / 5;
    n /= 5;
  }
  
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    public static void main(String[] args) {
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int answer = 0;
        for (int x = 0; x <= k; x++)
            answer += (s - x + 1) - Math.min(s - x + 1, Math.max(0, ((s - x - k) * 2)));
        System.out.println(answer);
    }
}

Measured memory_bytes: 23124
K = int(input())
if K % 7 == 0: K //= 7
if K % 2 == 0 or K % 5 == 0: print(-1)
#elif K == 1: print(1)
#elif K % 3 == 0: print(K)
else:
    mod = 0
    for i in range(K):
        mod += pow(10,i,K)
        if mod % K == 0:
             print(i + 1)
             break


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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int h, n;
  cin >> h >> n;
  int sum = 0;
  for(int i = 0; i < n; ++i) {
    int x; cin >> x;
    sum += x;
  }
  cout << (sum >= h ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
from collections import *
n=int(input())
a=list(map(int,input().split()))
b=deque()
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
b=list(b)
if n%2==0:
    print(*b)
else:
    print(*b[::-1])

Measured memory_bytes: 107376
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
#define pri(str) cout << str << endl
using ll = long long;
using P = pair<int, int>;

const ll MX = 1e18;
const long double PI = acos(-1);

int main()
{
    string s; cin >> s;
    int ans = 0;
    rep(i, s.length())
    {
        int num = (int)s[i] -48;
        ans += num;
    }
    
    if(ans%9)
        pri("No");
    else
        pri("Yes");
    return 0;
}


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

const int MAX = 510000, MOD = 1e9+7;
long long fac[MAX], finv[MAX], inv[MAX];

void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long com(int n, int k) {
  if (n < k || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int N, K;
  cin >> N >> K;

  init();

  for (int i = 1; i <= K; i++) cout << com(N - K + 1, i) * com(K - 1, i - 1) % MOD << "\n";
}

Measured memory_bytes: 12160
#include <iostream>

using namespace std;

long long mypow(long long a) {
    long long ret = 1;
    for (int i=1; i<a; i++) {
        ret *= 3;
    }
    return ret;
}

bool check1(long long nokori, long long speed) {
    long long t = 0;
    t += mypow(++speed);
    while(speed > 2) {
        t += mypow(--speed);
    }
    return t <= nokori;
}

bool check2(long long nokori, long long speed) {
    long long t = 0;
    t += mypow(speed);
    while(speed > 2) {
        t += mypow(--speed);
    }
    return t <= nokori;
}

int main() {
    long long t;
    cin >> t;
    long long speed = 1;

    long long tt = t;

    if (t == 0) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 1;
    t--;

    while(t) {
        ans++;
        // 加速しても大丈夫な場合
        if (check1(t, speed)) {
            speed++;
        }
        // 速度そのままでも大丈夫な場合
        else if (check2(t, speed)) {

        }
        // 速度を落とさないといけない場合
        else {
            speed--;
        }

        t -= mypow(speed);
        // cout << ans << " " << tt - t << endl;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3116
import queue

def main():
    K = int(input())

    count = 0
    q = queue.Queue()
    for i in range(1,10):
        count += 1
        q.put(i)
        if count == K:
            print(i)
            break

    result = 0
    while count != K:
        tmp = q.get()
        keta1 = tmp % 10
        for i in  range(-1,2):
            if i == -1 and keta1 == 0:
                continue
            if i == 1 and keta1 == 9:
                continue
            result = tmp*10 + (keta1+i)
            q.put(result)
            count += 1
            if count == K:
                print(result)
                break
        else:
            continue
        break

if __name__ == "__main__":
    main()


Measured memory_bytes: 6768
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#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 REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;


signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n,m;

  cin >> n >> m;

  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int64_t minn(int64_t a,int64_t b){
    if(a >= b) return b;
    else return a;
}
int main(){
    string O,E;
    cin >> O>>E;
   for(int i = 0;i < (O.size()+E.size()+1)/2;i++){
       if(E.size() ==O.size() - 1 && i == (O.size()+E.size()+1)/2 -1 ){
       cout <<O[i];
       }
       else cout << O[i] << E[i];

   }
}



Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

#面倒なので全探索。50ぐらい間に合う
count = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            total = i * 500 + j * 100 + k * 50
            if total == X:
                count += 1
print(count)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
from decimal import Decimal,ROUND_HALF_UP
def print_ans(N, ar):
    """Test Case
    >>> print_ans(2, [["10000", "JPY"],["0.10000000", "BTC"]])
    48000.0
    >>> print_ans(3, [["100000000", "JPY"],["100.00000000", "BTC"],["0.00000001", "BTC"]])
    138000000.0038
    """
    ans = 0.0
    for a in ar:
        if a[1] == 'BTC':
            ans += float(Decimal(str(float(a[0]) * 380000.0)).quantize(Decimal('0.00001'), rounding=ROUND_HALF_UP) )
        else:
            ans += float(a[0])
    print(ans)


if __name__ == '__main__':
    N = int(input().rstrip())
    ar = [input().rstrip().split() for _ in range(N)]
    print_ans(N, ar)


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

namespace ABC137A
{
    class Program
    {
        static void Main(string[] args)
        {
            var items = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToArray();
            var ans1 = items[0] + items[1];
            var ans2 = items[0] - items[1];
            var ans3 = items[0] * items[1];
            var max = ans1;
            if(max < ans2)
            {
                max = ans2;
            }
            if(max < ans3)
            {
                max = ans3;
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13396
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def main():
    n, k = map(int, input().split())
    p = tuple(map(int, input().split()))
    c = tuple(map(int, input().split()))
    ans = -10**18
    for i in range(n):
        start, count = i, 1
        val = c[start]
        while p[start]-1 != i:
            start = p[start]-1
            count += 1
            val += c[start]
        start = i
        if val > 0:
            a = (k//count-1)*val
            ans = max(a, ans)
            num = count + k % count
        else:
            a = 0
            num = min(k, count)
        for _ in range(num):
            a += c[start]
            start = p[start] - 1
            ans = max(a, ans)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 74256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	H := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&H[i])
	}

	sort.Ints(H)

	sum := 0
	for i := 0; i < N-K; i++ {
		sum += H[i]
	}
	fmt.Println(sum)
}


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

N,M = map(int, input().split())
h_l = list(map(int, input().split()))

all_l = list(range(1,N+1))
lose_l = []
while M > 0:
    a,b = map(int, input().split())
    if h_l[a-1] > h_l[b-1]:
        lose_l.append(b)
    elif h_l[a-1] < h_l[b-1]:
        lose_l.append(a)
    else:
        lose_l.append(b)
        lose_l.append(a)
    M -= 1

result = list(set(all_l) - set(lose_l))
print(len(result))

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

int H[100005], dp[100005];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N, K;
    cin >> N >> K;
    
    for(int i=1; i<=N; i++)
        cin >> H[i];
    
    for(int i=2; i<=N; i++)
    {
        dp[i] = (int) 1e9 + 7;
        
        for(int j=1; j<=K && i-j>=1; j++)
            dp[i] = min(dp[i], dp[i-j] + abs(H[i] - H[i-j]));
    }
    
    cout << dp[N] << "\n";
    return 0;
}

Measured memory_bytes: 1024