akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    rep(ri, 2) {  // solve R
        int cnt = 0;
        rep(i, n) {
            if (s[i] == 'R')
                cnt++;
            else {
                ans[i] += cnt / 2;
                ans[i - 1] += (cnt + 1) / 2;
                cnt = 0;
            }
        }

        reverse(ans.begin(), ans.end());
        reverse(s.begin(), s.end());
        rep(i, n) {
            if (s[i] == 'L')
                s[i] = 'R';
            else
                s[i] = 'L';
        }
    }

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

    return 0;
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
 
lli d[300][300];
 
void func(long long N, long long M, long long R, std::vector<long long> r, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
 
    vector<lli> per(R);
    REP(i,0,R)per[i]=i;
 
    REP(k,0,N)REP(i,0,N)REP(j,0,N)chmin(d[i][j],d[i][k]+d[k][j]);
 
    lli ans = INF;
 
    do{
        lli sum = 0;
        REP(i,1,R){
            sum += d[r[per[i-1]]][r[per[i]]];
        }
        chmin(ans,sum);
 
    }while(next_permutation(per.begin(),per.end()));
 
    cout<<ans<<endl;
 
}
 
int main(){
    // cout << fixed << setprecision(5);
    REP(i,0,300)REP(j,0,300)d[i][j]=INF;
    REP(i,0,300)d[i][i]=0;
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long R;
    scanf("%lld",&R);
    std::vector<long long> r(R);
    for(int i = 0 ; i < R ; i++){
        scanf("%lld",&r[i]);
        r[i]--;
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
        A[i]--,B[i]--;
        d[A[i]][B[i]]=C[i];
        d[B[i]][A[i]]=C[i];
    }
    func(N, M, R, std::move(r), std::move(A), std::move(B), std::move(C));
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define pb(x) push_back(x)
#define PRIME 1000000007
using namespace std;
typedef vector<vector<ll>> matrix;

int main()
{
   int a, b, c, k;
   cin >> a >> b >> c >> k;
   if (k <= a)
   {
      cout << k * 1 << endl;
   }
   else
   {
      k -= a;
      if (k <= b)
      {
         cout << a * 1 << endl;
      }
      else
      {
         k -= b;
         cout << (a - k) << endl;
      }
   }
}


Measured memory_bytes: 3636
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif

void solve() {
    int n;
    cin >> n;
    vi a(n), b(n);
    forn(i, n) cin >> a[i] >> b[i];
    sort(all(b));
    sort(all(a));
    if(n & 1){
        cout << (b[n / 2] - a[n / 2] + 1);
    }else{
        cout << ((b[n / 2] - a[n / 2] + b[n / 2 - 1] - a[n / 2 - 1]) + 1);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


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

#define    ll     long long int

int main( )
{
    int n, i, j;
    map<int, int> mp;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> j;
        mp[j]++;
        if (mp[j] == 2) {
            mp.erase(mp.find(j));
        }
    }
    cout << (int) mp.size() << '\n';
    return 0;
}



Measured memory_bytes: 4864
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int K = sc.nextInt();

        long[] posi = new long[N];
        long[] nega = new long[N];

        int posiSize = 0;
        int negaSize = 0;
        for (int i = 0; i < N; i++) {
            long value = sc.nextLong();
            if (value > 0) {
                posi[posiSize] = value;
                posiSize++;
            } else {
                nega[negaSize] = value;
                negaSize++;
            }
        }

        long min = Long.MAX_VALUE;

        // 全部右
        if (K <= posiSize) {
            min = Math.min(posi[K - 1], min);
        }
        // 全部左
        if (K <= negaSize) {
            min = Math.min(Math.abs(nega[negaSize - K]), min);
        }


        // 右行ってから左.
        for (int i = 1; i <= posiSize; i++) {
            if (i < K) {
                int posiCount = i;
                int negaCount = K - i;
                if (negaCount <= negaSize) {
                    long posiD = (2 * posi[posiCount - 1]);
                    long negaD = Math.abs(nega[negaSize - negaCount]);
                    min = Math.min(posiD + negaD, min);
                }
            }
        }
        // 左行ってから右.
        for (int i = 1; i <= negaSize; i++) {
            if (i < K) {
                int negaCount = i;
                int posiCount = K - i;
                if (posiCount <= posiSize) {
                    long posiD = posi[posiCount - 1];
                    long negaD = 2 * Math.abs(nega[negaSize - negaCount]);
                    min = Math.min(posiD + negaD, min);
                }
            }
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 63312
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	string s;cin>>s;
	if(s=="ABC") cout<<"ARC";
	else cout<<"ABC";
	
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <stack>

using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
const int MaxN = 1e6;

int n,m,x,c,tnt1,tnt2;
int a[MaxN];

int main()
{
	cin >> n >> m >> x;
	for(int i = 0; i < m; i++)
	{
		cin >> c;
		a[c] = 1;
	}
	for(int i = x; i <= n; i++)
	{
		if(a[i] == 1)
			tnt1++;
	}
	for(int i = x; i >= 0; i--)
	{
		if(a[i] == 1)
			tnt2++;
	}
	int ans = min(tnt1,tnt2);
	cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#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++)


const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif
    const int m = 256;
    int n, l, x;
    cin >> n >> l;
    ll ans, p;
    vector<vector<ll>> bitdp(n + 1, vector<ll>(m, 0));
    bitdp[0][0] = 1;

    rep(k, n)
    {
        cin >> x;
        rep(i, n)
        {
            rep(j, m)
            {
                bitdp[n - i][j ^ x] += bitdp[n - i - 1][j];
                bitdp[n - i][j ^ x] %= mod;
            }
        }
    }

    ans = 0;
    p = 1;
    rep(i, n)
    {
        p *= i + 1;
        p %= mod;
        ans += (bitdp[i + 1][l] * p) % mod;
        ans %= mod;
    }
    cout << ans << rt;

    return 0;
}


Measured memory_bytes: 512
#![allow(dead_code)]
#![allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{BufWriter, stdin, stdout, Write};
const BITS: usize = 19;

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

    let n: i64 = scan.next();
    let d: i64 = scan.next();
    let d: i64 = d.checked_pow(2).unwrap();

    let mut arr: Vec<i64> = Vec::new();
    for _ in 0..n {
        let x: i64 = scan.next();
        let x = x.abs();
        let y: i64 = scan.next();
        let y = y.abs();
        let res: i64 = (x * x) + (y * y);
        arr.push(res);
    }

    arr = arr
        .iter()
        .filter_map(|i| if i > &d { None } else { Some(*i) }).collect::<Vec<i64>>();

    writeln!(out, "{}", arr.len());
}

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

using namespace std;

int main(){

  int l,a,b,c,d;
  int jp=0;
  int ma=0;
  int result;
  
  cin>>l>>a>>b>>c>>d;

  while(1){
	a=a-c;
	jp++;
	if(a<=0)
	  break;
  }

  while(1){
	b=b-d;
	ma++;
	if(b<=0)
	  break;
  }

  result=l-max(jp,ma);

  cout<<result<<endl;

  return 0;
  
}



Measured memory_bytes: 3080
import java.util.Scanner;
import java.util.ArrayDeque;
public class Main{
	static int h;
	static int w;
	static char[][] map;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		h=sc.nextInt();
		w= sc.nextInt();
		map=new char[h][w];
		int black=0;
		for(int i =0; i<h; i++){
			String s=sc.next();
			for(int j = 0; j<w; j++){
				map[i][j]=s.charAt(j);
				if(map[i][j]=='#'){
					black++;
				}
			}
		}
		ArrayDeque<Integer> qux=new ArrayDeque<>();
		ArrayDeque<Integer> quy=new ArrayDeque<>();
		qux.add(0);
		quy.add(0);
		int[] dx={1,0,0,-1};
		int[] dy={0,1,-1,0};
		int[][] ans=new int[h][w];
		map[0][0]='#';
		while(!qux.isEmpty()){
			int x = qux.poll();
			int y = quy.poll();
			for(int i=0; i<4; i++){
				if(jud(x+dx[i],y+dy[i])){
					qux.add(x+dx[i]);
					quy.add(y+dy[i]);
					map[y+dy[i]][x+dx[i]]='#';
					ans[y+dy[i]][x+dx[i]]=ans[y][x]+1;
				}
			}
		}
		if(ans[h-1][w-1]==0){
			System.out.println(-1);
		}else{
			System.out.println(h*w-black-ans[h-1][w-1]-1);
		}
	}
	static boolean jud(int x,int y){
		return x>=0 && x<w && y>=0 && y<h && map[y][x]!='#';
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu long long unsigned
int main()
{
    int t,a,b,x,y,z,n,mx,mn,tmp;
        int cnt=0,ans=0;
        string s="";
        vector<int>vc;
        map<int,int>mp;
        map<char,int>mc;
        scanf("%d %d %d",&x,&y,&z);
        char ch,ch2;
        ans=x/y;
        if(x%y!=0) ans++;
        printf("%d\n",ans*z);




    return 0;
}




Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    map<ll, int> mp;
    ll ans = 0;
    rep(i, N) {
        ll x = (i+1) - A[i];
        ans += mp[x];
        mp[A[i] + (i+1)]++;
    }
    cout << ans << '\n';    
    return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string s, t;
    cin >> s >> t;
    if (s == t) {
        cout << "Yes" << endl;
        return 0;
    }
    rep(i, s.size()) {
        char tmp = s[s.size()-1];
        s.pop_back();
        s = tmp + s;
        if (s == t) {
            if (s == t) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


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

namespace ConsoleApp55
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());//.Split(' ').Select(int.Parse)
            var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            for ( var i = 1; i< 1000; i++)
            {
                var r = check(N * i, ab);
                if (r== 1)
                {
                    Console.WriteLine("OK");
                    return;
                }
                
            }
            Console.WriteLine("NG");



        }
        static int  check (int c ,int[] ab ){

            if ( ab[1]< c)
                return -1;
            return ab[0] <= c && c <= ab[1] ? 1 :  0;


            }
    }
}


Measured memory_bytes: 27912
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int n;
while( cin >> n,n){
	int I[256];
	for(int i=0;i<n;i++) cin >> I[i];
	double Hmin = -1;
	int mS, mA, mC;
	for(int S=0;S<16;S++){
		for(int A=0;A<16;A++){
			for(int C=0;C<16;C++){
				double tmpH = 0.0;
				int R = S;
				int O[256];
				memset(O, 0, sizeof(O));
				for(int i=0;i<n;i++){
					R = (A*R+C)%256;
					O[(I[i]+R)%256]++;
				}
				for(int i=0;i<256;i++){
					if(O[i]!=0){
						double d = (double)O[i]/n;
						tmpH -= (d*(log10((double)O[i])/log10(2.0)-log10((double)n)/log10(2.0)));
//						tmpH -= d*(log10(d)/log10(2.0));
					}
				}
				if(Hmin<-0.5||tmpH<Hmin){
					Hmin = tmpH;
					mS = S; mA = A; mC = C;
				}
			}
		}
	}
	cout << mS << " " << mA << " " << mC << endl;
}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>

int k;
long long q[1000000]; int h,t;

int main() {
	int k; std::cin >> k;
	h = 1, t = 0;
	for(int i = 1;i <= 9;i++) q[++t] = i;
	for(int i = 1;i < k;i++) {
		long long n = q[h++];
		int mod = n % 10;
		if(mod != 0) q[++t] = 10 * n + mod - 1;
		q[++t] = 10 * n + mod;
		if(mod != 9) q[++t] = 10 * n + mod + 1;
	}
	std::printf("%lld\n",q[h]);
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb(a) push_back((a))
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
//-------------------関数----------------------//

ll ch[114514], shurui = 0;
string str;
//-------------------??¢??°----------------------//

int main() {
  cin >> str;
  if (str.size() == 1) {
    cout << "YES" << endl;
    return 0;
  }
  REP(i, str.size()) {
    if (ch[str[i] - 'a'] == 0) {
      shurui++;
    }
    ch[str[i] - 'a']++;
  }
  if (shurui == 1) {
    cout << "NO" << endl;
    return 0;
  }
  sort(ch, ch + shurui);
  if (shurui == 2) {
    if (str.size() == 2) {
      cout << "YES" << endl;
      return 0;
    }
    cout << "NO" << endl;
    return 0;
  }
  if (ch[2] - ch[0] <= 1) {
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 512
n,m = map(int,input().split())
ka = [list(map(int,input().split())) for i in range(n)]
a = [ka[i][1:] for i in range(n)]
a_all =[]
for i in a:
  for j in range(len(i)):
    a_all.append(i[j])
cnt = 0
for i in range(m):
  if a_all.count(i+1) == n:
    cnt+=1
print(cnt)

Measured memory_bytes: 3064
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
#define int long long
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),x=read(),d=read(),a[200005],pre[200005],suf[200005];
map<int,set<pair<int,int> > > segs;
signed main(){
	if(d<0)		d=-d,x=-x;
	a[1]=x;
	fz(i,2,n)	a[i]=a[i-1]+d;
	if(d==0){
		if(x==0)	puts("1");
		else		print(n+1);
		return 0;
	}
	fz(i,1,n)	pre[i]=pre[i-1]+a[i];
	fd(i,n,1)	suf[i]=suf[i+1]+a[i];
	fz(i,0,n){//x*i+d*y
		int mod=(x*i+d*(1ll<<30))%d;
		int l=pre[i],r=suf[n-i+1];
		int _l=(l-mod)/d,_r=(r-mod)/d;
		segs[mod].insert({_l,_r});
	}
	vector<int> used;
	foreach(it,segs)	used.push_back(it->first);
	int ans=0;
	foreach(it,used){
		int val=*it,r=-1ll<<45;
		foreach(seg,segs[val]){
			int L=seg->first,R=seg->second;
			if(r<L)			ans+=(R-L+1),r=R;
			else if(r<=R)	ans+=R-r,r=R;
		}
	}
	cout<<ans<<endl;
	return 0;
}
/*1
3 4 2
*/
/*2
2 3 -3
*/
/*3
100 14 20
*/

Measured memory_bytes: 38388
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;
const int dx[] = {0,1};
const int dy[] = {1,0};

int main(){
  int H,W;
  cin >> H >> W;
  int dp[H][W];
  int imap[H][W];
  rep(i,H){
    string s;
    cin >> s;
    rep(j,W){
      dp[i][j] = INF;
      imap[i][j] = s[j]-'0';
    }
  }
  dp[0][0] = imap[0][0];
  rep(i,H){
    rep(j,W){
      rep(k,2){
	int nx = j+dx[k],ny = i+dy[k];
	if(!(0<=nx && nx < W && 0<= ny && ny < H))continue;
	dp[ny][nx] = min(dp[ny][nx],dp[i][j]+imap[ny][nx]);
      }
    }
  } 
  cout << dp[H-1][W-1] << endl;


return 0;
}

Measured memory_bytes: 1224
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;

  ll cur = 1;
  rep(i, n) { cur = min(cur + k, cur*2); }

  cout << cur << endl;

  return 0;
};


Measured memory_bytes: 256
h, w = map(int, input().split())
A = [input() for _ in range(h)]
mod = 10**9 + 7
memo = [[0] * w for _ in range(h)]
for i in range(h):
    if A[i][0] == '.':
        memo[i][0] = 1
    else:
        break
for j in range(w):
    if A[0][j] == '.':
        memo[0][j] = 1
    else:
        break
for i in range(1, h):
    for j in range(1, w):
        if A[i][j] == '#':
            memo[i][j] = 0
        else:
            memo[i][j] = (memo[i-1][j] + memo[i][j-1]) % mod
print(memo[-1][-1])

Measured memory_bytes: 71968
class NormalInput{
  input: string[];
  pointer: number;
  constructor(raw:string){
    this.input=raw.split(/ |\n/);
    this.pointer=0;
  }
  int():number{
    const ret= parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  }
  str():string{
    const ret= this.input[this.pointer];
    this.pointer++;
    return ret;
  }
  strs(length:number):string[]{
    let ret:string[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.str());
    }
    return ret;
  }
  ints(length:number):number[]{
    let ret:number[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.int());
    }
    return ret;
  }
}
function Main(_: NormalInput) {
  const [A,B]=[_.int(),_.int()];
  if((A-B)%2==0){
    console.log((A+B)/2);
  }else{
    console.log('IMPOSSIBLE')
  }
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        List<Point> list = new ArrayList<Point>();
        for (int i = 0; i < N; i++) {
            Point p = new Point();
            p.x = scan.nextLong();
            p.y = scan.nextLong();
            list.add(p);
        }
        list.sort(new PointComparator());
        int answer = Integer.MAX_VALUE;
        HashMap<String, Integer> map = new HashMap<> ();
        for(int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (i == j) {
                    continue;
                }
                Point p1 = list.get(i);
                Point p2 = list.get(j);
                long dx = p2.x - p1.x;
                long dy = p2.y - p1.y;
                String key = dx +":" + dy;
                if (!map.containsKey(key)) {
                    map.put(key, 0);
                }
                map.put(key, map.get(key)+1);
            }
        }
        int max = 0;
        for (String key : map.keySet()) {
            max = Math.max(max, map.get(key));
        }
        System.out.println(N - max);
    }
    class Point {
        long x;
        long y;
    }
    class PointComparator implements Comparator<Point> {
        @Override
        public int compare(Point o1, Point o2) {
            if (o1.x == o2.x) {
                return Long.compare(o1.y, o2.y);
            }
            return Long.compare(o1.x, o2.x);
        }
    }
}

Measured memory_bytes: 23124
#include <stdio.h>

int main (){
	
	int darah;
	int dmg;
	int jumlah;
	int bagi;

	scanf ("%d %d", &darah, &dmg);
	jumlah = darah % dmg;
	bagi = darah / dmg;
	jumlah > 0 ? printf ("%d", bagi + 1) : printf ("%d", bagi);
	
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int mod=998244353;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
void ckmax(int &x,int y){
	if (x<y)
		x=y;
}
void ckmin(int &x,int y){
	if (x>y)
		x=y;
}
const int N=3005;
int A,B,C,D;
int dp[N][N][2];
int main(){
	A=read(),B=read(),C=read(),D=read();
	dp[A][B][0]=1;
	For(i,A,C)
		For(j,B,D)
			For(k,0,1){
				int v=dp[i][j][k];
				Add(dp[i+1][j][1],(LL)v*j%mod);
				if (!k)
					Add(dp[i][j+1][0],(LL)v*i%mod);
				else
					Add(dp[i][j+1][0],v);
			}
	cout<<Add(dp[C][D][0]+dp[C][D][1])<<endl;
	return 0;
}

Measured memory_bytes: 73996
#include<stdio.h>
#include<time.h>
 
#define MAX 100005 
 
typedef struct tq{
    char name[100];
    int time;
} s;
 
int head, tail, n;
s Q[MAX];
 
s dequeue()
{
    s t; 
    t = Q[head];
    head = (head + 1) % MAX;
    return t;
}
 
void enqueue(s x)
{
    Q[tail] = x;
    tail = (tail + 1) % MAX;
}
 
int main()
{
    int q, n, i, count;
    s x;
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    scanf("%d", &n);
    count = n;
    scanf("%d", &q);
    for(i=0;i<n;i++)
    {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].time);
        enqueue(Q[i]);
    }
    i = 0;
    while(head!=tail)
    {
        if(Q[head].time>q)
        {
            Q[head].time -= q;
            enqueue(dequeue());
            i += q;
        } 
        else
        {
            x = dequeue();
            i += x.time;
            printf("%s ", x.name);
            printf("%d\n", i);
        }
    }
    //printf("%lf\n",(double)clock()/CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 12840
function main(input) {
    var S = input.trim();

    var count = 0;
    var before = "";
    var current = "";
    var debug = [];
    for(var i = 0; S.length > i; i++) {
        current += S[i];
        if (current === before) {
            continue;
        }

        before = current;
        debug.push(current);
        current = "";
        count++;
    }

    console.log(count);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 31424
def main():
    a,b,c,d = map(int, input().split())
    ans = b-a+1
    cd = c*d
    g = gcd(c,d)
    if g != 0:
        cd //= g
    ans -= b//c-(a-1)//c
    ans -= b//d-(a-1)//d
    ans += b//cd-(a-1)//cd
    print(ans)

def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){
int N;
cin>>N;
int d[N];
rep(i,N){
    cin>>d[i];
}
long long ans=0;
for(int i=0;i<N-1;i++){
    for(int k=1;k+i<N;k++){
        
            ans+=d[i]*d[i+k];
    }
}
cout<<ans<<endl;
 return 0;
}
/*
3
3 1 2

11

7
5 0 7 8 3 3 2

312
*/

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

const int MAXN = 100005;
int N, W;
int num[MAXN];
int ans;
vector<int> d[MAXN];

void add(int v, int end) {
  for(int j = 0; j < d[v].size(); ++j) {
    int i = d[v][j];
    ++num[i];
    if(i < end && num[i] == 2) ++ans;
  }
}

void subtract(int v, int end) {
  for(int j = 0; j < d[v].size(); ++j) {
    int i = d[v][j];
    --num[i];
    if(i < end && num[i] == 1) --ans;
  }
}

int main() {
  for(int i = 1; i < MAXN; ++i) {
    for(int j = i; j < MAXN; j += i) {
      d[j].push_back(i);
    }
  }

  while(cin >> N >> W) {
    fill(num, num+MAXN, 0);
    ans = W;
    for(int i = 1; i < W; ++i) add(i, 1);
    for(int i = W; i <= N; ++i) {
      add(i, i-W+1);
      if(i != W) cout << " ";
      cout << ans;
      subtract(i-W+1, i-W+1);
      if(num[i-W+1] >= 2) {
        ++ans;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    cout << max(0,C - (A - B)) << endl;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
S=input()
flag = True

for i in range(len(S)):
  if i == a:
    if not S[a]=="-":
      flag = False
  else:
    if not S[i].isnumeric():
      flag = False
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9080
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
using namespace std;
#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N, K;
  cin >> N >> K;
  ll cnt = 0;
  for(int b = K + 1; b <= N; b++) {
    cnt += (b - K) * (N / b);
    int rest = N % b;
    if(K >= 1) {
      if(rest >= K) {
        cnt += rest - K + 1;
      }
    } else {
      cnt += rest;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

    cout << a*a <<endl;

    return 0;
}

Measured memory_bytes: 256
/*
  Author: @yash_31
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#define ll long long int
#define eb emplace_back
#define fatafat ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define ft first
#define sd second
#define deb(x) std::cout<<#x<<":"<<x<<endl;
#define endl "\n"
 
using namespace std;

const int mlt=(1<<18)+69;
const ll inf=1e18;
//TTBDC

int main()
{
  fatafat
  string s;
  cin>>s;
  int x=0;
  for(char ch:s){
    int y = ch-'0';
    x+=y;
  }
  if(x%9==0)cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int n = S.length();
    int ans = n;
    rep(i, S.length() - 1) {
        if(S[i] != S[i + 1]) {
            ans = min(ans, max(n - i - 1, i + 1));
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<string> s(n);
    for(int i = 0;i < n;i ++){
        string t;
        cin >> t;
        sort(t.begin(),t.end());
        s.at(i) = t;
    }
    sort(s.begin(),s.end());

    int ans = 0;
    int count = 0;
    for(int i = 1;i < n;i ++){
        if(s.at(i) == s.at(i-1)){
            count ++;
        }else{
            ans += (count+1) * count / 2;
            count = 0;
        }
        if(i == n-1) ans += (count + 1) * count / 2;
    }

    cout << ans << endl;
}

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

class Node{
public:
	vector< int > e_to;
	vector< int > e_cost;
	
	bool def;
	int min_cost;
	
	Node(){
		def = false;
		min_cost = -1;
	}
};
bool operator==(const Node& ot1, const Node& ot2){
	return ot1.min_cost == ot2.min_cost;
}
bool operator!=(const Node& ot1, const Node& ot2){
	return !(ot1 == ot2);
}
bool operator<(const Node& ot1, const Node& ot2){
	return ot1.min_cost < ot2.min_cost;
}
bool operator>(const Node& ot1, const Node& ot2){
	return ot1.min_cost > ot2.min_cost;
}
bool operator<=(const Node& ot1, const Node& ot2){
	return !(ot1 > ot2);
}
bool operator>=(const Node& ot1, const Node& ot2){
	return !(ot1 < ot2);
}

class Dijkstra{
	priority_queue< Node, vector< Node >, greater< Node > > que;
	vector< Node > nodes;
	
public:
	void Init(int node_num){
		nodes.resize(node_num);
		for(int i = 0; i < node_num; ++i){
			nodes[i] = Node();
		}
	}
	
	void Put(int id, int to, int cost){
		nodes[id].e_to.push_back(to);
		nodes[id].e_cost.push_back(cost);
	}
	
	int Run(int s, int t){
		
		for(vector< Node >::iterator it = nodes.begin(); it != nodes.end(); ++it){
			it->min_cost = -1;
			it->def = false;
		}
		
		nodes[s].min_cost = 0;
		que.push(nodes[s]);
		
		while(!que.empty()){
			Node def_node = que.top();
			que.pop();
		
			if(def_node.def)continue;
		
			def_node.def = true;
		
			for(int i = 0; i < def_node.e_to.size(); ++i){
				int to = def_node.e_to[i];
				int cost = def_node.min_cost + def_node.e_cost[i];
				
				if(nodes[to].min_cost == -1 || cost < nodes[to].min_cost){
					nodes[to].min_cost = cost;
					que.push(nodes[to]);
				}
			}
		}
		return nodes[t].min_cost;
	}
};


int main(){
	int n, r, k, t, p, s, d, v;
	Dijkstra dijk;
	
	
	cin >> n;
	
	dijk.Init(n);

	for(int i = 0; i < n; ++i){
		cin >> r >> k;
		
		for(int j = 0; j < k; ++j){
			cin >> t;
			dijk.Put(r - 1, t - 1, 1);
		}
	}
	
	cin >> p;
	
	for(int i = 0; i < p; ++i){
		cin >> s >> d >> v;
		
		int res = dijk.Run(s - 1, d - 1);
		
		if(res >= v || res == -1){
			cout << "NA" << endl;
		}else{
			cout << res + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1252
N, M, X = gets.chomp.split(" ").map(&:to_i)
C = []
A = []

N.times do
  c, *a = gets.chomp.split(" ").map(&:to_i)
  C << c
  A << a
end

SUC = []

def rec(i, s, c)
  if s.all? {|n| n >= X } then
    SUC << c
    return
  end
  return if i == N
  rec(i + 1, s, c)
  rec(i + 1, s.zip(A[i]).map {|a,b| a+b}, c + C[i])
end

rec(0, [0] * M, 0)

if SUC.size == 0 then
  puts "-1"
  return
end
puts SUC.min

Measured memory_bytes: 14308
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);

	for (size_t i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for (size_t i = 0; i < n; i++) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				cout << "DENIED";
				return 0;
			}
		}
	}
	cout << "APPROVED";
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

def read_int_n():
    return list(map(int, buff_readline().split()))


def read_str():
    return readline().strip()


def slv(N, A, B, C, S):
    D = [A, B, C]
    ans = []

    def f(s):
        t = []
        if 'A' in s:
            t.append(0)
        if 'B' in s:
            t.append(1)
        if 'C' in s:
            t.append(2)
        return t
    for i, s in enumerate(S):
        t = f(s)
        if D[t[0]] == 0 and D[t[1]] == 0:
            print('No')
            return
        else:
            if D[t[0]] == D[t[1]] == 1 and i != N-1:
                ns = S[i+1]
                if s == ns:
                    ans.append(t[1])
                    D[t[0]] -= 1
                    D[t[1]] += 1
                else:
                    n = set(t) & set(f(ns))
                    m = set(t) - n
                    n = n.pop()
                    m = m.pop()
                    ans.append(n)
                    D[n] += 1
                    D[m] -= 1


            elif D[t[0]] > D[t[1]]:
                ans.append(t[1])
                D[t[0]] -= 1
                D[t[1]] += 1
            else:
                ans.append(t[0])
                D[t[0]] += 1
                D[t[1]] -= 1

    print('Yes')
    for a in ans:
        if a == 0:
            print('A')
        elif a == 1:
            print('B')
        else:
            print('C')



def main():
    N, A, B, C = read_int_n()
    S = [read_str() for _ in range(N)]
    (slv(N, A, B, C, S))

if __name__ == '__main__':
    main()


Measured memory_bytes: 80276
macro_rules! get_one {
    ($t:ty) => {{
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<$t>().unwrap()
    }};

    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_one!($t)).collect::<Vec<_>>()
    };
}

use std::f64;

fn main() {
    let r = get_one!(i32);

    let l = 2. * (r as f64) * f64::consts::PI;
    println!("{}", l);
}


Measured memory_bytes: 2172
def abc():
    group1 = [1, 3, 5, 7, 8, 10, 12]
    group2 = [4, 6, 9, 11]
    x, y = map(int, input().split())
    if x in group1 and y in group1:
        print('Yes')
        return
    if x in group2 and y in group2:
        print('Yes')
        return
    print('No')


abc()


Measured memory_bytes: 2940