akhauriyash/Code-Regression huggingface dataset:
// Contest: AtCoder Beginner Contest 158 (https://atcoder.jp/contests/abc158)
// Problem: E: Divisible Substring (https://atcoder.jp/contests/abc158/tasks/abc158_e)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

#include <cstring>

int ma[10000], mpa[10000];

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

    int n, p; string s; cin >> n >> p >> s;
    ll cnt = 0;

    if (p == 2 || p == 5) {
        rep(i, n)
            if ((s[i] - '0') % p == 0)
                cnt += i + 1;
    } else {
        vi m(p);
        int suff = 0, b = 1;
        for (int i = n - 1; i >= 0; --i) {
            suff = (suff + b * (s[i] - '0')) % p, b = b * 10 % p;
            cnt += m[suff];
            m[suff]++;
            if (suff == 0)
                ++cnt;
        }
    }

    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
	cin >> n >> m;
	
	int wa = 0 , ac = 0;
	int a[n+1] = {0};
	int b[n+1] = {0};
	for(int i=0 ; i<m ; i++)
	{
		int p;
		string v;
		cin >> p >> v;
		if(a[p])
			continue;
		if(v == "WA")
			b[p]++;
		else
			a[p]++;
	}
	for(int i=1 ; i<=n ; i++)
	{
		if(a[i])
			ac++ , wa += b[i];
	}
	
	cout << ac << " " << wa;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[100010];
bool num[27];
int main()
{
	memset(num,false,sizeof(num));
	scanf("%s",a);
	int len=strlen(a);
	for(int i=0;i<len;i++)
	{
		num[int(a[i])-96]=true;
	}
	int i=1;
	while(num[i]==true&&i<26)
	{
		i++;
	}
	if(num[i]==false)cout<<char(i+96);else cout<<"None";
	return 0;
}

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

const int INF = 1<<28;

struct E {
  int to, cost, cap, rev;
  E(int to, int cost, int cap, int rev)
    : to(to), cost(cost), cap(cap), rev(rev) {}
  E() {}
};

typedef vector<vector<E> > G;

void addEdgeF(int from, int to, int cost, int cap, G &g) {
  g[from].push_back(E(to,cost,cap,g[to].size()));
  g[to].push_back(E(from,cost,0,(int)g[from].size()-1));
}

int dfsF(int v, int t, int f, bool *used, G &g) {
  if(v == t) return f;
  used[v] = true;
  for(int i = 0; i < g[v].size(); ++i) {
    E &e = g[v][i];
    if(!used[e.to] && e.cap > 0) {
      int d = dfsF(e.to, t, min(f, e.cap), used, g);
      if(d > 0) {
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int maxFlow(int s, int t, G g) {
  int flow = 0;
  bool used[g.size()];
  while(1) {
    memset(used, 0, sizeof(used));
    int f = dfsF(s, t, INF, used, g);
    if(f == 0) break;
    flow += f;
  }
  return flow;
}

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

int main() {
  int m, n, tmp;
  vector<int> b, r;
  G g;
  while(cin >> m >> n && (m|n)) {
    b.resize(m);
    r.resize(n);
    for(int i = 0; i < m; ++i) {
      cin >> b[i];
    }
    for(int i = 0; i < n; ++i) {
      cin >> r[i];
    }

    g = G(m+n+2);
    for(int i = 0; i < m; ++i) {
      addEdgeF(m+n, i, 0, 1, g);
    }
    for(int i = 0; i < m; ++i) {
      for(int j = 0; j < n; ++j) {
        if(gcd(b[i], r[j]) != 1) {
          addEdgeF(i, m+j, 0, 1, g);
        }
      }
    }
    for(int i = 0; i < n; ++i) {
      addEdgeF(m+i, m+n+1, 0, 1, g);
    }
    cout << maxFlow(m+n, m+n+1, g) << endl;
  }
  return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if((a == 5 && b == 5 && c == 7)||(a == 5 && b == 7 && c == 5)||(a == 7 && b == 5 && c == 5)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0017
{
    public class Program

    {
        public static void Main(string[] args)
        {
 
            List<string> h_and_b = new List<string>();

            string str;
            while ((str = Console.ReadLine())!=null)
            {
                int hit = 0;
                int blow = 0;
                List<string> num_a = str.Split(' ').ToList();
                List<string> num_b = Console.ReadLine().Split(' ').ToList();
                for (int i = 0; i < num_b.Count(); i++)
                {
                    hit += (num_b[i] == num_a[i]) ? 1 : 0;
                    blow += (num_b[i] != num_a[i] && num_a.Contains(num_b[i])) ? 1 : 0;
                }
                string ans = string.Join(" ", hit, blow); 
                h_and_b.Add(ans);
            }

            foreach (string item in h_and_b)
                Console.WriteLine(item);     
        }
    }

}


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

public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int [] x = new int[n];
        int [] xSorted = new int[n];
        for (int i = 0; i < n; i++) {
            int m = cin.nextInt();
            x[i] = m;
            xSorted[i] = m;
        }
        Arrays.sort(xSorted);
        int center = n / 2;
        for (int i = 0; i < n; i++) {
            int rank = Arrays.binarySearch(xSorted, x[i]);
            if (rank < center) {
                System.out.println(xSorted[center]);
            } else {
                System.out.println(xSorted[center - 1]);
            }
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<vector<long>> a(N, vector<long>(2));
 
 
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> a.at(i).at(j);
    }
  }
 for(int i=0; i<N; i++){
   swap(a.at(i).at(0),a.at(i).at(1));
 }
  sort(a.begin(), a.end());

  long n=0;
  string b="Yes";
  
 
  for(int i=0; i<N; i++){
     n+=a.at(i).at(1);
    if(a.at(i).at(0)<n){
      b="No";
      break;
    }
  }
  cout<<b<<endl;

  

}







Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
int d[60];
int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i-1]) ans++;
  }
  cout << ans;
}


Measured memory_bytes: 512
import sys
readline = sys.stdin.readline

def parorder(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[p] = -1
    stack = [p]
    order = []
    visited = set([p])
    ast = stack.append
    apo = order.append
    while stack:
        vn = stack.pop()
        apo(vn)
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            ast(vf)
    return par, order

def getcld(p):
    res = [[] for _ in range(len(p))]
    for i, v in enumerate(p[1:], 1):
        res[v].append(i)
    return res

def dfs(St):
    dist = [0]*N
    stack = St[:]
    used = [False]*N
    for s in St:
        used[s] = True
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if not used[vf]:
                used[vf] = True
                dist[vf] = 1 + dist[vn]
                stack.append(vf)
    return dist

N = int(readline())
Edge = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)

dist0 = dfs([0])
fs = dist0.index(max(dist0))
distfs = dfs([fs])
en = distfs.index(max(distfs))
disten = dfs([en])

Dia = distfs[en]
path = []
for i in range(N):
    if distfs[i] + disten[i] == Dia:
        path.append(i)

if max(dfs(path)) > 1:
    print(-1)
else:
    
    path.sort(key = lambda x: distfs[x])
    
    cnt = 1
    hold = 0
    perm1 = [None]*N
    onpath = set(path)
    idx = 0
    for i in range(Dia+1):
        vn = path[i]
        hold = 0
        for vf in Edge[vn]:
            if vf in onpath:
                continue
            hold += 1
            perm1[idx] = cnt + hold
            idx += 1
        perm1[idx] = cnt
        idx += 1
        cnt = cnt+hold+1
    
    cnt = 1
    hold = 0
    perm2 = [None]*N
    onpath = set(path)
    idx = 0
    for i in range(Dia+1):
        vn = path[Dia-i]
        hold = 0
        for vf in Edge[vn]:
            if vf in onpath:
                continue
            hold += 1
            perm2[idx] = cnt + hold
            idx += 1
        perm2[idx] = cnt
        idx += 1
        cnt = cnt+hold+1
    print(*min(perm1, perm2))

Measured memory_bytes: 87852
#include <stdio.h>

int main(void){
	
	int a=0;
	char b[4];
	scanf("%s",&b);
	if(b[1]=='+')a++;
	if(b[1]=='-')a--;
	if(b[2]=='+')a++;
	if(b[2]=='-')a--;
	if(b[3]=='+')a++;
	if(b[3]=='-')a--;
	if(b[0]=='+')a++;
	if(b[0]=='-')a--;
	
	printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int dp[50];

int fibonacci(int);

int main(){
int n,i;
for(i = 0;i < 50; i++) dp[i] = -1;

scanf("%d",&n);
printf("%d\n",fibonacci(n));

return 0;
}

int fibonacci(int a){
	if(a == 0 || a == 1)return dp[a] = 1;
	if( dp[a] != -1) return dp[a];
	return dp[a] = fibonacci(a - 1) + fibonacci(a - 2);
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
#include <atcoder/all>

#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// // Unionfind 素集合データ構造
// struct Unionfind {
// 	vector<ll> par;
// 	vector<ll> rank;

// 	Unionfind(ll n) : par(n), rank(n) {
// 		REP(i, n) { par[i] = i; }
// 	}

// 	ll root(ll v) {
// 		if(par[v] == v) return v;
// 		return par[v] = root(par[v]);
// 	}

// 	void unite(ll x, ll y) {
// 		x = root(x);
// 		y = root(y);
// 		if(x == y) return;

// 		if(rank[x] < rank[y]) {
// 			par[x] = y;
// 		} else {
// 			par[y] = x;
// 			if(rank[x] == rank[y]) { rank[x]++; }
// 		}
// 	}

// 	bool is_same(ll x, ll y) { return root(x) == root(y); }
// };


// function -------------------------------------------


// main -----------------------------------------------

int main() {

	ll n, m;
	cin >> n >> m;
  
  atcoder::dsu uf(n);

	REP(i, m){
		ll a, b;
		cin >> a >> b;
		a --;
		b --;
		// 要素aが含まれる集合とbが含まれる集合を結合
		uf.merge(a, b);
	}

	set<ll> st;
	REP(i, n){
		// 要素iが含まれる集合の親の種類をカウント
		// cout << uf.root(i) << endl;
		if(st.count(uf.leader(i)) == 0){
			st.insert(uf.leader(i));
		}
	}

	// カウント-1が答え
	cout << ((ll)st.size() - (ll)1) << endl;

}

Measured memory_bytes: 7792
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

const int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];
    map<int,int> fact;
    for(int i = 0; i < n; i++){
        int cp = v[i];
        for(int i = 2; i*i <= cp; i++){
            if(cp%i)    continue;
            int cnt = 0;
            while(cp%i == 0)    cp /= i, cnt++;
            if(fact[i] < cnt)   fact[i] = cnt;
        }
        if(cp != 1 && fact.count(cp) == 0)  fact[cp] = 1;
    }
    ll all = 1;
    for(auto p : fact){
        int times = p.second;
        while(times--)  (all *= p.first) %= mod;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += all*modpow(v[i],mod-2,mod);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-9
#define MOD 1000000007
#define int long long
using namespace __gnu_pbds;
using namespace std;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ost;


int32_t main(){
	int n;
	cin >> n;
	double a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	vector<double> dp(n+1);
	dp[0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j >= 0; j--){
			dp[j] = (j == 0 ? 0 : dp[j-1]*a[i]) + dp[j]*(1.0-a[i]);
		}
	}
	double ans = 0;
	for(int i = n/2+1; i <= n; i++){
		ans += dp[i];
	}
	cout << fixed << setprecision(10) << ans;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    vector<vector<char>> a(110,vector<char>(110));
    int h,w;
    cin >> h  >> w;
    rep(i,h) rep(j,w) cin >> a[i][j];
    vector<bool> hh(110,1),ww(110,1);
    //x
    rep(i,h){
        bool ok = 1;
        rep(j,w) if(a[i][j]=='#') ok = 0;
        if(ok) hh[i]=0;
    }
    rep(j,w){
        bool ok = 1;
        rep(i,h) if(a[i][j]=='#') ok = 0;
        if(ok) ww[j]=0;
    }
    rep(i,h){
        rep(j,w) if(hh[i]==1 && ww[j]==1){
            cout<<a[i][j];
        }
        if(hh[i]) cout<<endl;
    }    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;cin>>a>>b;
  int ans=0;
  if(a[0]==b[0])ans+=1;
  if(a[1]==b[1])ans+=1;
  if(a[2]==b[2])ans+=1;
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
void dfs(){ 
  return;
}
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n,x,y; cin >> n >> x >> y;
  vector<int> res(n, 0);
  REPZ(i, 1, n){
    REPZ(j,i+1, n+1){
      int dis;
      // i<=x y<=j A-C
      if(i<=x and y<=j) dis=min(j-i,x-y+j-(i-1));
      // i<=x<j<y A-B
      else if(i<=x and x<j and j<y) dis=min(j-i, x+y+1-i-j);
      // x<i<y x<j<y B-B
      else if(x<i and i<y and x<j and j<y) dis=min(j-i,i-x+y-j+1 );
      // x<i<y y<=j B-C
      else if(x < i and i < y and y<=j) dis=min(j-i, i+j+1-x-y);
      else dis=j-i;
//cout << i <<"-"<< j << " "<< dis << endl;
      res[dis]++;
    }
  }
  REPZ(i, 1, n){
    cout << res[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 256