akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2];
int R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    
    for(int i=0 ; i<n1 ; i++){
        L[i] = A[left + i];
    }
    for(int i=0 ; i<n2 ; i++){
        R[i] = A[mid + i];
    }
    
    L[n1] = R[n2] = SENTINEL;
    
    int i = 0;
    int j = 0;
    
    for(int k=left ; k<right ; k++){
        cnt++;
        
        if(L[i] <= R[j]){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right){
    if(left+1<right){
        int mid = (left + right)/2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main(){
    int A[MAX];
    cnt = 0;
    int n, i;
    
    cin >> n;
    for(i=0 ; i<n ; i++){
        cin >> A[i];
    }
    
    mergeSort(A, n, 0, n);
    
    for(i=0; i<n ; i++){
        if(i)cout << " ";
            cout << A[i];
    }
    
    cout << endl;
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 6980
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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() {
    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    vector<int> t(n);
    rep(i, n) t[p[i]-1] = i + 1;
    int maxLen = 0;
    int r = 0;
    for (int l = 0; l < n;) {
        while (r+1 < n && t[r] <= t[r+1]) r++;
        chmax(maxLen, r-l+1);
        l = r + 1;
        r++;
    }
    cout << n - maxLen << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int e[2005][3];
long long dis[1005];
int main() {
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++ i) {
        scanf("%d%d%d", &e[i][0], &e[i][1], &e[i][2]);
        -- e[i][0], -- e[i][1];
    }
    memset(dis, -0x3f, sizeof(dis));
    dis[0] = 0;
    for (int t = 0; t < 5 * m; ++ t) {
        for (int i = 0; i < m; ++ i) {
            int u = e[i][0];
            int v = e[i][1];
            int w = e[i][2];
            if (dis[v] < dis[u] + w) {
                dis[v] = dis[u] + w;
                if (v == n - 1 && t >= 3 * m) {
                    puts("inf"); return 0;
                }
            }
        }
    }
    printf("%lld\n", dis[n - 1]);
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORL(i,a,b) for(ll i=(a);i<(b);++i)
#define REPL(i,n) FORL(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   RFOR(i,n,0)

using namespace std;

bool isprime(int n){
	bool f = true;
	FOR(i, 2, n){
		if (n%i == 0){
			f = false;
			break;
		}
	}
	return f;
}

int main(){
	int N;
	scanf("%d", &N);
	int a[55];

	a[0] = 11, a[1] = 31, a[2] = 41, a[3] = 61, a[4] = 71;
	FOR(i, 5, N){
		FOR(j, 13, 55555){
			if (isprime(j) && j%5== 1){
				bool f = true;
				REP(k, i){
					if (a[k] == j){
						f = false;
					}
				}
				if (f){
					a[i] = j;
					break;
				}
			}
		}
	}
	REP(i, N){
		if (i != 0){
			printf(" ");
		}
		printf("%d", a[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
using System;

class B5{
  static int count = 0;
  static int n;
  static string[] str;
  static int[] S;
  public static void Main(){
    n = int.Parse(Console.ReadLine());
    str = Console.ReadLine().Split(' ');
    S = new int[n];
    for(int i = 0;i < n;i++){
      S[i] = int.Parse(str[i]);
    }
    mergeSort(ref S,0,n);
    int l = 0;
  foreach(int x in S){
    Console.Write(x);
    l++;
    if(l == n) Console.WriteLine("");
    else Console.Write(" ");
  }
  Console.WriteLine(count);
  }

  static void merge(ref int[] S,int left,int mid,int right){
    int i,j;
    int n1 = mid - left;
    int n2 = right - mid;
    int[] L = new int[n1 + 1];
    int[] R = new int[n2 + 1];
    for(i = 0;i < n1;i++){
      L[i] = S[left + i];
    }
    for(i = 0;i < n2;i++){
      R[i] = S[mid + i];
    }
    L[n1] = int.MaxValue;
    R[n2] = int.MaxValue;
    i = 0;
    j = 0;
    for(int k = left;k < right;k++){
      if(L[i] <= R[j]){
        S[k] = L[i];
        count++;
        i++;
      }else{
        S[k] = R[j];
        count++;
        j++;
      }
    }
  }

  static void mergeSort(ref int[] S,int left,int right){
    if(left + 1 < right){
      int mid = (left + right) / 2;
      mergeSort(ref S,left,mid);
      mergeSort(ref  S,mid,right);
      merge(ref S,left,mid,right);
    }
  }
}



Measured memory_bytes: 70584
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using i64=long long int;

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

    int c = 0;
    i64 ans = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (c && a) {
            ++ans; --a;
        }
        ans += a / 2;
        c = a % 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
ans = []
f_ans = []
for i in range(len(s)):
    if ord(s[i]) + n > 90:
        ans.append(ord(s[i]) + n - 26)
    else:
        ans.append(ord(s[i]) + n)
    f_ans.append(chr(ans[i]))
for i in range(len(s)):
    print(f_ans[i],end = "")


Measured memory_bytes: 4596
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using ll = long long;
using namespace std;
char g[900][900];
int vis[900][900];
int H, W, K;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> H >> W >> K;
  int x0, y0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> g[i][j];
      if (g[i][j] == 'S') {
        x0 = i;
        y0 = j;
      }
    }
  }

  vis[x0][y0] = 1;

  vector<pair<int, int>> pos;

  pos.push_back({x0, y0});
  vector<pair<int, int>> apos;

  auto checkAdd = [&apos](const int x, const int y, vector<pair<int, int>> &npos) {
    if (x < 0 || x >= H || y < 0 || y >= W) return;
    if (vis[x][y] || g[x][y] == '#') return;
    vis[x][y] = 1;

    npos.push_back({x, y});
    apos.push_back({x, y});
  };
  int ct = 0;
  apos.push_back({x0, y0});
  while (ct < K && pos.size()) {
    vector<pair<int, int>> npos;
    for (auto &p : pos) {
      apos.push_back(p);
      int x = p.first;
      int y = p.second;
      checkAdd(x + 1, y, npos);
      checkAdd(x - 1, y, npos);
      checkAdd(x, y + 1, npos);
      checkAdd(x, y - 1, npos);
    }

    swap(pos, npos);
    ct++;
  }
  int ret = 800 * 800 + 1000;
  for (auto &p : apos) {
    int x = p.first;
    int y = p.second;
    int mstep = min({x, y, H - x - 1, W - y - 1});
    if (mstep == 0) {
      ret = 1;
      break;
    }
    ret = min(ret, (mstep + K - 1) / K + 1);
  }

  cout << ret << endl;
}

Measured memory_bytes: 21096
#include <cstdio>
#include <cstring>

int d,n;
int fie[101][101];
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};

int max(int a,int b){
	if(a>b)return a;
	return b;
}

int main(void){
	scanf("%d",&d);
	for(int data=0;data<d;data++){
		if(data>0)printf("\n");
		scanf("%d",&n);
		memset(fie,0,sizeof(fie));
		for(int i=0;i<n;i++){
			fie[0][i]=1;
		}
		int len=0,mlen=n-1,x=0,y=0,dir=1,cnt=0;
		while(mlen>0){
			x+=dx[dir];
			y+=dy[dir];
			fie[x][y]=1;
			len++;
			if(len==mlen){
				cnt++;
				if(mlen==1)break;
				dir=(dir+1)%4;
				len=0;
			}
			if(cnt==2){
				mlen-=2;
				cnt=0;
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				printf("%c",fie[j][i]==1?'#':' ');
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1044
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

  int n; cin >> n;
  while( n-- ) {
    string s,t; cin >> s >> t;
    int N = max(s.size(),t.size());
    vector< vector<int> > dp(N+1,vector<int>(N+1,0));
    for(int i = 0; i < s.size(); i++){
      for(int j = 0; j < t.size(); j++){
        if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
        else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
      }
    }
    cout << dp[s.size()][t.size()] << endl;
  }

  return 0;
}



Measured memory_bytes: 10776
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        string s;
        getline(cin, s);
        if(s.size() == 0)
            return 0;

        istringstream iss(s);
        stack<double> stk;
        for(;;){
            string s1;
            if(iss >> s1){
                if(s1.size() > 1 || ('0' <= s1[0] && s1[0] <= '9'))
                    stk.push(atof(s1.c_str()));
                else{
                    double x = stk.top();
                    stk.pop();
                    double y = stk.top();
                    stk.pop();
                    if(s1 == "+")
                        stk.push(y + x);
                    else if(s1 == "-")
                        stk.push(y - x);
                    else if(s1 == "*")
                        stk.push(y * x);
                    else
                        stk.push(y / x);
                }
            }else
                break;
        }
        printf("%.10f\n", stk.top());
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;
  cin >> N >> A >> B;
  if(N*A>B){
    cout << B << endl;
  }
  if(N*A<B){
    cout << N*A << endl;
  }
  if(N*A==B){
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 9223372036854775807

#define N 10000

vector<pair<int, int> > G[N];
int d[N];

void dijkstraWithPriorityQueue(int s, int n)
{
    int visited[n];
    priority_queue<pair<int, int> > que;
    for (int i = 0; i < n; i++)
    {
        visited[i] = 0;
        d[i] = INF;
    }

    d[s] = 0;
    que.push(pair<int, int>(d[s], s));

    while (!que.empty())
    {
        pair<int, int> f = que.top();
        que.pop();
        int u = f.second;
        int c = f.first;

        visited[u] = 1;

        if (d[u] < -1 * c)
            continue;

        for (int i = 0; i < G[u].size(); i++)
        {
            if (!visited[G[u][i].first])
            {
                if (d[u] + G[u][i].second < d[G[u][i].first])
                {
                    d[G[u][i].first] = d[u] + G[u][i].second;
                    que.push(pair<int, int>(-1 * d[G[u][i].first], G[u][i].first));
                }
            }
        }
    }
}

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

    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            int v, c;
            cin >> v >> c;
            G[u].push_back(pair<int, int>(v, c));
        }
    }

    dijkstraWithPriorityQueue(0, n);

    for (int i = 0; i < n; i++)
        cout << i << ' ' << d[i] << endl;
}



Measured memory_bytes: 12112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

class BIT {
    int n;
    VL dat;
public:
    void init(int in) {
        n = in + 1;
        dat.clear();
        dat.resize(n, 0);
    }
    ll sum(int i) {
        ll ret = 0;
        while (i >= 0) {
            ret += dat[i];
            i = (i & (i + 1)) - 1;
        }
        return ret;
    }
    void add(int i, ll x) {
        while (i <= n) {
            dat[i] += x;
            i |= i + 1;
        }
    }
};

int main() {
    int n;
    cin >> n;
    VI a(n), sorted(n);
    FOR(i, 0, n) {
        cin >> a[i];
        sorted[i] = a[i];
    }
    SORT(sorted);
    int ok = 0, ng = n;
    BIT bit;

    ll border = (((ll)n * (n + 1) / 2) + 1) / 2;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        int midnum = sorted[mid];
        bit.init(2 * n + 1);
        int sum = 0;
        bit.add(sum + n, 1);
        ll result = 0;
        FOR(i, 0, n) {
            sum += (a[i] >= midnum ? 1 : -1);
            result += bit.sum(sum + n);
            bit.add(sum + n, 1);
        }
        if (result >= border)ok = mid;
        else ng = mid;
    }
    cout << sorted[ok] << endl;
}


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

using namespace std;

long long gcd(long long a, long long b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	long long n, m;
	string s, t;
	cin >> n >> m >> s >> t;

	long long g = gcd(n, m);
	for (long long i = 0, j = 0;i < n && j < m;i += n / g, j += m / g)
		if (s[i] != t[j]) {
			cout << -1;

			return 0;
		}

	cout << n * m / g;

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	long long n,k,s;
	scanf("%lld%lld%lld",&n,&k,&s);
	if(s==1e9){
		for(int i=1;i<=k;i++){
			printf("%lld ",s);
		}
		for(int i=k+1;i<=n;i++){
			printf("1 ");
		}
		printf("\n");
	}
	else{
		for(int i=1;i<=k;i++){
			printf("%lld ",s);
		}
		for(int i=k+1;i<=n;i++){
			printf("%d ",s+1);
		}
		printf("\n");
	}
	return 0;
} 

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main()
{
    int n;
 
    cin >> n;
    int sum = 0;
    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a != i + 1)sum++;
    }
    if (sum == 0 || sum == 2)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int l,r,d;
        cin>>l>>r>>d;
        l--;
        int ans = (r/d) - (l/d);
        cout<<ans;
    }
    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a + b < c) {
    cout << "NA" << endl;
  } else if (a > c) {
    cout << 0 << endl;
  } else {
    cout << c-a << endl;
  }
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+100;
int n;
vector<int>ve;

int dp[N];
int main()
{
    int f=0;
    for(int i=2;i<=55555;i++){
            f=0;
        for(int j=2;j*j<=55555;j++){
            if(i%j==0) f=1;
        }
        if(f==0 && i%10==1) ve.push_back(i);
    }
     int n;cin>>n;
    for(int i=0;i<n;i++){
        cout<<ve[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3588
from collections import Counter
n = int(input())
*v, = map(int, input().split())

odds = v[1::2]
evens = v[::2]
o = Counter(odds)
e = Counter(evens)
omx, *ol = sorted(o.items(), reverse=True, key=lambda x: x[1])
emx, *el = sorted(e.items(), reverse=True, key=lambda x: x[1])

if omx[0] != emx[0]:
    ans = n - omx[1] - emx[1]
else:
    if ol:
        ol = ol[0]
    else:
        ol = (0, 0)

    if el:
        el = el[0]
    else:
        el = (0, 0)

    a = n - omx[1] - el[1]
    b = n - emx[1] - ol[1]
    ans = min(a, b)

print(ans)

Measured memory_bytes: 21944
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long N = sc.nextLong();
		long ans = 0;
		if(B <= N)
			ans = A*(B-1)/B;
		else
			ans = A*N/B;
		System.out.println(ans);
	}

}


Measured memory_bytes: 27076
package main
 
import(
	"fmt"
	"regexp"
)
 
 
func main(){
var a string
fmt.Scan(&a)
if regexp.MustCompile(`[A-Z]`).Match([]byte(a)) {
  fmt.Println("A")
}
if regexp.MustCompile(`[a-z]`).Match([]byte(a)) {
  fmt.Println("a")
}
}

Measured memory_bytes: 2000
import math
a, b, x = map(int, input().split())
l = (a*a*b - x)/(a*a / 2)
if l <= b:
    k = math.degrees(math.atan2(l, a))
    print(k)
else:
    l = x/(a*b/2)
    k = 90.0 - math.degrees(math.atan2(l, b))
    print(k)


Measured memory_bytes: 3060
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    d = defaultdict(int)
    for i in s:
        d[i] += 1
    for i in d.keys():
        if d[i] != 2:
            print("No")
            quit()
    print("Yes")
    return

#B
def B():
    n = I()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        k = p[i-1:i+2]
        k.sort()
        if k[1] == p[i]:
            ans += 1
    print(ans)
    return

#C
def C():
    n = I()
    d = LI()
    d.sort()
    print(d[n//2]-d[n//2-1])
    return

#D
def D():
    n,k = LI()
    fact = [1]*100001
    for i in range(1,100001):
        fact[i] = fact[i-1]*i%mod
    inv = [1]*100001
    inv[-1] = pow(fact[-1],mod-2,mod)
    for i in range(1,100001)[::-1]:
        inv[i-1] = inv[i]*i%mod

    for i in range(1,k+1):
        if n-k+1 < i:
            print(0)
        else:
            ans = fact[n-k+1]*inv[i]*inv[n-k+1-i]%mod
            ans *= fact[k-1]*inv[k-i]*inv[i-1]%mod
            ans %= mod
            print(ans)
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return


#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 44400
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll l ,r ,d;
    cin>>l>>r>>d;
    ll ans = 0;
    for(ll i=l; i<=r; i++){
        if(i%d==0) ans++;
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
int INF = 1000000000;
int main(){
	int N, M, P;
	cin >> N >> M >> P;
	vector<vector<pair<int, int>>> E(N);
	vector<vector<int>> E2(N);
	for (int i = 0; i < M; i++){
		int A, B, C;
		cin >> A >> B >> C;
		A--;
		B--;
		E[A].push_back(make_pair(C - P, B));
		E2[B].push_back(A);
	}
	vector<bool> ok(N, false);
	ok[0] = true;
	queue<int> Q;
	Q.push(0);
	while (!Q.empty()){
		int v = Q.front();
		Q.pop();
		for (auto P : E[v]){
			int w = P.second;
			if (!ok[w]){
				ok[w] = true;
				Q.push(w);
			}
		}
	}
	vector<bool> ok2(N, false);
	ok2[N - 1] = true;
	queue<int> Q2;
	Q2.push(N - 1);
	while (!Q2.empty()){
		int v = Q2.front();
		Q2.pop();
		for (int w : E2[v]){
			if (!ok2[w]){
				ok2[w] = true;
				Q2.push(w);
			}
		}
	}
	vector<int> d(N, -INF);
	d[0] = 0;
	bool inf = false;
	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			for (auto P : E[j]){
				int c = P.first;
				int w = P.second;
				if (d[w] < d[j] + c){
					d[w] = d[j] + c;
					if (i == N - 1 && ok[w] && ok2[w]){
						inf = true;
					}
				}
			}
		}
	}
	if (inf){
		cout << -1 << endl;
	} else {
		cout << max(d[N - 1], 0) << endl;
	}
}

Measured memory_bytes: 3904
#O(n^2)

NumOfBills, Amnt = map(int, input().split())
marker = 0

for i in range(NumOfBills+1):
    if marker != 0:
        break
    else:
        for k in range(NumOfBills-i+1):
            if i*10000 + k*5000 + (NumOfBills - i - k)*1000 == Amnt:
                print(i,k,NumOfBills-i-k)
                marker += 1
                break
            else: continue
else: 
    if marker == 0:
        print(-1,-1,-1)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    int n;
    int b=0;
	cin>>n;
	long long a[n];
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    sort(a, a+n);
    for(int i=1;i<n;i++){
      if(a[i-1]==a[i]){
        b++;
        break;
      }
    }
    if(b==0){
      cout<<"YES";
    }else{
      cout<<"NO";
    }
	return 0;
}

Measured memory_bytes: 1792
def main():
    N = int(input())
    S = [s for s in input()]
    ans = S.count("R") * S.count("G") * S.count("B")
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            k = j + (j - i)
            if N - 1 < k:
                continue
            if S[k] != S[i] and S[k] != S[j] and S[i] != S[j]:
                ans -= 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
open Batteries

let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let rec loop i j n accum res =
    if i = n then (
      Printf.printf "%d\n" res;
    ) else (
      if j = n then (
        loop (i+1) j n (accum lxor a.(i)) (res+j-i-1)
      ) else (
        if (accum land a.(j) = 0) then (

          let v = accum lxor a.(j) in
          loop i (j+1) n v (res+1)

        ) else (
          loop (i+1) j n (accum lxor a.(i)) (res+j-i-1)
        )
      )
    )
  in
  loop 0 0 n 0 0


Measured memory_bytes: 6784
s=int(input())
# dp[i][j] where i is length and j is sum
dp=[0]*(s+1)
mxn=(s+2)//3+1
ans=0
mod=10**9+7
dp[0]=1
for i in range(1,mxn):
    ndp=[0]*(s+1)
    cs=0
    for j in range(s-2):
        cs+=dp[j]
        ndp[j+3]+=cs
    ans=(ans+ndp[s])%mod
    dp=ndp
print(ans)

Measured memory_bytes: 9336
n = int(input())
s = input()
r = 0
g = 0
b = 0
for i in s:
    if i == 'R':
        r += 1
    elif i == 'G':
        g += 1
    else:
        b += 1
ans = r * g * b

for i in range(n):
    for j in range(i+1,n):
        if s[i] == s[j]:
            continue
        k = 2*j - i
        if k >= n or s[k] == s[i] or s[k] == s[j]:
            continue
        ans -= 1
        
print(ans)

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

listA=list(map(int,input().split()))

kenken_map = input()

A_init = listA[1]-1
B_init = listA[2]-1
A_goal = listA[3]-1
B_goal = listA[4]-1

kenken_temp_b = kenken_map[B_init:B_goal+1]
kenken_temp_b_i = kenken_map[B_init-1:B_goal+1]
kenken_temp_b_goal = kenken_map[:B_goal] + '#' + kenken_map[B_goal+1:]
kenken_temp = kenken_temp_b_goal[A_init:A_goal+1]


if '##' in kenken_temp_b:
    print('No')
elif not '##' in kenken_temp:
    print('Yes')
elif '...' in kenken_temp_b_i:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3836
package main
import "fmt"

func main(){
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)

	var parMax, par2, par3 int
	
	if a > b {
		parMax = a
		par2 = b
	} else {
		parMax = b
		par2 = a
	}
	
	if parMax > c {
		par3 = c
	} else {
		par3 = parMax
		parMax = c
	}
	
	for i := 0; i < k; i++ {
		parMax = parMax * 2
	}

	fmt.Printf("%d", parMax + par2 + par3)
	
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3,typename T4> inline void print4(T1 a, T2 b, T3 c, T4 d){
	cout << a << " " << b << " " << c << " " << d << endl;
}
const int mod = 1e9 + 7;

vl divisor(ll k){
	vl c;
	for(ll i=1; i*i<=k; i++){
		if(k % i == 0){
			c.push_back(i);
			if((k / i) != i){
				c.push_back(k/i);
			}
		}
	}
	sort(c.begin(), c.end());
	return c;
}

int main(){
	ll n; cin >> n;
	vl div = divisor(n);
	vl div2 = divisor(n-1);
	ll ans = 0;
	set<ll> se;
	for(auto i : div){
		if(i==1) continue;
		ll tmp = n;
		while(tmp % i == 0 && tmp >= i){
			tmp /= i;
		}
		if(tmp % i == 1){
			ans++;
		}
		se.insert(i);
	}
	for(auto i : div2){
		if(i==1) continue;
		if(se.find(i) != se.end()) continue;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import javax.swing.text.html.HTML


//https://pitsbuffersolution.com/compro/atcoder/arc079d.php
//$N=50$とする。$K$を$N$で割った商を$Q$、余りを$R$として、$R$個は$N−1+(Q−R+N+1)$、残りは$N−1+(Q−R)$を出力する。

fun main(arg: Array<String>) {
    val K = nextLong()
    val N = 50
    val Q = K / N
    val R = K % N
    println(N)
    val ans = LongArray(N)
    for (n in 0 until N) {
        ans[n] = N - 1 + Q - R + if (n < R) N + 1 else 0
    }
    println(ans.joinToString(" "))
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }



Measured memory_bytes: 34220
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
    string S; cin>>S;

    if(S=="SAT") cout<<"1"<<endl;
    if(S=="FRI") cout<<"2"<<endl;
    if(S=="THU") cout<<"3"<<endl;
    if(S=="WED") cout<<"4"<<endl;
    if(S=="TUE") cout<<"5"<<endl;
    if(S=="MON") cout<<"6"<<endl;
    if(S=="SUN") cout<<"7"<<endl;
}


Measured memory_bytes: 3528
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
using namespace std;
string s, t;
set<string> S;

void Work(){
    int lens = s.size();
    int lent = t.size();
    for(int i = 0; i < lens; i++){
        if(s[i] == '?'){
            string tmp = s;
            for(int j = 0; j < i; j++) if(tmp[j] == '?') tmp[j] ='a';
            bool can = false;
            for(int j = 0; j < lent; j++){
                if(tmp[i+j]!= '?' && tmp[i+j] != t[j]) break;
                tmp[i+j] = t[j];
                if(j == lent - 1) can = true;
            }
            if(can){
                for(int j = i; j < lens; j++) if(tmp[j] == '?') tmp[j] = 'a';
                S.insert(tmp);
            }
        }
        if(s[i] == t[0]){
            string tmp = s;
            bool can = false;
            for(int j = 0; j < i; j++) if(tmp[j] == '?') tmp[j] = 'a';
            for(int j = 0; j < lent; j++){
                if(s[i+j] != t[j] && s[i+j] != '?') break;
                tmp[i+j] = t[j];
                if(j == lent - 1) can = true;
            }
            if(can){
                for(int j = i; j < lens; j++) if(tmp[j] == '?') tmp[j] = 'a';
                S.insert(tmp);
            }
        }
    }
    if(S.size() == 0) cout << "UNRESTORABLE" << endl;
    else cout << *S.begin() << endl;
}
int main(){
    cin >> s >> t;
    Work();
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  long n, m;

  scanf("%ld%ld", &n, &m);

  long long h[n];

  for (long i = 0; i < n; i++)
    scanf("%lld", &h[i]);

  long ab[m][2];

  for (long i = 0; i < m; i++)
    for (long j = 0; j < 2; j++)
      scanf("%ld", &ab[i][j]);

  /*M本の道に従って計算*/
  long ans = 0, hh[n]; /* <- pear よりlow なら++*/
  for (long i = 0; i < n; i++)
    hh[i] = 0;

  for (long i = 0; i < m; i++) {
    if (h[ab[i][0]-1] >  h[ab[i][1]-1]) hh[ab[i][1]-1]++;
    else if(h[ab[i][0]-1] < h[ab[i][1]-1])  hh[ab[i][0]-1]++;
    else {hh[ab[i][1]-1] = hh[ab[i][0]-1] = 1;}
  }

  for (long i = 0; i < n; i++)
    if (hh[i] == 0) ans++;
    
  printf("%ld\n", ans);

  return 0;
}




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

using namespace std;
using ll=long long;

int main()
{
    int n;cin >>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    int q;cin >> q;
    int m[q];
    for(int i=0;i<q;i++){
        cin >>m[i];
    }
    vector<ll>l;
    for(int s=0;s<(1<<n);s++){
        ll sum=0;
        for(int i=0;i<n;i++){
            if(s&(1<<i))sum+=a[i];
        }
        l.push_back(sum);
    }
    for(int i=0;i<q;i++){
        bool flg=false;
        for(ll j=0;j<l.size();j++){
            if(m[i]==l[j])flg=true;
        }
        if(flg)puts("yes");
        else puts("no");
    }
    return 0;
}



Measured memory_bytes: 11072
/*<----------------------------------------------------------------------->

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
void solve(){
    ll n  ,x;cin >> n ;
    map<ll,ll> m ;
    For(i,n-1)
    {
        cin >> x;
        m[x]++ ;
    }
    Rep(i,n)pf(m[i]) ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


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

using namespace std;

const int MaxN = 707;

bool a[MaxN][MaxN];
int c[MaxN];
int n, m;

int all, cnt[3];

void fail()
{
    cout << "-1\n";
    exit(0);
}

void dfs(int x, int y)
{
    c[x] = y;
    ++cnt[y];


    for(int i = 1; i <= n; ++i)
        if(!a[x][i] && i != x)
        {
            if(!c[i])
                dfs(i, 3 - y);
            else
                if(c[i] == c[x])
                    fail();
        }
}

bool dp[MaxN][MaxN];

int f(int x)
{
    return x * (x - 1) / 2;
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;

    for(int i = 1; i <= m; ++i)
    {
        int x, y;
        cin >> x >> y;
        a[x][y] = a[y][x] = true;
    }

    vector <pair<int, int> > v;

    for(int i = 1; i <= n; ++i)
    {
        if(!c[i])
        {
            cnt[1] = cnt[2] = all = 0;
            dfs(i, 1);

            v.push_back(make_pair(cnt[1], cnt[2]));
        }
    }

    dp[0][0] = true;
    for(int i = 1; i <= v.size(); ++i)
        for(int j = 0; j <= n; ++j)
            if(dp[i - 1][j])
            {
                dp[i][j + v[i - 1].first] = true;
                dp[i][j + v[i - 1].second] = true;
            }

    int ans = f(n);

    for(int i = 0; i <= n; ++i)
        if(dp[v.size()][i])
            ans = min(ans, f(i) + f(n - i));

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1280
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

int main()
{
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n;
	cin >> n;


	map<string,int> cnt;
	int maxi = 0;
	for(int i =0; i< n; ++i)
	{
		string s;
		cin >> s;
		cnt[s]++;
		maxi = max(maxi, cnt[s]);
	}

	for(auto &it : cnt)
	{
		if(it.second == maxi)
		{
			cout << it.first << '\n';
		}
	}

    return 0;
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main(){
 int n,m;
  cin >> n >> m;
  vector<int> ac(n), pena(n);
  rep(i,m){
  int p;
  string s;
    cin >> p >> s;
    p--;
    if (ac[p]) continue;
    if (s == "AC"){
      ac[p] =1;
    }
    else{ 
      pena[p]++;
    }
    
  }
  int AC = 0, PENA=0;
    rep(i,n){
      AC+=ac[i];
      if (ac[i]) PENA+= pena[i];
    }
    cout << AC << ' ' << PENA << endl;
}

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

int main()
{
  int n, k;
  while (cin >> n >> k, n) {

    int a[101010] = {0};

    cin >> a[1];
    for (int i = 2; i < n + 1; i++){
      cin >> a[i];
      a[i] += a[i - 1];
    }

    int max_n = -1e9;
    for (int i = 0; i < n - k; i++){
      max_n = max(max_n, a[k + i] - a[i]);
    }

    cout << max_n << endl;
  }
}

Measured memory_bytes: 3376
l = [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]
print(l[int(input())-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cerr<<#x<<" "<<x<<endl;
#define f(i,n) for(ll i=0; i<n; i++)
#define f1(i,n) for(ll i=1; i<=n; i++)
#define fr(i,n) for(ll i=n-1; i>=0; i--)
#define f1r(i,n) for(ll i=n; i>0; i--)
#define mst(arr,val) memset(arr,val,sizeof(arr))
#define all(x) x.begin(),x.end()

typedef long long int ll;
typedef pair<ll,ll> pii;
ll M=1e9+7;
ll M2=998244353;
ll M3 = 1e8;
ll MAX = 5001;
string s = "Everything correct till here!";

void show(vector<ll> v)
{
    for(ll i=0; i<v.size(); i++)
        cout<<v[i]<<" ";
    cout<<"\n";
}
void showrev(vector<ll> v)
{
    for(ll i=0; i<v.size(); i++)
        cout<<v[v.size()-i-1]<<" ";
    cout<<"\n";
}
void showarr(ll arr[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
}
void showpv(vector<pair<ll,ll> > v)
{
    f(i,v.size())
        cout<<v[i].ff<<" "<<v[i].ss<<"\n";
}
int main()
{
    IOS
    ll T = 1,Q=1;
    //cin>>T;
    while(T--)
    {
        ll n,k; cin>>n>>k;
        ll a[n]; f(i,n) cin>>a[i];
        ll dp[n];
        dp[0] = 0;
        for(ll i=1; i<min(n,k); i++)
            dp[i] = abs(a[i]-a[0]);

        for(ll i=k; i<n; i++)
        {
            ll ans = 99999999999999999;
            for(ll j=i-k; j<i; j++)
                ans = min(ans,dp[j]+abs(a[j]-a[i]));
            dp[i] = ans;
        }
        //showarr(dp,n);
        cout<<dp[n-1];
    }
    return 0;
}



Measured memory_bytes: 1792
#include<cstdio>
#include<map>
#include<cassert>
#include<functional>
#include<string>
#include<cassert>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;
const int MOD(1e9+7);

int n;
int a[100011];
int main()
{
 scanf("%d", &n);
 int ans = 0;
 for (int i = 0; i < n; i++) {
  scanf("%d", a+i);
  --a[i];
 }
 for (int i = 0; i < n; i++) {
  if (a[a[i]] == i) ++ans;
 }
 printf("%d\n", ans >> 1);
 return 0;
}


Measured memory_bytes: 512
import Data.List( sortBy, sort, group)
main = do
    getLine
    as_ <- return . map (read::String->Int) . words =<< getLine
    let
	gs = group . sort $ as_
	counts = map length gs
	countSorted = sortBy (flip compare) counts
	proc []			= 0
	proc [n]
	  | even n		= 0
	  | otherwise		= 1
	proc (1:ns)		= 1 + length ns
	proc (2:tl@(1:ns))	= proc tl
	proc (2:2:ns)		= 2 + proc ns
	proc (2:n:ns)		= 1 + proc ((n-1):ns)
	proc (n:ns)
	  | even n		= proc (2:ns)
	  | otherwise		= 1 + proc ns
    print $ proc countSorted

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin>>s>>t;
    f1(i,0,s.size())
    {
        if(s[i]!=t[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979


int main()
{
	int n, a, b;
	ll ans = 0LL;
	cin >> n >> a >> b;

	for (int i = 1; i <= n; i++)
	{
		int _i = i;
		int count = 0;
		while (_i)
		{
			count += _i % 10;
			_i /= 10;
		}
		if (count >= a && count <= b) ans += (ll)i;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;


int MOD=1000000007;


int main(){
    long long N,sq=0;
    cin >> N;
    sq=sqrt(N);
    while(sq!=0){
        if(N%sq==0){
            long long co=0,cou=0;
            N=N/sq;
            while(N!=0){
                N/=10;
                cou+=1;
            }
            while(sq!=0){
                sq/=10;
                co+=1;
            }
            cout << max(co,cou) << endl;
            return 0;
        }
        sq-=1;
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
string s, t;
const ll L_MAX = 3000+10;

ll dp[L_MAX][L_MAX]; // dp[i][j] = (s[i],t[j]までの最長共通部分列長)

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

    cin >> s >> t;

    ll n = SZ(s);
    ll m = SZ(t);

    for(ll i=0;i<=n;i++){
        dp[i][0] = 0;
    }
    for(ll j=0;j<=m;j++){
        dp[0][j] = 0;
    }
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=m;j++){
            if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }

    ll i = n;
    ll j = m;

    string ans = "";

    while(i!=0 && j!=0){
        if(s[i-1]==t[j-1]){
            ans += s[i-1];
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>=dp[i][j-1]){
                i--;
            }
            else j--;
        }
    }
    reverse(ALL(ans));

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 74220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    bool isCheckingR = true;
    int rcount = 0;
    int lcount = 0;
    int i_lastR = 0;
    int odd_count = 0;
    int even_count = 0;
    rep(i,n){
        if(isCheckingR){
            if(s[i] == 'R'){
                rcount++;
            } else {
                i_lastR = i - 1;
                even_count += (rcount + 1) / 2;
                odd_count += rcount / 2;
                
                isCheckingR = false;
                lcount++;
            }
            if(i == n - 1){
                odd_count++;
                ans[i_lastR] = even_count;
                ans[i] = odd_count;
            }
        }
        else {
            if(s[i] == 'L'){
                lcount++;
            } else {
                odd_count += (lcount + 1) / 2;
                even_count += lcount / 2;
                rcount = 1;
                lcount = 0;
                isCheckingR = true;
                ans[i_lastR] = even_count;
                ans[i_lastR + 1] = odd_count;
                even_count = 0;
                odd_count = 0;
            }
            if(i == n - 1){
                odd_count += (lcount + 1) / 2;
                even_count += lcount / 2;
                ans[i_lastR] = even_count;
                ans[i_lastR + 1] = odd_count;
            }
        }
        // cout << "i: " << i << endl;
        // cout << "odd_count: " << odd_count << endl;
        // cout << "even_count: " << even_count << endl;
        // cout << "lcount: " << lcount << endl;
        // cout << "rcount: " << rcount << endl;
        // cout << "i_lastR: " << i_lastR << endl;

    }
    rep(i,n){
        cout << ans[i] << " "; 
    }
    cout << endl;
    return 0;
}


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

int main() {
int  A,B,C,D ;
    cin >> A >> B >> C >> D ;
  int L=A+B, R=C+D;
  
  if (L>R){
    cout << "Left" << endl;  
  }
  else if(L==R){
    cout << "Balanced" << endl ;
  }
  else {		
        cout << "Right" << endl;  
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using P = pair<int, int>;
using LL = long long;

#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN_LL(v) LL v;cin>>v;
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
const int MOD = 1000000007;
const int INF = 1000000000;

int main() {
  IN(N);

  vector<string> v;
  REP(i, N) {
    string S;
    cin >> S;
    SORT(S);
    v.push_back(S);
  }
  SORT(v);
  LL ans = 0;
  REP(i, N) {
    auto it = upper_bound(ALL(v), v[i]);
    LL n = (LL)(it - (v.begin() + i));
    // nC2
    ans += n * (n-1) / 2;
    i += n-1;
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 7796
# 問題：https://atcoder.jp/contests/abc139/tasks/abc139_a

def main():
    S = input()
    T = input()
    res = 0
    for i in range(3):
        if S[i] == T[i]:
            res += 1
    print(res)

if __name__ == '__main__':
    main()



Measured memory_bytes: 9016
def dfs(a, b, f):
    if vis[f] == 1: return
    vis[f] = 1
    for t in V[f]:
        if f!=a or t!=b: dfs(a, b, t)

n, m = map(int, input().split())
E, V = [], [[] for _ in range(n)]
for _ in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    E.append([a, b])
    V[a].append(b); V[b].append(a)
ans = 0
for a, b in E:
    vis = [0]*n
    dfs(a, b, a)
    if vis[b] == 0: ans += 1
print(ans)


Measured memory_bytes: 9220