akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <iostream>
#include <cstring> 
#include<algorithm>
#include<numeric>
#include<vector>
#include<queue>
#define lowbit(x) x&-x
#define il inline
#define mod 1000000007
#define inf 1e18
#define maxn 10000005
#define maxprime 3000005
#define db double
#define eps 1e-7
using namespace std;
typedef long long int ll;
int n,m,p;
int cnt=0,head[10005],vis[10005],c[10005];
ll d[10005];
struct node
{
	int to,nxt,w;
}edge[10005];
void addedge(int x,int y,int w)
{
	cnt++;edge[cnt].to=y;
	edge[cnt].w=w;edge[cnt].nxt=head[x];
	head[x]=cnt;
}
bool SPFA(int s)
{
        int x,y,i,j;
        queue<int>q;
        memset(vis,false,sizeof(vis));
        memset(d,-0x3f,sizeof(d));
        while(!q.empty())  q.pop();
        d[s]=0;
        c[s]=1;
        q.push(s);
        vis[s]=true;
        while(!q.empty())
        {
                x=q.front();
                q.pop();
                vis[x]=false;
                if(c[x]>n&&x==n)return false;
                else if(c[x]>n)d[x]=inf;
                for(i=head[x];i;i=edge[i].nxt)
                {
                        y=edge[i].to;
                        if(d[y]>1e16)continue;
                        if(d[y]<d[x]+edge[i].w)
                        {
                                d[y]=(d[x]>=1e16)?inf:d[x]+edge[i].w;
                                c[y]=c[x]+1;
                                if(c[y]>n&&y==n)return false;
                                else if(c[y]>=n+1)
                                {
                                	d[y]=inf;
                                }
                                if(!vis[y])
                                {
                                    q.push(y);
                                    vis[y]=true;
                                }
                        }
                }
        }
        return true;
}
int main()
{
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1;i<=m;i++)
	{
		int x,y,w;
		scanf("%d%d%d",&x,&y,&w);
		w-=p;
		addedge(x,y,w);
	}
	if(SPFA(1))printf("%lld\n",d[n]>=1e16?-1ll:max(d[n],0ll));
	else puts("-1");
}

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

using namespace std;

const int MAXN = 110;
const int MOD = 1000000007;
const int MAXW = 100010;
int64_t DP[MAXN][MAXW];
int N;
int64_t Weight[MAXN];
int64_t Price[MAXN];
int64_t W;

int main(){

    cin >> N >> W;
    for (int i = 1; i <= N; i++) {\
        cin >> Weight[i] >> Price[i];
    }

    for (int id = 1; id <= N; id++) {
        for (int weight = 1; weight <= W; weight++) {
            if (weight - Weight[id] < 0) {
                DP[id][weight] = DP[id - 1][weight];
            } else {
                DP[id][weight] = max(DP[id - 1][weight], DP[id - 1][weight - Weight[id]] + Price[id]);
            }

        }
    }

    cout << DP[N][W];

    return 0;
}


Measured memory_bytes: 79360
import java.util.Scanner;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        String[] B = new String[(int)(N)];
        
        for(int i = 0 ; i < N ; i++){
                B[i] = sc.next();
                
        }
        HashMap<String, Integer> m = new HashMap<String, Integer>();
        int a = 0;
        for (String s : B) {
        int v = 0;
        if (m.containsKey(s)) {
        // Mapに登録済み
        v = m.get(s) + 1;
        a++;
        } else {
        // Mapに未登録
        v = 1;
        }
        m.put(s, v);
        }
        
        System.out.println(N - a);
     }
}

Measured memory_bytes: 69664
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
typedef long long ll;
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; }
using namespace std;
const int INF = 1<<30;

int main(){
	int n, k, ans = INF;
	cin >> n >> k;
	vector<int> X(n);
	for (int i = 0; i < n; i++) cin >> X[i];
	for (int i = 0; i <= n-k; i++) {
		chmin(ans, X[i+k-1]-X[i] + abs(X[i]));
		chmin(ans, X[i+k-1]-X[i] + abs(X[i+k-1]));
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,i,j=0,k;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        long long x,y;
        cin>>x>>y;
        if(x*x+y*y<=k*k)
        {
            j++;
        }
    }
    cout<<j<<endl;
}


Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nk = br.readLine().split(" ");
        int n = Integer.parseInt(nk[0]);
        int k = Integer.parseInt(nk[1]);
        
        int ans = k*(int)Math.pow(k-1, n-1);
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21076
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long

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

	int K, A, B;
	int ans = 1;
	cin >> K >> A >> B;

	double per = (double)B - A;
	
	bool flg;
	if (per >= 2) {
		flg = true;
	}
	else {
		flg = false;
	}

	if (flg) {
		if (K < A - 1) {
			ans = K + 1;
		}
		else {
			K -= (A - 1);
			ans += (A - 1);
			ans += (B - A)*(K / 2) + (K % 2);
		}
	}
	else {
		ans = K + 1;
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    rep(i, s.length()) {
        char c = (char)s[i];
        c += n;
        if (c > 'Z') c -= ('Z' - 'A' + 1);
        cout << c;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
 os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif


#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pii >


const int mod=1e9+7;
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}
inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;} 

const int M = 5002;
vi g[M]; bool vis[M];
int cz =0;
bool sp[M];

vi sz;

int n; bool spc = 0;

void dfs(int x){
	vis[x]=1; cz++; if(sp[x]) spc = 1;
	for(auto z:g[x]) {
		if(!vis[z]) dfs(z);
	}
}

int get(int x){
	vi val(x+1, 0);
	val[0]=1; int in = inv(n-1);

	for(int i=1;i<=x;i++){
		int sn = mul(sz[i-1], in);
		for(int j=i;j>=1;j--){
			val[j] = add(val[j], mul(val[j-1], sn));
		}
	}
	// trace(val);
	int nk = power(n-1, x);
	vi fact(x+1, 0);
	fact[0] = fact[1] = 1;
	int sbt = 0;
	for(int i=2;i<=x;i++){
		fact[i] = mul(fact[i-1], i);
		val[i] = mul(val[i], nk);
		val[i] = mul(val[i], fact[i-1]);
		// trace(i, val[i]);
		sbt = add(sbt, val[i]);
	}
	for(int i=0;i<x;i++){
		if(sz[i]==1) continue;
		int cur = mul(sz[i]-1, mul(in, nk));
		sbt = add(sbt, cur);
	}
	return sbt; 
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	cin>>n;
	int k = 0 ;
	for(int i=0;i<n;i++){
		int p; cin>>p; 
		if(p<0) k++, sp[i+1] = 1;
		else g[i+1].pb(p), g[p].pb(i+1);
	}
	int pr = n;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			cz = 0; spc = 0;
			dfs(i), pr--;
			if(spc) sz.pb(cz);
			// if(cz == 1) exep++;
		}
	}
	// trace(pr, sz, k, n);
	int nk = power(n-1, k);
	int ex = get(k);
	int ans = mul(pr, nk);
	ans = add(ans, mul(k , nk));
	ans = sub(ans, ex);
	cout<<ans<<"\n";
}


Measured memory_bytes: 3884
h,w=gets.split.map(&:to_i)
dir=[[0,-1],[-1,-1],[-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1]]
S=h.times.map{gets.chomp.to_s}
res=Array.new(h){Array.new(w)}
h.times do |i|
  w.times do |j|
    if S[i][j]=="#"
      res[i][j]="#"
    else
      cnt=0
      dir.each do |dy,dx|
        if (0<=i+dy && i+dy<h && 0<=j+dx && j+dx<w)
          cnt+=1 if S[i+dy][j+dx]=="#"
        end
      end
      res[i][j]=cnt.to_s
    end
  end
end
h.times do |i|
  puts res[i].join("")
end

Measured memory_bytes: 2044
import sys
input = sys.stdin.readline
# import heapq as hp

N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
graph = [[] for _ in range(N)]
Par = [-1]*N
for i, a in enumerate(A):
    if i == 0:
        if a != 1:
            ans += 1
        continue
    Par[i] = a-1
    graph[a-1].append(i)

qs = []

stack = [0]
Depth = [-1]*N
Depth[0] = 0
while stack:
    p = stack.pop()
    for np in graph[p]:
        Depth[np] = Depth[p] + 1
        stack.append(np)
    qs.append((Depth[p], p))

qs.sort(reverse=True)
checked = [False]*N

for d, s in qs:
    if d <= K: break
    if checked[s]: continue

    for _ in range(K-1):
        s = Par[s]
    
    que = [s]
    checked[s] = True
    while que:
        qq = []
        for p in que:
            for np in graph[p]:
                if not checked[np]:
                    checked[np] = True
                    qq.append(np)
        que = qq
    
    ans += 1

print(ans)

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

int main()
{
	int n;
	cin >> n;
	vector<pair<int,int>> a(n);
	for(int i=0;i<n;++i)
	{
		cin >> a[i].first >> a[i].second;
	}
	map<pair<int,int>,int> mp; 
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<n;++j)
		{
			if(i!=j)
			{
				pair<int,int> c = {(a[i].first - a[j].first),(a[i].second - a[j].second)};
				mp[c]++;
			}
		}
	}
	
	
	int nax = 0;
	for(auto x:mp)
	{
		//~ cout << x.second << " ";
		nax = max(nax,x.second);
	}
	//~ cout << nax;
	cout << n - nax; 
	
}


Measured memory_bytes: 384
import sys
from heapq import heappush, heappop

readline = sys.stdin.readline


def solve():
    N = int(readline())

    left = [[] for _ in range(N)]
    right = [[] for _ in range(N)]
    ans = 0
    for _ in range(N):
        K, L, R = map(int, readline().split())
        if L > R:
            ans += R
            left[K - 1].append(R - L)
        else:
            ans += L
            if 0 <= N - K - 1:
                right[N - K - 1].append(L - R)

    for vec in (left, right):
        hq = []
        n = len(vec)
        for idx in range(N - 1, -1, -1):
            for p in vec[idx]:
                heappush(hq, p)
            if idx < n and hq:
                ans -= heappop(hq)

    return ans


def main():
    T = int(readline())

    ans = [0] * T
    for i in range(T):
        ans[i] = solve()

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 100996
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
ll C[51][51];
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    rep(i, 51) rep(j, i + 1) {
        if (j == 0 or j == i)
            C[i][j] = 1LL;
        else
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
    }

    int n, a, b;
    cin >> n >> a >> b;
    vector<double> vec(n);
    rep(i, n) cin >> vec[i];
    sort(vec.begin(), vec.end(), greater<double>());
    double sum = 0;
    rep(i, a) sum += vec[i];
    int p = 0, q = 0;
    rep(i, n) {
        if (vec[i] == vec[a - 1]) {
            p++;
            if (i < a) q++;
        }
    }
    ll ans = 0;
    if (vec[0] == vec[a - 1]) {
        repl(i, a, b + 1) ans += C[p][min(i, p - i)];
    } else {
        ans = C[p][min(q, p - q)];
    }
    sum /= (double)a;
    CST(10) << sum << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int s,w;
    cin >> s >> w;
    if(w>=s)cout << "unsafe";
    else cout << "safe";
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main(){
	char ch;
	cin>>ch;
	if(ch!='a'&&ch!='e'&&ch!='i'&&ch!='o'&&ch!='u') cout<<"consonant";
	else cout<<"vowel";
	return 0;
}


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

#define ll long long
#define endl '\n'
#ifndef _WINDOWS
// no getchar_unlocked on Windows so just call getchar
#define getchar getchar_unlocked
#endif

template <typename Func>
inline void loop(int e, Func&& f) {
    for (int i = 0; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename Func>
inline void loop(int s, int e, Func&& f) {
    for (int i = s; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename T>
inline void scanpn(T& num) {
    register int c;
    num = 0;
    c = getchar();
    // bool negative = false;
    // if (c == '-') {
    // 	negative = true;
    // 	c = getchar();
    // }
    for (; (c > 47 && c < 58); c = getchar()) num = num * 10 + c - 48;
    // if (negative)
    //     number = -number;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll i;
    ll sum = 0;
    for (i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) sum += i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3648
n = int(input())
s = str(input())
L = [[0]*2 for i in range(n+1)]
R = [[0]*2 for i in range(n+1)]

for i in range(n):
    L[i+1][0] = L[i][0]
    L[i+1][1] = L[i][1]
    if s[i] == 'E':
        L[i+1][0] += 1
    else:
        L[i+1][1] += 1

for i in reversed(range(n)):
    R[i][0] = R[i+1][0]
    R[i][1] = R[i+1][1]
    if s[i] == 'E':
        R[i][0] += 1
    else:
        R[i][1] += 1

ans = 10**18
for i in range(n):
    temp = L[i][1]+R[i+1][0]
    ans = min(ans, temp)
print(ans)


Measured memory_bytes: 137384
#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...);
}

int64 to_num(string s) {
  int64 ret = 0;
  REP(i, s.size()) {
    if (s[i] == ':') continue;
    ret = ret*10 + s[i]-'0';
  }
  return ret;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int64 n;
  while (cin >> n && n) {
    vector<int64> sum(1000000, 0);
    REP(i, n) {
      string s, e;
      cin >> s >> e;
      sum[to_num(s)]++;
      sum[to_num(e)]--;
    }
    int64 res = sum[0];
    REP(i, 1000000-1) {
      sum[i+1] += sum[i];
      chmax(res, sum[i+1]);
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 10900
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int a,b,c,d; cin >> a >> b >> c >> d;
    int x = a-c, y = b-d;
    cout << c + y << " " << d + x*-1 << " ";
    cout << a + y << " " << b + x*-1 << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> s >> ss >> sss;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

//  if(x <= a) anss = "Yes";
//  else anss = "No";

  cout << s[0] << ss[1] << sss[2] << endl;

}

Measured memory_bytes: 256