akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

using namespace std;
using P = pair<long, long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
int dist[2][100005];
vector<int> connect[100005];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N;
	cin >> N;

	string S;
	cin >> S;

	int right = 0;
	int left = 0;
	for (int i = 0; i < N;++i) {
		if (S[i] == ')') {
			right++;
			if (1 <= left) {
				right--;
				left--;
			}
		}
		else left++;
	}
	for (int i = 0; i < right;++i) {
		cout << '(';
	}
	cout << S;
	for (int i = 0; i < left;++i) {
		cout << ')';
	}
	cout << endl;
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
struct node{
    int x,y;
};
struct node ai[1000000];
bool cmp(node a,node b)
{
    if(a.y==b.y) return a.x<b.x;
    return a.y<b.y;
}
int main()
{
    int a,b;
    int min1 = 10000000;
    cin>>a>>b;
    for(int i=1; i<=b; i++)
    {
        cin>>ai[i].x>>ai[i].y;
        min1 = min(min1,ai[i].y);
    }
    sort(ai+1,ai+b+1,cmp);
    int ant = 1;
    for(int i=1;i<=b;i++)
    {
        if(ai[i].x>=min1)
        {
            ant++;
            min1 = ai[i].y;
        }
    }
    cout<<ant<<endl;
        return 0;

}
/*
4
128 4 340
*/



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

 /********* Credits *********/
 /// Coded by:             ///
 ///     - NikolaP         ///
 ///                       ///
 /// Compiler: C++ 14      ///
 /// Date: 11 - Sep - 2019 ///
 /***************************/

/** typedefs & #defines **/
//{

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define forn(i,n)    for(int i = 0 ; i < (int)(n) ; ++i)
#define forv(i,l,n)  for(int i = (int)(l) ; i < (int)(n) ; ++i)

#define all(x)     (x).begin(), (x).end()
#define allr(x)    (x).rbegin(), (x).rend()
#define mems(a,x)  memset((a),(int)(x),sizeof((a)))
#define memsb(a,x) memset((a),(bool)(x),sizeof(a))

using namespace std;

typedef long long int ll;
typedef double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

//}

int n,k;
int arr[(int)(1e5+4)];
int dp[(int)(1e5+4)];

int check(int i , int j){
    int ans = arr[i] - arr[j];

    if(ans < 0) return -ans;
    else return ans;
}

int f(int i){
    if(i == n-1) return 0;
    if(i >= n) return 1e9;
    if(dp[i] != -1) return dp[i];

    int ans = 1e9;
    forv(j,1,k+1)
        ans = min(ans,f(i+j) + check(i,i+j));

    dp[i] = ans;
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(8);
    // cout << fixed;

    cin >> n >> k;
    forn(i,n)
        cin >> arr[i];

    mems(dp,-1);

    cout << f(0);
    return 0;
}


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

struct BIT {
  long long n;
  vector<long long> dat;

  void init(long long n_input) {
    n = n_input + 1;
    dat.resize(n + 1);
    for (int i = 0; i <= n; i++) dat[i] = 0;
  }

  long long sum(long long i) {
    long long s = 0;
    while (i >= 0) {
      s += dat[i];
      i = (i & (i + 1)) - 1;
    }
    return s;
  }

  void add(long long i, long long x) {
    while (i <= n) {
      dat[i] += x;
      i |= i + 1;
    }
  }
};

int main() {
  int i;
  long long N;
  cin >> N;
  vector<int> A(N), sortedA(N);
  for (i = 0; i < N; i++) {
    cin >> A[i];
    sortedA[i] = A[i];
  }
  sort(sortedA.begin(), sortedA.end());
  int ub = N;
  int lb = 0;
  BIT bit;

  long long border = ((N * (N + 1) / 2) + 1) / 2;
  while (ub - lb > 1) {
    int mid = (ub + lb) / 2;
    int midn = sortedA[mid];
    bit.init(2 * N + 1);
    int sum = 0;
    bit.add(sum + N, 1);
    long long result = 0;
    for (i = 0; i < N; i++) {
      sum += A[i] >= midn ? 1 : -1;
      result += bit.sum(sum + N);
      bit.add(sum + N, 1);
    }
    if (result >= border) {
      lb = mid;
    } else {
      ub = mid;
    }
  }
  cout << sortedA[lb] << endl;
  return 0;
}


Measured memory_bytes: 5644
#include<bits/stdc++.h>
using namespace std;
#define MAX 100
char a[MAX],b[MAX];
int x[MAX+10],y[MAX+10],z[MAX*2+10];
int main()
{
    int len1,len2,i,j;
    scanf("%s%s",a,b);
    len1=strlen(a);
    len2=strlen(b);
    for(j=0,i=len1-1;i>=0;i--)
			x[j++]=a[i]-'0';
    for(j=0,i=len2-1;i>=0;i--)
    {
        if(b[i]!='.')
        {
            y[j++]=b[i]-'0';
        }
    }
    for(i=0;i<len1;i++)
		{
			for(j=0;j<len2;j++)
				z[i+j]=z[i+j]+x[i]*y[j];
		}
		for(i=0;i<MAX*2;i++)
		{
			if(z[i]>=10)  
			{
				z[i+1]=z[i+1]+z[i]/10;  
				z[i]=z[i]%10;  
			}
		}
		for(i=MAX*2;i>0;i--)  
		{
			if(z[i]==0)
				continue;
			else
				break;
		}
		 if(i<2)
       {
           printf("0\n");
           return 0;
       }
		for(;i>=2;i--)  //倒序输出
			printf("%d",z[i]);

		printf("\n");

}


Measured memory_bytes: 3824
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, S: str):
    print(S[:K - 1] + S[K - 1].lower() + S[K:])
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int dp[512345];

int main(){
  int N;cin >> N;
  string s;cin >> s;
  s = "0"+s+"0";
  for(int i=1;i<s.size()-1;i++){
    dp[i+1]=max(dp[i+1],dp[i]);
    if(s[i-1]=='1'&&s[i]=='0'&&s[i+1]=='1'){
      int l=1,r=1;
      while(s[i-l]=='1'){
        dp[i+1] = max(dp[i+1],dp[i-l-1]+l);
        l++;
      }
      while(s[i+r]=='1'){
        dp[i+r] = max(dp[i+r],dp[i-2]+r);
        r++;
      }
    }
  }
  cout << dp[s.length()-1] << endl;
  return 0;
}


Measured memory_bytes: 2840
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}



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

    if(S.length()<=K){
        cout << S <<endl;
    }else{
        string T="";
        rep(i,K){
            T+=S[i];
        }
        T+="...";



        cout << T<<endl;

    }

 
    return 0;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        2e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}




void solve()
{
 int a,b;
 cin >> a >> b;

 if(a<=b) cout<<"unsafe\n";
 else cout<<"safe\n";


}

int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <set>
#include <string>

using namespace std;

string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string new_str = "";
int main(){
    //cout << alpha.length();
    int n; string str;
    cin >> n >> str;
    for(int i = 0; i < str.length(); i++){
        int index = -1;
        for(int j = 0; j < 26; j++){
            if(str[i] == alpha[j]) {
                index = j;
                break;
            }
        }
        new_str += alpha[(index + n) % 26];

    }
    cout << new_str << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		System.out.println(m*(m-1)/2 + n*(n - 1)/2);
	}

}


Measured memory_bytes: 22228
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int all = 0, abr = 0;
    rep(i,n){
        if(s[i] == 'c') cout << "No" << endl;
        else if(s[i] == 'a'){
            if(all < a+b){
                cout << "Yes" << endl;
                all++;
            }
            else cout << "No" << endl;
        }
        else{
            if(all < a+b && abr < b){
                cout << "Yes" << endl;
                all++;
                abr++;
            }
            else cout << "No" << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 848
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef pair<int, int> pi;
typedef vector<pair<int,int> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
int cnt[N]={};
bool f;
int main()
{
int n,k,q;
cin>>n>>k>>q;
ve v(n,k);
for(int i=0;i<q ; i++)
{
    cin>>arr[i];
    cnt[arr[i]-1]++;
}
rep(i,n)
{
    v[i]=v[i]-abs(q-cnt[i]);
    if(v[i]<=0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}

go;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,const P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 2e5;
int n, k;
main(){
  cin.tie(0);
  cin >> n >> k;
  k = k*modInv(9, 11)%11;
  n--;
  int ans = 0;
  FOR(i, 0, 5){
    int j = i+9, m=2;
    while(j%11 != k){
      j += 7;
      m++;
    }
    if(m>n) continue;
    ans += (n-m)/11+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
def roll(l, command):
    '''
    return rolled list

    l : string list
    command: string
    '''
    res = []
    i = -1
    if command =='N':
        res = [l[i+2], l[i+6], l[i+3], l[i+4], l[i+1], l[i+5]]
    if command =='S':
        res = [l[i+5], l[i+1], l[i+3], l[i+4], l[i+6], l[i+2]]
    if command =='E':
        res = [l[i+4], l[i+2], l[i+1], l[i+6], l[i+5], l[i+3]]
    if command =='W':
        res = [l[i+3], l[i+2], l[i+6], l[i+1], l[i+5], l[i+4]]

    return res

faces = input().split()
commands = list(input())

for command in commands:
    faces = roll(faces, command)

print(faces[0])



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

ll n, a;
ll powmod(ll base, ll times)
{
	ll res = 1;
	while (times)
	{
		if (times % 2) res = res * base;
		base = base * base;
		times /= 2;
	}
	return res;
}
int main()
{
	cin >> n >> a;
	ll ans = n;
	for (ll i = 1; i <= 50; i++)
	{
		ll tmp = a * (i - 1);
		ll kk = pow(n*1.0, 1.0/i);
		ll cur = powmod(kk, i);
		tmp += kk * i;
		while (cur < n)
		{
			tmp++;
			if (cur % kk != 0) 
			{
				cout << "error" << endl;
				cout << 1/0 << endl;
				break;
			}
			cur /= kk;
			cur *= (kk + 1ll);
		}
		/*
		if (cur < n) kk++;
		cur = powmod(kk, i);
		ll now = kk;
		tmp += kk * i;
		while (cur > n && now > 1)
		{
			cur = (cur / now) * (now - 1);
			if (cur > n) tmp--;
			else break;
		}
		*/
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int M;
  cin>>M;
  vector<ll>d(M),c(M);
  for(int i=0;i<M;i++)cin>>d[i]>>c[i];
  ll ans=0;
  ll sum=0;
  for(int i=0;i<M;i++){
    sum+=d[i]*c[i];
    ans+=c[i];
  }
  ans+=(sum-1)/9;
  cout<<ans-1<<endl;
  return 0;
}


Measured memory_bytes: 3456
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

S = input()
if S[-1] == 's':
    print(S + 'es')
else:
    print(S + 's')


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

using namespace std;

int main() {

	int K, S, z, cnt = 0;
	cin >> K >> S;
	
	for (int x = 0; x <= K; x++)
	{
		for (int y = 0; y <= K; y++)
		{
			z = S - x - y;
			if (0 <= z && z <= K) cnt++;
		}
	}

	cout << cnt;

	return 0;
}

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

template <typename T>
struct Edge {
  int from, to;
  T weight;
};

template <typename T>
class Graph {
 public:
  Graph(int n) : edges_(n) {}
  void AddEdge(int from, int to, T weight = T()) {
    edges_[from].push_back({from, to, weight});
  }
  const std::vector<Edge<T>>& Edges(int from) const { return edges_[from]; }
  int NumVertices() const { return edges_.size(); }

 private:
  std::vector<std::vector<Edge<T>>> edges_;
};

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(ll, n);
  Graph<ll> g(n);
  rep(i, n - 1) {
    rd(ll, u, v, w);
    --u, --v;
    g.AddEdge(u, v, w);
    g.AddEdge(v, u, w);
  }
  vector<ll> color(n, -1);
  function<void(ll, ll, ll)> dfs = [&](ll node, ll parent, ll dist) {
    color[node] = dist % 2;
    for (const auto& e : g.Edges(node)) {
      if (e.to == parent) continue;
      if (color[e.to] != -1) continue;
      dfs(e.to, node, dist + e.weight);
    }
  };
  dfs(0, -1, 0);
  rep(i, n) wt(color[i]);
}


Measured memory_bytes: 15684
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        a: usize, b: usize, c: usize
    }
    let mut v = vec![a, b, c];
    v.sort();

    println!("{}", if v[0] + v[1] == v[2] { "Yes" } else { "No" });
}

Measured memory_bytes: 4352
#include<cstdio>
#include<cstdlib>
int main(void){
	int N,A,B;
	scanf("%d%d%d",&N,&A,&B);
	if(A + B - 1> N || (long)A*(long)B < (long)N){
		printf("%d\n",-1);
		fflush(stdout);
		return 0;
	}
	if(A > B){
		int i = 0,j=0;    
	    for(i=N - A + 1;i<=N;i++){
	        printf("%d ",i);
	    }
	    j = N-A+1;
	    int k;
	    if(B > 1){
	    	for(k=0; k < (N-A)%(B-1);k++){ 
				for(i=j - (N-A)/(B-1)-1;i< j;i++){
					printf("%d ",i);
				}
				j = j - (N-A)/(B-1)-1;
			}
			for(k=0; k < B-1 - (N-A)%(B-1);k++){ 
				for(i=j  - (N-A)/(B-1);i< j;i++){
					printf("%d ",i);
				}
				j = j - (N-A)/(B-1);
			}
			
		}
	}else{
		int i = 0,j=0;    
	    for(i=B;i>0;i--){
	        printf("%d ",i);
	    }
	    j = B;
	    int k;
	    if(A > 1){
			for(k=0; k < (N-B)%(A-1);k++){  
				for(i=j + (N-B)/(A-1) + 1;i > j;i--){
					printf("%d ",i);
				}
				j = j + (N-B)/(A-1) + 1;	
			}
			for(k=0; k < A-1 - (N-B)%(A-1);k++){  
				for(i=j + (N-B)/(A-1);i > j;i--){
					printf("%d ",i);
				}
				j = j + (N-B)/(A-1);	
			}

		}
	}
	
	printf("\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2048
def resolve():
    n, w = map(int, input().split())
    ws, vs = [0]*n, [0]*n
    for i in range(n):
        ws[i], vs[i] = map(int, input().split())
    dp = [[0]*(w+1) for _ in range(n+1)]
    for i in range(n):
        for j in range(w+1):
            if j >= ws[i]:
                dp[i][j] = max(dp[i][j], dp[i-1][j - ws[i]] + vs[i])
            dp[i][j] = max(dp[i][j], dp[i-1][j] if i - 1 >= 0 else 0)
    print(dp[n-1][w])
resolve()

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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a > b+c) cout << 0 << endl;
  else cout << b+c-a << endl;
}


/*





















*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>

enum State {
	A, BC, Other
};
std::vector<State> to_state(const std::string& str) {
	std::vector<State> result;
	for (auto i = 0; i < str.size(); ++i) {
		if (str[i] == 'A') {
			result.push_back(State::A);
		}
		else if (str[i] == 'B' && i + 1 < str.size() && str[i + 1] == 'C') {
			result.push_back(State::BC);
			++i;
		}
		else {
			result.push_back(State::Other);
		}
	}
	return result;
}
int main() {
	std::string s; std::cin >> s;
	auto state = to_state(s);
	int count = 0;
	long long int result = 0;
	for (int i = state.size() - 1; i >= 0; --i) {
		switch (state[i]) {
		case State::A:
			result += count;
			break;
		case State::BC:
			count += 1;
			break;
		case State::Other:
			count = 0;
			break;
		default:
			break;
		}
	}
	std::cout << result << std::endl;
}

Measured memory_bytes: 1532
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	ll N;
	cin >> N;
	string str = "";
	string ABC = "zabcdefghijklmnopqrstuvwxy";
	while(N>0){
		str = ABC.substr(N%26, 1)+str;
		if(N%26 == 0){
			N-=26;
		}
		N/=26;
	}
	cout << str << endl;
}


Measured memory_bytes: 3580
h,w = gets.split.map(&:to_i)
s = h.times.map{"."+gets.chomp+"."}.unshift("."*(w+2)).push("."*(w+2))
d = [1,0,-1,0]
ans = true
for i in 1..h
    for j in 1..w
        if s[i][j] == "#"
            ok = false
            for k in 0..3
                ok = true if s[i+d[k]][j+d[k^1]] == "#"
            end
            ans = false if !ok
        end
    end
end
puts ans ? "Yes" : "No"

Measured memory_bytes: 1788
X=int(input())
A = []
a=0
while a**5 - (a-1)**5 < 10.0**9:
    A.append(a**5)
    a+=1

for i, a_5 in enumerate(A):
    for j, b_5 in enumerate(A[i+1:]):
        if b_5 - a_5 == X:
            print(str(i+j+1) + ' ' + str(i))
            exit()
        elif b_5 + a_5 == X:
            print(str(i+j+1) +' ' + str((-1)*i))
            exit()
            

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> ab (m);
    for(int i=0; i<n; i++){
        int a,b;
        cin >> a >> b;
        if(a > m) continue;
        ab.at(m-a).push_back(b);
    }
    ll ans = 0;
    priority_queue<int> pq;
    for(int i=m-1; i>=0; i--){
        for(int x : ab.at(i)){
            pq.push(x);
        }
        if(!pq.empty()){
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5504
#include<iostream>
#include<map>
#include<set>
#include<string>
using namespace std;
#define mp make_pair

int main(){
  map<string, set<int> > index;
  string name;
  int num;
  while(cin>>name>>num){
    index[name].insert(num);
  }
  map<string, set<int> >::iterator it = index.begin();
  while(it != index.end()){
    cout<<(*it).first<<endl;
    set<int>::iterator it0 = (*it).second.begin();
    while(true){
      cout<<*it0;
      it0++;
      if(it0 != (*it).second.end()){
	cout<<" ";
      }
      else
	break;
    }
    cout<<endl;
    it++;
  }
  return 0;
}

Measured memory_bytes: 0
import itertools

N, K = (int(i) for i in input().split())  
heights = [int(input()) for i in range(N)] 

heights.sort()
min_diff = max(heights) - min(heights) 
for i in range(N-K+1):
    diff = heights[i+K-1] - heights[i]
    if diff < min_diff:
        min_diff = diff

print(min_diff)


Measured memory_bytes: 7532
#include<iostream>
#include<queue>
#include<vector>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
using namespace std;

int gcd(int a,int b){
    int tmp;
    int r;
    int ans=0;
    if(a<b){
        tmp=a;
        a = b;
        b = tmp;
    }
    r =a%b;
    while(r!=0){
        a = b;
        b =r;
        r = a %b;
    }
     ans=b;
     return ans;
} 
int main(){
    int k,i,j,l;
    int a,b,c;
    int ans=0;
    cin >> k ;
    //cin >> a >> b  >> c;
    for ( i=1;i<=k;i++){
        for( j=1;j<=k;j++){
            for(l=1;l<=k;l++){
                a = gcd(i,j);
                b = gcd(a,l);
                ans += b;
            }
        }
    }
    cout << ans <<endl;
    return 0;
}
     

Measured memory_bytes: 3636
import math

N, D = map(int, input().split())

X = []
for i in range(N):
    X.append(list(map(int, input().split())))


def dist(p1, p2, D):
    sum = 0
    for i in range(D):
        sum += (p1[i] - p2[i]) ** 2
    return math.sqrt(sum)


cnt = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        d = dist(X[i], X[j], D)
        if d.is_integer():
            cnt += 1
print(cnt)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) {
    cout << c << endl;
  }
  else if (b == c) {
    cout << a << endl;
  }
  else {
    cout << b << endl;
  }
  return 0;
}

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

int main() {
    int k; cin >> k;
    queue<int64_t> q;
    for (int i = 1; i <= 9; i++) {
        q.push(i);
    }
    int64_t x;
    for (int i = 0; i < k; i++) {
        x = q.front();
        if (x % 10 == 0) {
            q.push(x * 10);
            q.push(x * 10 + 1);
        }
        else if (x % 10 == 9) {
            q.push(x * 10 + 8);
            q.push(x * 10 + 9);
        }
        else {
            q.push(x * 10 + x % 10 - 1);
            q.push(x * 10 + x % 10);
            q.push(x * 10 + x % 10 + 1);
        }
        q.pop();
    }
    cout << x << endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;

main(){
	int W,H,x,y,r;
	
	cin>>W>>H>>x>>y>>r;
	
	if(x-r<0 || x-r>W || x+r>W || x+r<0 || y-r<0 ||y+r>H || y+r>H || y+r<0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 1160
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def func(x,btm,top):
  while btm < top:
    ctr = btm + (top-btm)//2 #中央値の添え字
    if x == S[ctr]:
      return 1
    elif x < S[ctr]:
      top = ctr
    elif x > S[ctr]:
      btm = ctr + 1
  return 0

C = 0
btm = 0
top = n
for i in T:
  C += func(i,btm,top)

print(C)


Measured memory_bytes: 16716
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i+)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vllvll = vector<vll>;
using vs = vector<string>;
ll sm(vll x) {ll sum=0; rep(i, x.size()) sum+=x[i]; return sum;}
void vdeb(string s, vll x) {cout<<s<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<endl;}

//=======================================================================================================

int main()
{
    ll n;
    cin >> n;
    vll h(n);
    vll ho(n);
    rep(i,n) {
        cin >> h[i];
        ho[i] = h[i];
    }
    srt(ho);

    int flag = 0;
    rep(i,n) {
        if(h[i]-ho[i] >= 2) flag = 1;
    }

    cout << (flag?"No":"Yes") << endl;
    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(x int) int {
	if x < 0 {
		return -1 * x
	}
	return x
}

func main() {
	sc.Split(bufio.ScanWords)

	s := next()
	ans := 753

	for i := 0; i < len(s)-2; i++ {
		x, e := strconv.Atoi(s[i:i+3])
		if e != nil {
			panic(e)
		}
		if ans > abs(x-753) {
			ans = abs(x-753)
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	string s;
    cin>>s;
    int ans=0;
    REP(i,SZ(s)/2){
        if(s[i]!=s[SZ(s)-1-i]) ans++;
    }
    OUT(ans);
	return 0;
}


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

bool solve(int n) {
  for (int a = 1; a < 10; ++a) {
    for (int b = 1; b < 10; ++b) {
		if (a * b == n) return true;
    }
  }
  return false;
}

int main() {
  int N; cin >> N;
  if (solve(N)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
ans=0
count=0
for i in range(1,n):
    if x[i-1]>=x[i]:
        count+=1
        if i==n-1:
            if count>ans:
                ans=count
    else:
        if count>ans:
            ans=count
            count=0
            continue
        else:
            count=0
            continue
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
int main(){
    int a,b,m;
    cin >> a >> b >> m;
//    int a_kin[a],b_kin[b];
    vector<int> a_kin(a),b_kin(b);
//    int len = (a*b) + m;
    int len =   1+m;
//    int ans_kin[len];
    vector<int> ans_kin(len);
    int di[m][3];
//    vector<int> di(m,3);
    rep(i,a){
        cin >> a_kin[i];
    }
    rep(i,b){
        cin >> b_kin[i];
    }
    rep(i,m){
        rep(j,3){
            cin >> di[i][j];
        }
    }    
/*
    cout << a << " " << b << " " << m << endl;
    rep(i,a){
        cout << a_kin[i] << " ";
    }
    cout << endl;
    rep(i,b){
        cout << b_kin[i] << " ";
    }
    cout << endl;
    rep(i,m){
        rep(j,3){
            cout << di[i][j] << " ";
        }
        cout << endl;
    }
*/
  	ans_kin[0] = *min_element(a_kin.begin(), a_kin.end()) + *min_element(b_kin.begin(), b_kin.end());
    int num = 1;
/*  
    rep(i,a){
        rep(j,b){
            ans_kin[num] = a_kin[i] + b_kin[j];
            num += 1;
        }
    }
*/    
    rep(i,m){
        ans_kin[num] = a_kin[di[i][0] -1] + b_kin[di[i][1] -1] - di[i][2];
        num += 1;
    }

/*
    cout << num << endl;
    rep(i,ans_kin.size()){
        cout << ans_kin[i] <<" ";
    }
    cout << endl;
*/
//  	sort(ans_kin, ans_kin + GET_ARRAY_SIZE(ans_kin));
    sort(ans_kin.begin(),ans_kin.end());
    cout << ans_kin[0] << endl;
 
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;

vll seen;
void dfs(vvll& graph, ll i){
	seen.at(i) = 1;
	vrep(j, graph.at(i)) if(seen.at(j) == 0) dfs(graph, j);
}

int main(){
	ll n, m;
	cin >> n >> m;
	map<ll, ll> score;
	rep(i, 0, n){
		ll a;
		cin >> a;
		score[a] += 1; // 後で見直す
	}
	rep(i, 0, m){
		ll b, c;
		cin >> b >> c;
		score[c] += b;
	}

	vll value;
	vrep(i, score) value.push_back(i.first);
	reverse(all(value));
	ll count = 0, ans = 0;
	vrep(i, value){
		if(n - count <= score[i]){
			ans += i * (n - count);
			break;
		}
		ans += i * score[i];
		count += score[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 14964
#coding: utf-8
N, M = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
diff = [abs(x[i] - x[i+1]) for i in range(M-1)]
diff.sort()
ans = 0
print(ans if N > M else ans + sum(diff[:M-N]))

Measured memory_bytes: 13960
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

//変数
ll N, M;
vector<int> vec(5);
ll k;

//解法
void solve() {

	ll tmp = 0;
	vector<int> t(5);
	rep(i, 5) {
		t[i] = (10 - vec[i] % 10)%10;
	}
	ll ans = 0;
	rep(i, 5) {
		ans += vec[i] + t[i];
	}
	ans -= MAX(t);

	cout << ans;

	return;
}

int main() {

	//入力
	rep(i, 5) cin >> vec[i];

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(n: int, m: int, x: "List[int]", y: "List[int]"):
    X = 0
    for k in range(1,n+1):
        X += (k-1)*x[k-1]-(n-k)*x[k-1]
        X %= MOD
    Y = 0
    for k in range(1,m+1):
        Y += (k-1)*y[k-1]-(m-k)*y[k-1]
        Y %= MOD
    print(X*Y%MOD)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    m = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    y = [int(next(tokens)) for _ in range(m)]  # type: "List[int]"
    solve(n, m, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20076
n = int(input())
p = {}
for i in range(2, n + 1):
    j = i
    for d in range(2, j + 1):
        while j % d == 0:
            p[d] = p.get(d, 0) + 1
            j //= d

def doit(ds, ps):
    if ds == []:
        return 1
    if ps == []:
        return 0
    ret = doit(ds, ps[1:])
    if ps[0] + 1 >= ds[0]:
        ret += doit(ds[1:], ps[1:])
    return ret

ret = 0
for ds in ([3, 5, 5], [5, 3, 5], [5, 5, 3], [5, 15], [15, 5], [3, 25], [25, 3], [75]):
    ret += doit(ds, list(p.values()))
print(ret)


Measured memory_bytes: 44140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#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()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    if (s[0] != s[1] || s[1] != s[2])cout << "Yes\n";
    else cout << "No\n";
}

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

int main() {
 string S;
  cin>>S;
  int X=0;
  for(int i=0; i<S.size(); i+=2){
    if(S.at(i)=='L')
      X++;
    else continue;
  }
  for(int i=1; i<S.size(); i+=2){
    if(S.at(i)=='R') X++;
    else continue;
  }
  if(X==0)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int gcd = gcd(a, b);

      for(int i = gcd; i >= 1; i--) {
        if(a % i == 0 && b % i == 0) {
          k--;
          if(k == 0) {
            System.out.println(i);
            return;
          }
        }
      }
  }

  private static int gcd(int a, int b) {
    if(b == 0)
      return a;
    return gcd(b, a % b);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
#include <queue>
#include <stack>
#include <vector>
#define loop(n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;

ll expo(ll a,ll b)
{
    ll result = 1;
    ll hold = a;
    while (b >= 1)
    {
        if(b%2 != 0)
        {
            result *= a;
        }
        b /= 2;
        a *= a;
    }
    return result;
}

int main()
{
    fastio;
    string a;
    string b;
    cin>>a;
    cin>>b;
    ll len = a.size();
    ll ans = 0;
    for(ll i =0;i<len;i++)
    {
        if(a[i] != b[i])
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define repd(i,a,b) for (int i=(a);i<(b);i++)
typedef long long ll;
using namespace std;

int main() {
    int n,k;cin>>n>>k;
    int h[n];
    rep(i,n)cin>>h[i];
    int num=0;
    rep(i,n){
        if(h[i]>=k)num++;
    }
    cout<<num<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
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;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) {
            os << ',';
        }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    int N, K;
    cin >> N >> K;
    vector<pair<ll, ll>> v(N);
    for(int i = 0; i < N; i++) {
        cin >> v[i].second >> v[i].first;
    }
    sort(RALL(v));
    set<int> se;
    ll o = 0;
    priority_queue<ll, vector<ll>, greater<ll>> que;
    for(int i = 0; i < K; i++) {
        o += v[i].first;
        if(se.count(v[i].second)) {
            que.push(v[i].first);
        } else {
            se.insert(v[i].second);
        }
    }
    ll ans = o + (ll)se.size() * (ll)se.size();
    for(int i = K; i < N; i++) {
        if(se.count(v[i].second)) {
            continue;
        }
        if(que.empty()) {
            break;
        }
        o -= que.top();
        que.pop();
        o += v[i].first;
        se.insert(v[i].second);
        chmax(ans, o + (ll)se.size() * (ll)se.size());
    }
    cout << ans << endl;
}

Measured memory_bytes: 8104