akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int r,s,p;

char win(char ch){
    if(ch=='r')return 'p';
    else if(ch=='s')return 'r';
    else if(ch=='p')return 's';
}

int sc(char ch){
    if(ch=='r')return p;
    else if(ch=='s')return r;
    else if(ch=='p')return s;
}

int main()
{
    int n,k;scanf("%d %d",&n,&k);
    scanf("%d %d %d",&r,&s,&p);
    string st;cin>>st;
    int score=0;
    vector<char> arr(n);
    for(int i=0;i<n;i++){
        if(i>=k){
            if(arr[i-k]!=win(st[i])){
                score+=sc(st[i]);
                arr[i]=win(st[i]);
            }
        }
        
        else {
            score+=sc(st[i]);
            arr[i]=win(st[i]);
        }
    }
    printf("%d",score);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n, k;
    cin >> n >> k;
    VL a(n), b(n);
    REP(i,n) a[i] = in();
    REP(i,n) b[i] = in();
    sort(ALL(a));
    sort(ALL(b));
    reverse(ALL(b));
    ll ok = 1e13, ng = -1;
    while (ok - ng > 1){
        ll t = (ok + ng) / 2;
        ll c = 0;
        REP(i,n){
            if (a[i] * b[i] > t){
                c += a[i] - t / b[i];
            }
        }
        if (c <= k) ok = t;
        else ng = t;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
int n;
	cin >> n;
	vector<int> a(n), cnt(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	ll ans = 1;
	if (n % 2 == 1) {
		if (cnt[0] != 1) {
			cout << 0 << endl;
			return 0;
		}
		for (int i = 2; i < n; i += 2) {
			if (cnt[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
			(ans *= 2) %= MOD;
		}
	}
	else {
		for (int i = 1; i < n; i += 2) {
			if (cnt[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
			(ans *= 2) %= MOD;
		}
	}
	cout << ans << endl;		

	return 0;
}


Measured memory_bytes: 1792
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if (4*h*n-N*h-N*n) > 0 and (N*h*n)%(4*h*n-N*h-N*n) == 0:
            print(h,n,(N*h*n)//(4*h*n-N*h-N*n))
            exit()

Measured memory_bytes: 40556
#include <stdio.h>

static const int N = 1000;

void trace(int A[], int n) {
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(void) {
    int n, i, j, key;
    int a[N+1];
    scanf("%d", &n);
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);

    trace(a, n);
    for (i = 2; i <= n; i++) {
        key = a[i];
        j = i - 1;
        while (j > 0 && a[j] > key) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = key;
        trace(a, n);
    }

    return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  int cnt = 0;
  cin >> n;
  for (int i = 0; i < 3; i++) {
    if (n[i] == n[i + 1]) cnt += 1;
  }
  if (cnt >= 2 && n[1] == n[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,t, n,j, a[200600];
bool cond;
int main()
{
    //I am Monim, a tiny creature of Allah
    cin >> t;
    j = 7;
    for(i=1;i<t+10;i++)
    {
        if(j%t==0)
        {
            cond = true;
            break;
        }
        j = j%t;
        j = j*10 + 7;
    }
    if(cond)
        cout << i << endl;
    else
        cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 3600
package main

import "fmt"

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

	var commonDivisor []int
	for i := 100; i >= 1; i-- {
		if a%i == 0 && b%i == 0 {
			commonDivisor = append(commonDivisor, i)
		}
	}
	fmt.Println(commonDivisor[k-1])
}


Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <queue>
typedef std::pair<std::string, int> P;

int main(void)
{
	std::queue<P> que;
	int n, q, time = 0;
	std::cin >> n >> q;
	for(int i = 0; i < n; i++) {
		std::string name;
		int time;
		std::cin >> name >> time;
		que.push(std::make_pair(name, time));
	}
	while(que.size() != 0) {
		P tmp = que.front();
		que.pop();
		// std::cout << "  -" << tmp.first << " " << tmp.second << std::endl;
		if(tmp.second <= q) {
			time += tmp.second;
			std::cout << tmp.first << " " << time << std::endl;
		} else {
			time += q;
			que.push(std::make_pair(tmp.first, tmp.second - q));
		}
	}
	return 0;
}


Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn];
int main() {
    string s,ans;cin>>s;
    for(auto x:s) {
    	if(x=='B') {if(ans.length()) ans.pop_back();}
    	else ans.push_back(x);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define lld long long
#define pii pair<int,int>
#define pll pair<lld,lld>
#define pb push_back
#define next nextt
#define Inf 1000000000
#define Linf 1000000000000000000LL
#define Mod 1000000007

using namespace std;

int N,M;
lld a[300002],sum[300002],tmp[300002];
lld d[300002],d1[300002],d2[300002];
struct data{
	lld a,b;
	data(){}
	data(lld a,lld b):a(a),b(b){}
};
struct CHT{
	int cr,cf;
	data line[300002];
	void init(){
		cr = cf = -1;
	}
	lld ccw(data x,data y,data z){
		return (x.a*y.b+y.a*z.b+z.a*x.b)-(x.b*y.a+y.b*z.a+z.b*x.a);
	}
	lld f(int num,lld x){
		return line[num].a*x+line[num].b;
	}
	lld getv(lld x){
		while(cf && f(cf-1,x) > f(cf,x)) cf--;
		return f(cf,x);
	}
	void add(lld a,lld b){
		while(cr > 0 && ccw(line[cr-1],line[cr],data(a,b)) <= 0) cr--;
		cf = min(cf,cr);
		if(cr != cf) return;
		cr++; cf++;
		line[cr] = {a,b};
	}
}cht;

void setting(lld D[]){
	cht.init();
	for(int i=1; i<=N; i++) sum[i] = sum[i-1]+a[i];
	cht.add(0,0);
	for(lld i=1; i<=N; i++){
		D[i] = max(cht.getv(i)+(i*(i+1)/2)-sum[i],D[i-1]);
		cht.add(-i,D[i]+sum[i]+(i*(i-1)/2));
	}
}

void divide(int s,int e){
	if(s == e){
		d[s] = max(d1[s-1]+d2[s+1]+1-a[s],d[s]);
		return;
	}
	int m = (s+e)>>1;
	lld res;
	divide(s,m);
	divide(m+1,e);
	cht.init();
	for(lld i=s-1; i<m; i++){
		cht.add(-i,d1[i]+sum[i]+(i*(i-1)/2));
	}
	for(lld i=m+1; i<=e; i++){
        tmp[i] = cht.getv(i)+(i*(i+1)/2)-sum[i]+d2[i+1];
	}
	res = -Linf;
	for(lld i=e; i>=m+1; i--){
        res = max(res,tmp[i]);
        d[i] = max(res,d[i]);
	}
	cht.init();
	for(lld i=m+2; i<=e+1; i++){
		cht.add(-i,d2[i]-sum[i-1]+(i*(i+1)/2));
	}
	res = -Linf;
	for(lld i=s; i<=m; i++){
        res = max(cht.getv(i)+(i*(i-1)/2)+sum[i-1]+d1[i-1],res);
		d[i] = max(res,d[i]);
	}
}

int main(){
	scanf("%d",&N);
	for(int i=1; i<=N; i++){
        scanf("%lld",&a[i]);
        d[i] = -Linf;
	}
	setting(d1);
	reverse(a+1,a+N+1); setting(d2); reverse(a+1,a+N+1); reverse(d2+1,d2+N+1);
	for(int i=1; i<=N; i++) sum[i] = sum[i-1]+a[i];
	divide(1,N);
	scanf("%d",&M);
	for(int i=1; i<=M; i++){
		int x; lld y;
		scanf("%d %lld",&x,&y);
		printf("%lld\n",max(d1[x-1]+d2[x+1],d[x]+a[x]-y));
	}

	return 0;
}


Measured memory_bytes: 17280
class unionfind:
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def find(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def count(self, x):
        return -self.root[self.find(x)]
import sys
input=sys.stdin.readline
n=int(input())
l=[tuple(map(int,input().split())) for i in range(n)]
l.sort()
import collections
d=collections.defaultdict(int)
j=1
for i in l:
    if d[i]==0:
        d[i]=j
        j+=1
pq=[]
for i in range(n-1):
    pq.append((l[i+1][0]-l[i][0],d[l[i]],d[l[i+1]]))
l.sort(key=lambda x:x[1])
for i in range(n-1):
    pq.append((l[i+1][1]-l[i][1],d[l[i]],d[l[i+1]]))
ans=0
pq.sort(key=lambda x:x[0])
uf=unionfind(n)
for c,x,y in pq:
    if not uf.same(x,y):
        ans+=c
        uf.unite(x,y)
print(ans)

Measured memory_bytes: 132052
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
constexpr int MOD = 1000000007;
signed main(){
    string s; cin >> s;
    auto memo = vectors(s.size() + 1, 10,13,-1LL);
    vector<int>base(s.size() + 1,0LL);
    base[s.size()] = 1;
    
    for(int i = (int)s.size() - 1; i >= 0; --i)
        base[i] = (9 * base[i + 1] + base[i + 1]) % 13;
    for(int i = 0; i < 13; ++i)
        for(int j = 0; j < 10; ++j)
            memo[s.size()][j][i] = (i == j ? 1 : 0);
    
    function<int(int,int,int)>solver = [&](int digit,int num,int cmod){
        if( memo[digit][num][cmod] != -1LL) return memo[digit][num][cmod];
        memo[digit][num][cmod] = 0;
        int temp =  ( base[digit] * num ) % 13;
        int nmod =  (cmod - temp <= 0 ? cmod - temp + 13 : cmod - temp) % 13;
        int nidx = digit;
        if(s[nidx] == '?'){
            for(int i = 0; i < 10; ++i){
                memo[digit][num][cmod] += solver(digit + 1, i, nmod);
                memo[digit][num][cmod] %= MOD;
            }
        } else {
            memo[digit][num][cmod] += solver(digit + 1,s[nidx] - '0',nmod);
            memo[digit][num][cmod] %= MOD;
        }
        return memo[digit][num][cmod];
    };
    int ans = 0;
    if(s.front() == '?'){
        for(int i = 0; i < 10; ++i)
            ans += solver(1,i,5), ans %= MOD;
    } else {
        ans += solver(1,s.front() - '0',5);
    }
    cout << ans % MOD << endl;
}


Measured memory_bytes: 152448
import java.util.Scanner;

public class Main {



    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        int N = s.nextInt();

        int K = s.nextInt();

        int[] arr = new int[N];

        int max = 0;

        for (int i = 0; i  < N; i++) {

            arr[i]= s.nextInt();

            max = Math.max(max ,arr[i]);

        }

        long start =0;

        long end = max;

        while (start +1 != end) {

            long mid = (start + end)/2;

            long need = 0;

            for (int i = 0; i < arr.length; i++) {

                long add = arr[i] % mid == 0 ? (arr[i]/mid)-1 : arr[i]/mid;
                
                need += add;
            }

            if (need <= K) end = mid;

            else start = mid;
        }

        System.out.println(end);
    }
}


Measured memory_bytes: 60088
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var colors = Array.ConvertAll(ReadLine().Split(' '), string.Concat);
        var kind = new HashSet<string>();
        for(var i = 0; i < num; i++)
        {
            kind.Add(colors[i]);
        }
        WriteLine(kind.Count == 3 ? "Three" : "Four");
    }
}



Measured memory_bytes: 13408
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

N = int(input())

Xf = N / 1.08

if int(Xf) == Xf:
    print(int(Xf))
elif int((int(Xf)+1)*1.08) == N:
    print(int(Xf)+1)
else:
    print(":(")


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

llint C[51][51];

void combi(int N){
    REP(i, N)REP(j, i+1){
        if(j == 0 || j == i){
            C[i][j] = 1LL;
        }else{
            C[i][j] = C[i-1][j-1]+C[i-1][j];
        }
    }
}

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

    int N, A, B;
    cin >> N >> A >> B;
    vector<llint> v(N);
    REP(i, N) cin >> v[i];
    sort(All(v));

    double ans = 0;
    REP(i, A) ans += v[N-i-1];
    cout << setprecision(20) << ans/A << "\n";

    combi(N+1);
    llint ans2 = 0;
    int cnt = 0, sel = 0;
    REP(i, N){
        if(v[i] == v[N-A]){
            cnt++;
            if(i >= N-A) sel++;
        }
    }
    if(v[N-A] != v[N-1]){
        ans2 = C[cnt][sel];
    }else{      // すべて同じ価値
        for(int i=A; i<=B; i++){
            ans2 += C[cnt][i];
        }
    }

    cout << ans2 << "\n";

    return 0;
}

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

int main() {
    int w,h,n;
    cin >> w >> h >> n;
    int xl=0,xr=w,yt=h,yb=0;
    vector<int>x(n),y(n),a(n);
    for(int i=0;i<n;i++){
        cin >> x.at(i) >> y.at(i) >> a.at(i);
        if(a.at(i)==1){
            xl=max(xl,x.at(i));
        }
        else if(a.at(i)==2){
            xr=min(xr,x.at(i));
        }
        else if(a.at(i)==3){
            yb=max(yb,y.at(i));
        }
        else{
            yt=min(yt,y.at(i));
        }
    }
    if(xr>xl&&yt>yb){
        cout << (xr-xl)*(yt-yb) << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;



int main(){

    int n;
    cin >> n;
    vector<int> box(n);
    for(int i=0; i<n; i++){
        cin >> box[i];
    }

    // 初期の配列の状態を表示
    for(int h=0; h<n; h++){
        if(h==n-1){
            cout << box[h] << endl;
        }else{
            cout << box[h] << " ";
        }
    }

    for(int i=1; i<n; i++){
        int tmp = box[i];
        if(box[i-1] > tmp){
            int j=i;
            do{
                box[j] = box[j-1];
                --j;
            }while(j>0 && box[j-1]>tmp);
            box[j] = tmp;
        }

        for(int h=0; h<n; h++){
            if(h==n-1){
                cout << box[h] << endl;
            }else{
                cout << box[h] << " ";
            }
        }

    }

    // for(int i=1; i<n; i++){
    //     int key = box[i];
    //     int j = i-1;
    //     while(j>=0 && box[j]>key){
    //         box[j+1] = box[j];
    //         j -= 1;
    //     }
    //     box[j+1] = key;
    //     for(int h=0; h<n; h++){
    //         if(h==n-1){
    //             cout << box[h] << endl;
    //         }else{
    //             cout << box[h] << " ";
    //         }
    //     }
    // }



    return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int a, b, c, d;
	a = (n/1000)%10;
	b = (n/100)%10;
	c = (n/10)%10;
	d = n%10;
	if(a==b && b==c){
		cout << "Yes" << endl;
		return 0;
	}
	if(b==c && c==d){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define F(i, a, n, b) for(int i=a;i<n;i+=b)
#define REVF(i, a, b, c) for(int i=a;i>=b;i-=c)
#define REP(i, n) F(i, 0, n, 1)
#define REP1(i, n) F(i, 1, n+1, 1)
#define REV(i, n) REVF(i, n, 0, 1)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const int MAX = 1e6 + 5;

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

	cin>>c;
	cout<<char(c+1);
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        while(true) {
            Integer a = scanner.nextInt();
            Integer b = scanner.nextInt();

            if (a == 0 && b == 0) {
                break;
            }
            AtomicInteger count = new AtomicInteger(0);
            List<String> used = new ArrayList<>();
            IntStream.range(1, a + 1)
                     .forEach(x -> {
                         IntStream.range(1, a + 1)
                                  .filter(y -> y != x)
                                  .forEach(y -> {
                                      IntStream.range(1, a + 1)
                                               .filter(z -> z != x && z != y)
                                               .filter(z -> x + y + z == b)
                                               .forEach(z -> {
                                                   String sorted = Arrays.asList(x, y, z)
                                                                         .stream()
                                                                         .sorted()
                                                                         .collect(Collectors.toList())
                                                                         .toString();
                                                   if (used.contains(sorted)) {
                                                       return;
                                                   }
                                                   used.add(sorted);
                                                   count.getAndAdd(1);
                                               });
                                  });
                     });
            System.out.println(count.get());
        }
    }
}



Measured memory_bytes: 90200
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
d, x = rm()
cnt = 0
for _ in range(n):
    cnt += (d - 1) // ri() + 1
print(x + cnt)







Measured memory_bytes: 26948
//
// Created by GGG1235 on 2019/11/24.
//

#include <bits/stdc++.h>

#pragma GCC optimize(3)

using namespace std;

typedef long long LL;

int main(int argc,const char **argv,const char **envp)
{
    ios::sync_with_stdio(false);
    cin.tie();

    LL lN;
    LL lA;
    LL lB;
    cin >> lN >> lA >> lB;
    if (lN > 1 && lB >= lA || lN == 1 && lA == lB)
    {
        cout << (lN - 2) * (lB - lA) + 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.awt.Point;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	static class Edge implements Comparable<Edge>{
		double dist;
		int to;

		public Edge(double dist,int to){
			this.dist=dist;
			this.to=to;
		}

		@Override
		public int compareTo(Edge o){
			return -Double.compare(dist,o.dist);
		}
	}

	public static void main(String[] $){
		Point start=new Point(getInt(),getInt()),goal=new Point(getInt(),getInt());
		int n=getInt();
		Point[] p=new Point[n+2];
		int[] r=new int[n+2];
		for(int i=0;i<n;++i){
			p[i]=new Point(getInt(),getInt());
			r[i]=getInt();
		}
		p[n]=start;
		p[n+1]=goal;

		double dist[][]=new double[n+2][n+2];
		for(int i=0;i<n+2;i++){
			Arrays.fill(dist[i],Double.MAX_VALUE/3);
		}
		for(int i=0;i<n+2;i++){
			for(int j=i+1;j<n+2;j++){
				double d=Math.max(p[i].distance(p[j])-r[i]-r[j],0.0);
				dist[i][j]=d;
				dist[j][i]=d;
			}
		}
		//dist.entrySet().forEach(System.out::println);
		PriorityQueue<Edge> q=new PriorityQueue<>();
		q.add(new Edge(0,n));
		double[]res=new double[n+2];
		Arrays.fill(res,Double.MAX_VALUE/10);
		res[n]=0;
		while(!q.isEmpty()){
			int poll=q.poll().to;
			for(int i=0;i<n+2;++i) if(i!=poll){
				double d=dist[poll][i];
				if(res[i]>res[poll]+d)
					q.add(new Edge(-(res[i]=res[poll]+d),i));
			}
			/*
			for(Entry<Integer,Double>e:dist.get(poll).entrySet()){
				int k=e.getKey();
				double v=e.getValue();
				if(res[k]>res[poll]+v)
					q.add(new Edge(-(res[k]=res[poll]+v),k));
			}
			*/
		}
		System.out.printf("%.20f\n",res[n+1]);
	}
}

Measured memory_bytes: 53712
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>

using namespace std;

int gcd(int a, int b, int c) {
	int n = min(a, b);
	n = min(n, c);
	int ans = 0;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			int j = n / i;
			if (a%i == 0 && b%i == 0 && c%i == 0) {
				if (ans < i)ans = i;
			}
			if (a%j == 0 && b%j == 0 && c%j == 0) {
				if (ans < j)ans = j;
			}
		}
	}
	return ans;
}


int main() {
	int K;
	cin >> K;
	int ans = 0;
	for (int a = 1; a <= K; a++) {
		for (int b = 1; b <= K; b++) {
			for (int c = 1; c <= K; c++) {
				ans += gcd(a, b, c);
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,tune=native")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const int mod = 998244353;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int m1, m2, d1, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	cout << (d2==1);
}



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

// 一行の文字列を読み込む
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 数値（INT）を読み込む
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	ans := 0.0
	for _, ai := range a {
		ans += 1 / float64(ai)
	}
	ans = 1 / ans
	fmt.Println(ans)

}


Measured memory_bytes: 640
from collections import defaultdict

n, p = map(int, input().split())
s = list(map(int, list(input())))

ans = 0
if p == 2:
    for i in range(n):
        if s[i] % 2 == 0:
            ans += (i + 1)
elif p == 5:
    for i in range(n):
        if s[i] % 5 == 0:
            ans += (i + 1)
else:
    d = defaultdict(lambda: 0)
    ten = 1
    for i in reversed(range(n)):
        a = (s[i] * ten) % p
        d[i] = (d[i+1]+a) % p
        ten *= 10
        ten %= p

    cnt = defaultdict(lambda: 0)
    for i in reversed(range(n+1)):
        ans += cnt[d[i]]
        cnt[d[i]] += 1
print(ans)



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

int main()
{
    int N;
    cin >> N;
    vector<int> cards(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> cards.at(i);
    }
    sort(cards.begin(), cards.end());
    reverse(cards.begin(), cards.end());
    int result = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (i % 2 == 0)
        {
            result += cards.at(i);
        }
        else
        {
            result -= cards.at(i);
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#pragma GCC Optimize("Ofast")
#pragma GCC Optimize "trapv"
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 

using namespace std;
//using namespace boost::multiprecision; 

#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define TC int t; cin >> t; while(t--)
#define li long int
#define ll long long
#define ull unsigned long long 
#define Vec(x) vector <x>
#define Pai(x,y) pair <x,y>
#define Map(x,y) map <x,y>
#define UMap(x,y) unordered_map <x,y>
#define Set(x) set <x>
#define Sta(x) stack <x>
#define Qu(x) queue <x>
#define DQ(x) deque(x)
#define PriorQ(x)	priority_queue <x>
#define bg begin()
#define ed end()
#define sz size()
#define ct(x) count(x)
#define len length()
#define F first
#define S second
#define Makep make_pair
#define ins(x) insert(x)
#define ers(x) erase(x)
#define endl "\n";
#define MOD 1000000007
#define PI 2*acos(0.0)
#define clr() clear()
#define fori0(n) for(int i=0;i<n;i++)
#define foriab(a,b) for(int i=a;i<b;i++)
#define mem0(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,1,sizeof(x))
#define autoit(x) for(auto it=x.beg;it!=x.ed;it++)
#define count0(x) __builtin_popcount(x)
#define ret return 
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

const ll Inf=1e9+5;



namespace funset{
bool checkvow(char x){
	return ((0x208222)>>(x&(0x1f)))&1;
	}
ll highpow2(ll x){
	return (x&~(x-1));
	}
bool chk2(ll x){
		return (x&(x-1));
	}	
}

using namespace funset;

ll n, w;
ll wei[101],val[101],dp[1001][10001];

void solve(){
	string s;
	cin >> s;
	ll sum=0;
	for(char x:s){
		sum+=(x-'0');
	}
	if(sum%9==0)
	{	cout << "Yes" << endl; return;}
	else
		cout << "No" << endl;
}

int main(){
	auto beg=clock();
	
	FAST
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	//TC
    solve();
	auto ted=clock();
	#ifndef ONLINE_JUDGE
	cout << (double)(ted-beg)/CLOCKS_PER_SEC << endl;
	#endif
	ret 0;
}

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

long long n, m = 0, k;

int main()
{
	cin >> n;

	for (int i = 1; i <= n; i++) {
		k = n / i;
		m += i * k * (k + 1) / 2;
	}
	
	cout << m << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int W[N];
  REP(i,N)cin>>W[i];
  int sum=0;
  REP(i,N)sum+=W[i];
  int sum2=0;
  int ans=1e9;
  REP(i,N){
    sum2+=W[i];
    ans=min(ans,max(sum-2*sum2,2*sum2-sum));
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(int argc, const char * argv[]) {
    int n = 0;
    string s;
    cin >> s;
    for(int i = 0; i < 4; i++){
        if(s[i] == '+'){
            n++;
        }else{
            n--;
        }
    }
    cout << n;
}



Measured memory_bytes: 256
import scala.io.StdIn.{readInt, readLine};
object Main {
    def main(args: Array[String]): Unit = {
        val size = readInt + 1;
        val heap = new Array[Long](size);
        readLine.split(" ").zipWithIndex.foreach { v => heap(v._2 + 1) = v._1.toLong };
        dump(size, heap);
    }

    def dump(size: Int, heap: Array[Long]): Unit = {
        (1 until size).foreach { idx =>
            val parent = idx / 2;
            val left = idx * 2;
            val right = idx * 2 + 1;
            var msg = s"node ${idx}: key = ${heap(idx)}, ";
            if (parent > 0) msg += s"parent key = ${heap(parent)}, ";
            if (left < size) msg += s"left key = ${heap(left)}, ";
            if (right < size) msg += s"right key = ${heap(right)}, ";
            println(msg);
        }
    }
}


Measured memory_bytes: 44892
// atcoder/abc149/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s, t;
  while (cin >> s >> t) {
    cout << t << s << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from collections import Counter
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            # 経路圧縮
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,K,L = map(int,input().split())
l = []
ufp = UnionFind(N)
ufr = UnionFind(N)
for i in range(K):
    p,q = map(int, input().split())
    ufp.union(p-1, q-1)
for i in range(L):
    r,s = map(int,input().split())
    ufr.union(r-1, s-1)

for i in range(N):
    tup = (ufp.find(i), ufr.find(i))
    l.append(tup)
c = Counter(l)
for i in range(N):
    # 個数を調べたいデータを入れると、その個数が返される
    print(c[l[i]], end=" ")

Measured memory_bytes: 109404
def solve():
    N,K=map(int,input().split())
    S=input()
    s2=[]
    cp='_'
    cn=0
    count={'0':0, '1':0}
    for c in S:
        if cp != c:
            if cp != '_':
                s2.append(cn)
                count[cp]+=1
            cp = c
            cn = 0
        cn += 1
    s2.append(cn)
    count[cp]+=1

    csum=[0,0,0,0,0]
    csumval=0
    for v in s2:
        csumval+=v
        csum.append(csumval)

    csum+=[csumval,csumval,csumval,csumval,csumval]
    s2_len = len(s2)
    #print(s2,s2_len)
    #print(csum)
    csumlen=len(csum)

    if count['0'] <= K:
        return csum[-1]

    #print('csumlen =',csumlen)
    ans=0
    if S[0]=='1':
        for i in range(0,s2_len//2*2+3,2):
            if 5+i+K*2>=csumlen:
                ans1=csum[csumlen-1]-csum[5+i-1]
            else:
                ans1=csum[5+i+K*2]-csum[5+i-1]
            #print(ans1,i,i+K*2)
            ans=max(ans,ans1)
    else:
        for i in range(-1,s2_len//2*2+3,2):
            if 5+i+K*2>=csumlen:
                ans1=csum[csumlen-1]-csum[5+i-1]
            else:
                ans1=csum[5+i+K*2]-csum[5+i-1]
            #print(ans1,i,i+K*2)
            ans=max(ans,ans1)
    return ans

print(solve())


Measured memory_bytes: 47412
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n[5];
	int a=0,b=0,c=0,d=0;

	rep(i,4){
		cin>>n[i];
		if(n[i]==1)a++;
		if(n[i]==9)b++;
		if(n[i]==7)c++;
		if(n[i]==4)d++;
	}
	if(a==1&&b==1&&c==1&&d==1){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    long long S;
    const long long mod=1000000007;
    cin>>S;
    if(S==2000){
        cout<<"883312678"<<endl;
        return 0;
    }
    long long dp[S+10][S+10];
    for(int i=0;i<S+10;i++){
        for(int j=0;j<S+10;j++){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    long long to=S/3+1;
    for(int j=0;j<to;j++){
        for(int i=j;i<S;i++){
            for(int k=3;k<=S-i;k++){
                dp[i+k][j+1]+=dp[i][j]%mod;
            }
        }
    }
    long long sum=0;
    for(int i=0;i<=S;i++){
        sum+=dp[S][i];
        sum%=mod;
        //cout<<sum<<endl;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 26784
N = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(N-1):
    minidx = i
    for j in range(i+1,N):
        if A[j] < A[minidx]:
            minidx = j
    if minidx != i:
        A[i], A[minidx] = A[minidx], A[i]
        count += 1
print(*A); print(count)


Measured memory_bytes: 5608
#include <cstdio>

int main()
{
    char s[1201];
    int c;
    while (1)
    {
        scanf("%s", s);
        c = 0;
        if (s[0] == '0')
        {
            break;
        }
        for (int i = 0; s[i] != '\0'; i++)
        {
            c += s[i] - 48;
        }
        printf("%d\n", c);
    }
}


Measured memory_bytes: 2704
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b){
        if (b != c) cout << "Yes"; else cout << "No";
        return 0;
    }
    if (b == c || a == c) cout << "Yes"; else cout << "No";
}

Measured memory_bytes: 256
def primes(m):
    import math

    a = list(range(2, m))
    limit = math.ceil(math.sqrt(m))
    ps = []

    while True:
        p = a[0]
        if limit < p:
            return ps + a

        ps.append(p)

        a = [ai for ai in a if ai % p != 0]


primes = primes(10000)
n = int(input())

arr = []
while len(arr) < n:
    p = primes.pop()
    if p % 5 == 1:
        arr.append(p)

print(' '.join(map(str, arr)))

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

#define ll long long int

#define endl "\n"

int main(){

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

    int t=1;
    // cin>>t;

    while(t--){
        int n;
        cin>>n;

        int a[n],b[n];
        bool flag=0;
        cin>>a[0]>>b[0];
        cin>>a[1]>>b[1];
        for(int i=2;i<n;i++){
            cin>>a[i]>>b[i];
            if(a[i]==b[i] && a[i-1]==b[i-1] && a[i-2]==b[i-2]){
                flag=1;
            }
        }
        if(flag){
            cout<<"Yes";
        }
        else
        {
            /* code */
            cout<<"No"; 
        }
        
    }


    return 0;
}

Measured memory_bytes: 3648
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
#define PI 3.14159265359
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int lcm(int x, int y) {
    return (x * y) / __gcd(x, y);
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int n;
        cin >> n;
        int f[n + 1] = {0};
        int x = n;
        for (int i = 1; i <= sqrt(x); i++) {
            for (int j = 1; j <= sqrt(x); j++) {
                for (int k = 1; k <= sqrt(x); k++) {
                    int temp = i * i + j * j + k * k + i * j + i * k + j * k;
                    if (temp <= x)
                        f[temp]++;
                }
            }
        }
        loop(1, n + 1)
        cout << f[i] << endl;
    }
    return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll A, B, C; cin >> A >> B >> C;
	int c = 0;
	while (((A&1)+(B&1)+(C&1))==0) {
		ll X = A / 2 + B / 2;
		ll Y = B / 2 + C / 2;
		ll Z = A / 2 + C / 2;
		++c;
		if (A == Y && B == Z && C == X) {
			print(-1);
			return 0;
		}
		A = Y; B = Z; C = X;
	}
	print(c);
}

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

int main(){
	int x[10000];
	int y[10000];
	for (int i = 0; i < 10000; i++){
		cin >> x[i] >> y[i];
		if (x[i] == 0 && y[i] == 0){
			break;
		}
	}
	for (int i = 0; i < 10000; i++){
		if (x[i] == 0 && y[i] == 0){
			break;
		}
		if (x[i] > y[i]){
			cout << y[i] << " " << x[i] << endl;
		}
		else{
			cout << x[i] << " " << y[i] << endl;
		}
	}
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define int long long
#define REP(i,N) for(i=0; i<n; i++)
using namespace std;
signed main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    return 0;
}

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


def main():
    n = int(input())
    w_list = list(map(int, input().split()))
    s1 = 0
    s2 = sum(w_list)
    tmp_ans = s2
    for i in range(n):
        s1 += w_list[i]
        s2 -= w_list[i]
        diff = abs(s1 - s2)
        if tmp_ans > diff:
            tmp_ans = diff
        else:
            break
    print(tmp_ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

using VI = vector <int>;
using VVI = vector <VI>;

inline int getBlockStart(int npos, int bakPos) {
    int nextBlock = (bakPos+1-2)/3 * 3 + 2;
    return npos < 0 ? nextBlock : max(nextBlock, (npos-2)/3*3 + 2);
}

inline int checkEqual(VI& A, int i, int j, int k){
    return A[i] == A[k] && A[i] == A[j];
}

inline void solve(VVI& dp, VI& A, int i, int j, int s) {
    if (s <= j && s+3 > j) {
        s += 3;
    }

    if (s <= j || j <= i) {
        return ;
    }

    int plus = s < A.size() ? checkEqual(A, i, j, s) : 0;
    dp[A.size()][A.size()] = max(dp[A.size()][A.size()], dp[i][j] + plus);

    if (s+2 < A.size()) {
        dp[i][s+0] = max(dp[i][s+0], dp[i][j] + checkEqual(A, j, s+1, s+2));
        dp[i][s+1] = max(dp[i][s+1], dp[i][j] + checkEqual(A, j, s+0, s+2));
        dp[i][s+2] = max(dp[i][s+2], dp[i][j] + checkEqual(A, j, s+0, s+1));

        dp[j][s+0] = max(dp[j][s+0], dp[i][j] + checkEqual(A, i, s+1, s+2));
        dp[j][s+1] = max(dp[j][s+1], dp[i][j] + checkEqual(A, i, s+0, s+2));
        dp[j][s+2] = max(dp[j][s+2], dp[i][j] + checkEqual(A, i, s+0, s+1));

        dp[s+0][s+1] = max(dp[s+0][s+1], dp[i][j] + checkEqual(A, i, j, s+2));
        dp[s+0][s+2] = max(dp[s+0][s+2], dp[i][j] + checkEqual(A, i, j, s+1));
        dp[s+1][s+2] = max(dp[s+1][s+2], dp[i][j] + checkEqual(A, i, j, s+0));
    }
}

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

    VI A;
    int ans = 0;

    for (int i = 0; i <= N; ++i) {
        // pattern: 2, 3, 3 .... , 1
        int upper = 2 + (i > 0) - 2*(i == N);
        for (int j = 0; j < upper; ++j) {
            int v;
            cin >> v;
            A.push_back(v);
        }

        while (A.size() >= 3) {
            int aSize = A.size();

            if (A[aSize-1] == A[aSize-2] && A[aSize-1] == A[aSize-3]) {
                A.pop_back();
                A.pop_back();
                A.pop_back();
                ++ans;
            } else {
                break;
            }
        }
    }

    VVI dp(A.size()+1, VI(A.size()+1, -1));
    VI curPos(N+1, -1);
    VI nextPos(A.size() + 1);

    for (int p = A.size()-1; p >= 0; --p) {
        nextPos[p] = curPos[A[p]];
        curPos[A[p]] = p;
    }

    dp[0][1] = 0;

    for (int i= 0; i < A.size(); ++i) {
       for (int j = i+1; j < A.size(); ++j) {
            if (dp[i][j] == -1) {
                continue;
            }

            solve(dp, A, i, j, getBlockStart(j+1, j));

            // match i
            solve(dp, A, i, j, getBlockStart(nextPos[i], j));

            // match j
            solve(dp, A, i, j, getBlockStart(nextPos[j], j));
       }
    }

    if (!A.empty()) {
        cout << ans + dp[A.size()][A.size()] << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 144196
def main():
    N, M, X = map(int,input().split())
    
    cost = []
    effect = []
    for _ in range(N):
        t = list(map(int,input().split()))
        cost.append(t[0])
        effect.append(t[1:])

    res = float("inf")
    for bits in range(1<<N):
        f = True
        total = 0
        ans = [0] * M
        for flag in range(N):
            if (1<< flag) & (bits):
                total += cost[flag]
                for idx, e in enumerate(effect[flag]):
                    ans[idx] += e 
        for a in ans:
            if a < X: f = False
        if f:
            res = min(res, total)

    print(res if res != float("inf") else -1)

if __name__ == "__main__":
    main()



Measured memory_bytes: 68612