akhauriyash/Code-Regression huggingface dataset:
/*やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん

（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。

今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、

そこでしこたま酒を飲んでからやりはじめたんや。

3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。

しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。

浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、

先に兄ちゃんがわしの口に糞をドバーっと出して来た。

それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、

3人で出した糞を手で掬いながらお互いの体にぬりあったり、

糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。

しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。

浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると

けつの穴が糞と小便でずるずるして気持ちが良い。

にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。

糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。

それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、

糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。

やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。

ああ～～早く糞まみれになろうぜ。

岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や

糞まみれでやりたいやつ、至急、メールくれや。

土方姿のまま浣腸して、糞だらけでやろうや。*/
#include "bits/stdc++.h"
#include <numeric>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define llMIN numeric_limits<long long>::min()
#define intMIN numeric_limits<int>::min()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

ll digitpower(ll a,ll b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  if(b%2==1){
    ll tmp = digitpower(a,(b-1)/2);
    tmp%=d9_7;
    tmp*=tmp;
    tmp%=d9_7;
    tmp*=a;
    return (tmp)%d9_7;
  }else{
    ll tmp = digitpower(a,(b)/2);
    tmp%=d9_7;
    tmp*=tmp;
    tmp%=d9_7;
    return (tmp)%d9_7;
  }
}
//階乗
vl facs(1000000,-1);
ll Factrial(ll num){
  if(facs[num]!=-1){
    return facs[num];
  }
  if(num==1||num<=0){
    return 1;
  }else if(num<0){
    printf("ERROR_minus\n");
    return 0;
  }else{
    facs[num]=(num*Factrial(num-1))%d9_7;
    return facs[num];
  }
}
long long modinv(long long a, long long m) {//modの逆元
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
ll linercomb(ll n,ll k, ll mod){//n,kの線形時間で求める
  ll ans=Factrial(n);
  ans*=modinv(Factrial(k),mod);
  ans%=d9_7;
  ll k1=Factrial(k);
  k1%=mod;
  ans*=modinv(k1,mod);
  ans%=mod;
  return ans;
}
int main(void){
  ll n,h,w;
  cin>>h>>w>>n;
  ll maxn = max(h,w);
  cout<<((n+maxn-1)/maxn)<<endl;
  return 0;
}


Measured memory_bytes: 8064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            Map<Integer, Character> map = new HashMap<>();
            map.put(2, 'c');
            map.put(4, 'b');
            map.put(6, 'b');
            map.put(9, 'b');
            map.put(11, 'b');

            char x = map.getOrDefault(in.nextInt(), 'a');
            char y = map.getOrDefault(in.nextInt(), 'a');
            out.println(x == y ? "Yes" : "No");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
using namespace std;
void printA(int A[], int n){
    for (int k = 0; k < n; k++){
        if (k != n - 1){
            cout << A[k] << " ";
        }else{
            cout << A[n - 1] << endl;
        }
    }
}
int main(void){
    int n;
    cin >> n;
    int A[n];
    for (int i = 0; i < n; i++){
        int item;
        cin >> item;
        A[i] = item;
    }
    // insertion sort
    for (int i = 0; i < n; i++){
        int key;
        key = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > key){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = key;
        printA(A, n);
    }
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}


int main (){
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>> vp;
    Rep(i,n){
        string tmps;
        int tmpp;
        cin >> tmps >> tmpp;
        vp.pb(mp(mp(tmps,-tmpp),i+1));
    }
    sort(All(vp));
    Rep(i,n){
        cout << vp[i].S << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll a, b, k; cin >> a >> b >> k;
    ll tmp = a;
    a = max(0ll, a-k);
    k = max(0ll, k-tmp);
    b = max(0ll, b-k);
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >>s;
    bool a=true;
    for(int i=0;i<s.size();i++){
        if(s[i]=='L'&&i%2==0)a=false;
        if(s[i]=='R'&&i%2==1)a=false;
    }
    if(a)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int a,b;
int main()
{
    scanf("%d",&a);
    for (int i = 1;i <= 9;i++)
        for (int j = 1;j <= 9;j++)
            if (a == i * j)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
    cout<<"No"<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i=0;i<N;i++){
    cin >>vec.at(i);
  }
  int count=0;
  for (int i=0;i<N;i++){
    if (vec.at(i)!=i+1){
      count++;
    }
  }
  if (count==0 or count==2){
    cout << "YES" <<endl;
  }
  else{
    cout << "NO" <<endl;
  }
}

Measured memory_bytes: 256
def quick_sort(list):
    stand=list[0]
    over=[]
    same=[]
    under=[]
    for i in list:
        if(i>stand):
            over.append(i)
        elif(i<stand):
            under.append(i)
        else:
            same.append(i)
    if(len(over)>1):
        over=quick_sort(over)
    else:
        pass
    if(len(under)>1):
        under=quick_sort(under)
    else:
        pass

    return under+same+over

N=int(input())
A=list(map(int,input().split()))
A=quick_sort(A)
ans=1
way=0
for i in A:
    ans*=i
    way=str(ans-1)
    if(len(way)>=19):
        ans=-1
        break
    else:
        pass
print(ans)

Measured memory_bytes: 22316
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(15, vector<int>(15, -1));
    rep(i, n) {
        int a;
        cin >> a;
        rep(j, a) {
            int x, y;
            cin >> x >> y;
            --x;
            g[i][x] = y;
        }
    }
    int ans = 0;
    rep(i, 1<<n) {
        vector<bool> flg(n, false);
        rep(j, n) {
            if ((i>>j) & 1) {
                flg[j] = true;
            }
        }
        bool ok = true;
        rep(j, n) {
            if (flg[j]) {
                rep(k, n) {
                    if (g[j][k] == -1) continue;
                    if (g[j][k] != flg[k]) ok = false;
                }
            }
        }
        if (ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int count = 0;
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();
    for (int i = 0; i < N; i++) {
      if (a[i] != i + 1) count++;
    }
    if (count <= 2) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


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

int N,K,a[100];
LL dp[101][100001] = {};
LL wa[101][100002] = {};
const LL MOD = 1000000007;

int main(){
	cin >> N >> K;
	for(int i=0; i<N; i++) cin >> a[i];

	dp[0][0] = 1;
	for(int i=0; i<=K; i++) wa[0][i+1] = 1;
	for(int i=1; i<=N; i++){
		for(int j=0; j<=K; j++){
			dp[i][j] = wa[i-1][j+1] - wa[i-1][max(0,j-a[i-1])] + MOD;
			dp[i][j] %= MOD;
			wa[i][j+1] = wa[i][j] + dp[i][j];
			wa[i][j+1] %= MOD;
		}
	}
	cout << dp[N][K] << endl;

	return 0;
}

Measured memory_bytes: 158080
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

int main() {
	int N;
	while(cin>>N,N){
		unsigned int allN=N;
		set<int> s[51];
		int a,b,ans=-1;
		bool day[51][31]={false};
		REP(i,0,N){
			cin>>a;
			REP(j,0,a){
				cin>>b;
				day[i][b]=true;
			}
			s[i].insert(i);
		}

		REP(i,1,31){
			set<int> today;
			REP(j,0,N){
				if(day[j][i]){
					for(auto itr=s[j].begin();itr!=s[j].end();itr++){
						today.insert(*itr);
					}
				}
			}
			if(today.size()==allN){
				ans=i;
				break;
			}
			REP(j,0,N){
				if(day[j][i])
				s[j]=today;
			}
		}

		p(ans);
	}
	return 0;
}

Measured memory_bytes: 3204
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::map<int64_t, int64_t> M;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        M[t]++;
    }

    int64_t one = 0;
    int64_t dbl = 0;
    for (auto& m: M) {
        int64_t c = m.second;
        if (c % 2 == 1) {
            one++;
        }
        else {
            dbl++;
        }
    }

    one += dbl;
    one -= dbl % 2;

    std::cout << one << std::endl;

    return 0;
}


Measured memory_bytes: 6528
import java.util.*

fun main(args: Array<String>) {
    class P(val x: Int, val y: Int, val d: Int)
    val (H, W) = readLine()!!.split(' ').map(String::toInt)
    val field = Array(H){ readLine()!!.toCharArray() }
    val visited = Array(H) { Array(W) {false} }

    val q = ArrayDeque<P>()
    q.push(P(0, 0, 0))
    val totalBlack = field.sumBy { x -> x.filter{c -> c == '#'}.count() }
    var ans = -1;
    val dx = arrayOf(1, 0, -1, 0)
    val dy = arrayOf(0, 1, 0, -1)
    while (!q.isEmpty()) {
        val p = q.poll()
        if (p.y < 0 || p.y >= H || p.x < 0 || p.x >= W) {
            continue
        }
        if (visited[p.y][p.x]) continue
        visited[p.y][p.x] = true
//        println("${p.x} ${p.y} ${p.d} $totalBlack")
        if (p.y == H-1 && p.x == W -1) {
            ans = H * W - p.d - 1 - totalBlack
            break
        }
        if (field[p.y][p.x] == '#') {
            continue
        }
        dx.zip(dy).forEach { pair ->
            val dx = pair.first
            val dy = pair.second
            q.add(P(p.x + dx, p.y + dy, p.d + 1))
        }
    }
    println(ans)
}


Measured memory_bytes: 38176
#include <bits/stdc++.h>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD (ll)(1e9+7)
#define MAX (ll)(1e5*2+200)
#define print(x) cout << x << endl;
#define printArr(arr) REP(i, (sizeof arr / sizeof arr[0])){print(arr[i])}
#define printVec(vec) REP(i, vec.size()){print(vec[i])}
using namespace std;

std::string replaceAll(std::string &replacedStr, std::string from, std::string to) {
    int pos = replacedStr.find(from);
    int toLen = to.length();
    
    if (from.empty()) {
        return replacedStr;
    }
    
    while ((pos = replacedStr.find(from, pos)) != std::string::npos) {
        replacedStr.replace(pos, from.length(), to);
        pos += toLen;
    }
    return replacedStr;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    replaceAll(s, ",", " ");
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     int ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/















bool compare(pair<int,int> p1,pair<int,int> p2){
     if(p1.fi<p2.fi)return true;
     else if(p1.fi==p2.fi&&p1.se<p2.fi)return true;
     return false;

}

int main(){
     int n;
     cin>>n;
     ll a[n];
     for(int i=0;i<n;i++)cin>>a[i];
     sort(a,a+n);reverse(a,a+n);
     ll res=a[0];
     int t=2;
     for(int i=1;i<n&&t<=n;i++){
          if(t+2<=n){
               res+=2*a[i];
               t+=2;
          }
          else if(t+1==n){
               res+=a[i];t++;
          }
          else{
               break;
          }
     }
     cout<<res;
}



















































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

int main() {
  int N;
  cin >> N;
  vector<double> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }

  double sita;

  for (int i = 0; i < N; i++) {
    sita += 1 / vec[i];
  }
  cout << fixed << setprecision(6);
  cout << 1 / sita << endl;
}

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

using namespace std;

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

    vector<int> C(N);
    vector<int> S(N);
    vector<int> F(N);

    for (int i = 1; i < N; i ++) {
        cin >> C[i] >> S[i] >> F[i];
    }

    for (int x = 1; x < N; x ++) {
        int t = S[x];
        t += C[x];

        for (int i = x + 1; i < N; i ++) {

            //cerr << "In station " << i << endl;

            int tcd = S[i];
            while (tcd < t)
                tcd += F[i];

            //cerr << "TCD, T " << tcd << ", " << t << endl;

            t += (tcd - t);
            t += C[i];
        }

        cout << t << endl;
    }
    cout << 0 << endl;

    return 0;
}



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

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int>p(n);
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    int ans = 0;
    for(int i = 0; i < k; i++)
    {
        ans +=  p[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;


int main(){
    int n, x, t;
    cin >> n >> x >> t;

    int k = (n + x - 1) / x;

    cout << t * k << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)


int power(int n, int r){
  int ans = 1;
  rep(i, r)
    ans *= n;
  return ans;
}

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  char c[H][W];
  rep(i, H)
    rep(j, W)
    cin >> c[i][j];
  //

  int count = 0;
  int ans = 0;
  bool CH[H], CW[W];  
  rep(i, power(2, H) ){
    rep(j, power(2, W) ){
      count = 0;
      rep(k, H){
	int bitH = H-1-k;
	bool h = i&power(2, bitH);
	rep(l, W){
	  int bitW = W-1-l;
	  bool w = j&power(2, bitW);
	  if(h==0 && w==0){
	    if(c[k][l] == '#'){
	      //cout << i<<" "<<j<<",  "<<k<<" "<<l<<endl;
	      count++;
	    }
	  }
	} //l
      } //k
      //cout << "count : "<<count<<endl;
      if(count == K)
	ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3592
// <------------- Template -----------------------> //


#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(2);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 
 
typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAX5]; 

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, q, m, k;
string s, t, d;
ll sum = 0;
ll cou = 0;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> k;
	vpll a;
	for(ll i=0;i<n;i++) {
		cin >> x >> y;
		a.pb({x,y});
	}
	sort(all(a));
	if(a[0].s >= k) {
		cout<<a[0].f;
		return;
	}
	for(ll i=1;i<=n;i++) {
		a[i].s += a[i-1].s;
		if(a[i].s >= k) {
			cout<<a[i].f;
			return;
		}	
	}
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

int main() {
  string n;
  cin >> n;
  int sum = 0;
  
  for(int i =0; i<n.size(); i++){
    sum += (n.at(i) - '0');
  }
  if(sum%9 == 0)
    cout << "Yes" <<endl;
  else
  	cout << "No" << endl;
  
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,p,a,odd;

main() {
    cin >> n >> p;
    rep(i,n) {
        cin >> a;
        if (a%2) odd++;
    }
    if (!odd) {
        if (p) ct(0)
        else ct((int)pow(2,n))
    }
    else ct((int)pow(2,n-1))
}


Measured memory_bytes: 256
input_d1 = int(input()) 
input_d2 = list(input().split())

c = sorted(input_d2)
c.append('0')
e = {'0':0}
g = [0]
s = 0
f = 0

for i in range(0,input_d1):
    if c[i] == c[i+1]:
        pass
    else:
        g.append(i+1)
        e[c[i]] = i + 1 - g[s]
        s += 1
        f += e[c[i]]*(e[c[i]]-1)/2
        
e.pop('0')
d = {}

for i in e.keys():
    d[i] = 1 - e[i] + f


for i in input_d2:
    print(int(d[i]))

Measured memory_bytes: 45152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

typedef long double ld;

const ld PI = 4 * atanl(1);

const int C = 2 * (int)1e8;
const int N = 200200;
int n, m;
int Sx, Sy, Tx, Ty;
bool revX = false, revY = false;
pii a[N];
int xs[N];
int dp[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d%d%d", &Sx, &Sy, &Tx, &Ty);
	scanf("%d", &m);
	if (Sx > Tx) {
		Sx = C - Sx;
		Tx = C - Tx;
		revX = true;
	}
	if (Sy > Ty) {
		Sy = C - Sy;
		Ty = C - Ty;
		revY = true;
	}
	while(m--) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (revX) x = C - x;
		if (revY) y = C - y;
		if (x < Sx || x > Tx || y < Sy || y > Ty) continue;
		a[n++] = mp(x, y);
	}
	m = 0;
	for (int i = 0; i < n; i++)
		xs[m++] = a[i].first;
	sort(xs, xs + m);
	m = unique(xs, xs + m) - xs;
	if (m != n) throw;
	for (int i = 0; i < n; i++)
		a[i].first = lower_bound(xs, xs + m, a[i].first) - xs;
	m = 0;
	for (int i = 0; i < n; i++)
		xs[m++] = a[i].second;
	sort(xs, xs + m);
	m = unique(xs, xs + m) - xs;
	if (m != n) throw;
	for (int i = 0; i < n; i++)
		a[i].second = lower_bound(xs, xs + m, a[i].second) - xs;
	sort(a, a + n);
	for (int i = 0; i <= n; i++)
		dp[i] = N;
	dp[0] = -1;
	for (int i = 0; i < n; i++) {
		int pos = lower_bound(dp, dp + n + 1, a[i].second) - dp;
		dp[pos] = a[i].second;
	}
	int val = n;
	while(dp[val] == N) val--;

	ld ans = 100 * (ld)(Tx - Sx + Ty - Sy) - (ld)val * (4 - PI) * 5;

	if (val == min(Tx - Sx, Ty - Sy) + 1) {
		ans += 10 * (PI - 2);
		ans += (4 - PI) * 5;
	}

	printf("%.15lf\n", (double)ans);

	return 0;
}


Measured memory_bytes: 3328
x, y = [int(x) for x in input().split()]
canbe = "No"
for i in range(1, x + 1):
    a = (i * 2) + (x - i) * 4
    b = (i * 4) + (x - i) * 2
    if a == y or b == y:
        canbe = "Yes"
        break
print(canbe)


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
int main() {
  int s,a,b,c;
  cin >> s;
  a = s / 100;
  s = s % 100;
  b = s / 10;
  s = s % 10;
  c = s;
  cout << a+b+c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;
typedef struct{
  int x,y,n;
}T;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
vector<vector<char> > mas;
queue<T> que;

int bfs(int H, int W){
  int max = 0;
  while(que.size()){
    T t = que.front();que.pop();
    int i;
    REP(i,4){
      int nx = t.x+dx[i], ny = t.y+dy[i], nn = t.n+1;
      if(nx >= 0 && nx < W && ny >= 0 && ny < H && mas[nx][ny] != '#'){
        mas[nx][ny] = '#';
        if(nn > max) max = nn;
        que.push({nx,ny,nn});
      }
    }
  }
  return max;
}

int main(void){
  int x,y,H,W;cin >> H >> W;
  mas = vector<vector<char> >(W,vector<char>(H));
  REP(y,H)REP(x,W){
    cin >> mas[x][y];
    if(mas[x][y] == '#')que.push({x,y,0});
  }
  cout << bfs(H,W) << endl;
  return 0;
}


Measured memory_bytes: 13328
#include <bits/stdc++.h> 
using namespace std; 
int main() 
{ 
	int n;
    cin >> n;
    long long int a[n], hash[200007];
    long long int prob[200007];
    memset(hash, 0, sizeof hash);
    memset(prob, 0, sizeof prob);
    long long int sum = 0;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        hash[a[i]]++;
    }
    for(int i=1;i<=200001;i++)
    {
        prob[i] = 0;
        if(hash[i]>1)
        {
            prob[i] = hash[i]*(hash[i]-1);
            prob[i] /= 2;
            sum += prob[i];
        } 
    }
    for(int i=0;i<n;i++)
    {
        long long int x = sum - prob[a[i]];
        long long int y = hash[a[i]] -1;
        //cout << y << endl;
        if(y>0)
        {
            y = y*(y-1);
            y /= 2;
        }
        if(y>0)
        cout << x + y << endl;
        else
        cout << x << endl;
    }
} 


Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<bitset>
#include<vector>
#include<deque>
using namespace std;
#define re register int
inline int read(){
	int x=0,ff=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')ff=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*ff;
}
long long a,b,k;
int main(){
	cin>>a>>b>>k;
	if(a<k){
		b=b-(k-a);if(b<0)b=0;
		a=0;
	}
	else a-=k;
	cout<<a<<" "<<b<<endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
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 int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
int main(){
    ll n;cin>>n;
    ll ng=0;
    map<l_l,l_l> mp;
    rep(i,n){
        ll x,y;cin>>x>>y;
        if(x==0&&y==0){
            ng++;
            continue;
        }
        ll g=gcd(x,y);
        x=x/g;
        y=y/g;
        if(y<0)x=-x,y=-y;
        if(y==0&&x<0)x=-x;
        bool rot=(x<=0);
        if(rot){
            ll tmp=x;
            x=y;
            y=-tmp;
        }
        if(rot)mp[{x,y}].se++;
        else mp[{x,y}].fi++;
    }
    mint ans=1;
    for(auto p:mp){
        mint now=1;
        ll s=p.se.fi;
        ll t=p.se.se;
        now+=mint(2).pow(s)-1;
        now+=mint(2).pow(t)-1;
        ans*=now;
    }
    ans-=1;
    ans+=ng;
    cout<<ans.x<<endl;
    return 0;
}

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

int main() {
	int n;
	int count = 0;
	long a[114514];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 1) count++;
	}
	if (count % 2 == 1)cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

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

int main() {
    long n, k;
    cin >> n >> k;
    vector<long> h(n);
    for(long i=0; i<n; i++){
        cin >> h.at(i);
    }
    long count=0;
    sort(h.begin(), h.end());
    for(long i=0; i<n-k; i++){
        count += h.at(i);
    }
    cout << count << endl;
}

Measured memory_bytes: 1792
N = gets.to_i
ss = Array.new(N) { gets.chomp }
M = gets.to_i
ts = Array.new(M) { gets.chomp }

m = {}
ss.each {|s| m[s] ? m[s] += 1 : m[s] = 1 }
ts.each {|s| m[s] ? m[s] -= 1 : m[s] = -1}

key = ''
ans = 0
m.each do |k, v|
  if v >= ans
    ans = v
    key = k
  end
end

puts ans


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int N, M;
VI G[100005];
bool visited[100005];

void dfs(int v) {
    if (visited[v]) return;
    visited[v] = true;
    for (int u : G[v]) {
        dfs(u);
    }
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> N >> M;
    REP(i, M) {
    	ll x, y, w;
    	cin >> x >> y >> w;
    	G[x].push_back(y);
    	G[y].push_back(x);
    }
    int ans = 0;
    FOR(i, 1, N) {
        if (!visited[i]) {
            dfs(i);
            ans++;
        }
    }
    cout << ans << "\n";

}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;

int main() {FIN
	
	ll n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0)
		cout << (b - a) / 2 << "\n";
	else
		cout << min(min(b - 1, n - a), min(a + ((b - a) - 1) / 2, (n - b) + 1 + ((b - a) - 1) / 2)) << "\n";
	return 0;
}


Measured memory_bytes: 256
/*
 * atcoder/abc124/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const ll INF = 1000000000000000;
const int MAX = 100100;
int N;
string S;
vector<bool> B(MAX, false);

// dp[n][i] := 最後がiでn番目まで揃えた時の最小のタイル変更数
ll dp[MAX][2];

void solve() {
  cin >> S;
  N = S.size();
  loop(n,0,N+1) loop(i,0,2) dp[n][i] = INF;
  dp[0][0] = 0;
  dp[0][1] = 0;

  loop(n,0,N) {
    bool b = S[n] == '1'; // 今回のタイル色
    loop(i,0,2) {
      // 今回bだったので、前回が!bなら +0 bなら+1
      chmin(dp[n+1][!i], dp[n][i] + (b == i));
    }
  }
  cout << min(dp[N][0], dp[N][1]) << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    vector<vector<int>> c(n, vector<int>(26));
    for(int i = 0; i < n; i++){
        cin >> s[i];
        for(int j = 0; j < s[i].size(); j++){
            c[i][s[i].at(j) - 'a']++;
        }
    }
    vector<int> x(26);
    fill(x.begin(), x.end(), 51);
    for(int i = 0; i < 26; i++){
        for(int j = 0; j < n; j++){
            x[i] = min(x[i], c[j][i]);
        }
        for(int j = 0; j < x[i]; j++)
            cout << (char)(i + 'a');
    }
}

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

int main() {
    int N, K, R, S, P; 
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    int rkai=0, skai=0, pkai=0;

    for(int i=0; i<N-K; i++){
        if(T[i]==T[i+K]){
            T[i+K] = 'u';
        }
    }
    for(int i=0; i<N; i++){
        if(T.at(i)=='r') rkai++;
        if(T.at(i)=='s') skai++;
        if(T.at(i)=='p') pkai++;
    }

    int score = P*rkai + R*skai + S*pkai;

    cout << score << endl;

}


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

int N;
vector<int> X;

void dfs(vector<bool> &visited,int now){
	for(int i=1;i<=N;i++){
		if(visited.at(i))	continue;
		visited.at(i)=true;
		dfs(visited,now*10+i);
		visited.at(i)=false;
	}

	bool flag=true;
	for(int i=0;i<=N;i++)	if(visited.at(i)==false)	flag=false;
	if(flag)	X.push_back(now);
}

int main(){
	cin >> N;
	vector<int> P(N),Q(N);
	for(int i=0;i<N;i++)	cin >> P.at(i);
	for(int i=0;i<N;i++)	cin >> Q.at(i);

	int p=0;
	int q=0;
	for(int i=0;i<N;i++){
		p*=10;
		p+=P.at(i);
		q*=10;
		q+=Q.at(i);
	}
	//cout << p << "," << q << endl;
	vector<bool> visited(N+1,false);
	visited.at(0)=true;
	dfs(visited,0);
	sort(X.begin(),X.end());
	int a=0;
	int b=0;
	for(int i=0;i<X.size();i++){
		if(X.at(i)==p)	a=i;
		if(X.at(i)==q)	b=i;
	}
	cout << abs(a-b) << endl;

	return 0;
}


Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
	val sc = Scanner(System.`in`)
	val h = sc.nextInt()
	val w = sc.nextInt()

	val ans = mutableListOf<String>()

	for (i in 0 until h) {
		val c = sc.next()
		for (j in 0 until 2) {
			ans.add(c)
		}
	}
	println(ans.joinToString("\n"))
}


Measured memory_bytes: 31516
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;
 
int main() {
    int N;
    cin >>N;
    vector<int> M;
    for(int i=1;i<=9;++i){
        for(int j=1;j<=9;++j){
            int a=i*j;
            M.emplace_back(a);
        }
    }
 
  auto itr = find(M.begin(), M.end(), N);
  size_t index = std::distance( M.begin(), itr );
  if (index != M.size()){
      cout<<"Yes"<<endl;
  }
  else{
      cout<<"No"<<endl;
  }



return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int sum = 1, x, y, c[200], k[200], t[200];
signed main() {
	scanf ("%lld", &x); y = x;
	c[2] = 3, c[3] = 2, c[5] = 1;
	for (int i = 2; i <= x; ++i) {
		if (!k[i]) {
			while (x % i == 0) x /= i, ++t[i];
		} for (int j = i + i; j <= x; j += i) k[j] = 1; 
	} 
	for (int i = 1; i < 200; ++i) {
		for (int j = 1; j <= max (c[i], t[i]); ++j) sum *= i;
	} return printf ("%lld\n", sum / y), 0;
}

Measured memory_bytes: 3788
from sys import setrecursionlimit; setrecursionlimit(10**9)
N = int(input())

def factorize(n):
    # NOTE: if n == 1, return []
    if n < 1:
        raise Exception('Invalid input: n = {}'.format(n))
    i = 2
    ret = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            ret.append(i)
        i += 1
    if n > 1:
        ret.append(n)
    return ret

A = factorize(N)
l = len(A)

def res(i, B, C):
    if i >= l:
        val = 1
        for b in B:
            val *= b
        C.append(max(len(str(val)), len(str(N//val))))
        return None
    B.append(A[i])
    res(i+1, B, C)
    B.pop()
    res(i+1, B, C)
    return C

if N == 1:
    print(1)
else:
    C = res(0, [], [])
    print(min(C))


Measured memory_bytes: 11336
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(x,n) for(int i=x;i<n;i++)
#define REP(y,n) for(int j=y;j<n;j++)
#define vi vector<int>
#define vvi vector<vector<int>>
signed main(){
  int n,x,count=0;
  while(true){
    cin>>n>>x;
    if(n==0&&x==0)break;
    for(int i=1;i<n+1;i++){
      for(int j=i+1;j<n+1;j++){
        for(int k=j+1;k<n+1;k++){
          if(i+j+k==x)count++;
        }
      }
    }
    cout<<count<<endl;
    count=0;
  }
}



Measured memory_bytes: 3088
use std::cmp;
use std::collections::*;
use std::io::{self, Read};

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let n: usize = sc.read().unwrap();

    let mut s = HashSet::new();
    let w: String = sc.read().unwrap();
    let w: Vec<char> = w.chars().collect();
    let mut wp = *w.last().unwrap();
    s.insert(w);

    for _ in 0..n - 1 {
        let wi: String = sc.read().unwrap();
        let wi: Vec<char> = wi.chars().collect();
        let ws = *wi.first().unwrap();

        if wp == ws && !s.contains(&wi) {
            wp = *wi.last().unwrap();
            s.insert(wi);
        } else {
            println!("No");
            return;
        }
    }

    println!("Yes");
}

struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }

    fn read_board(&mut self, n: usize) -> Option<Vec<Vec<char>>> {
        (0..n)
            .map(|_| {
                self.read::<String>()
                    .map(|s| s.chars().collect::<Vec<char>>())
            })
            .collect()
    }
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int alice = 0, bob = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) alice += a[i];
        else bob += a[i];
    }
    cout << alice - bob << '\n';
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split(" ")))


def solve(s1, s2):
    "if start == true, assume the first of the sum is positive."
    res = 0
    sum = 0
    for i in range(n):
        sum += a[i]
        if sum <= 0 and i % 2 == s1:
            res += abs(sum) + 1
            sum = 1
        elif sum >= 0 and i % 2 == s2:
            res += abs(sum) + 1
            sum = -1
    return res


print(min(solve(0, 1), solve(1, 0)))


Measured memory_bytes: 19980
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <unordered_map>

const int MOD = pow(10,9)+7;
typedef long long ll;

using namespace std;
int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}




int main() {

    ll N = lin(); ll M = lin();
    
    ll ans = 0;

    ll count = min(N,M/2);
    
    ans+=count;
    N-=count;
    M-=2*count;
    
    
    ans+=M/4;

    
    cout << ans << endl;
    

    
    return 0;
    
}





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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    vi a(N);
    Rep(i,N){
        Scd(a[i]);
    }

    ll ans = 1e13;
    ll tmp = 0;
    Rep(xi,101){
        tmp = 0;
        Rep(i,N){
            tmp += (a[i]-xi)*(a[i]-xi);
        }
        ans = min(ans,tmp);
    }

    printf ("%lld\n", ans );

    return 0;
}



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

int main (){
  string s ;
  int list[3] = {0};
  std::cin >> s;

  for(int i = 0; i < 3; i++){
    list[s[i]-'a']++;
  }
  if(list[0] == list[1] && list[1] == list[2]){
    std::cout <<"Yes"<< '\n';
  }else{
    cout << "No" << '\n';
  }


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>

using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;

//int main() {
//	int n,c,v;
//	array<array<pii, 50>, 50> graph = {};
//	scanf("%d %d %d", &n, &c, &v);
//	vector<pii> roads(v, {0,0});
//	for (int i = 0; v > i; i++) {
//		int s;
//		scanf("%d", &s);
//		roads[i].first = s;
//	}
//	for (int i = 0; v > i; i++) {
//		int s;
//		scanf("%d", &s);
//		roads[i].second = s;
//	}
//	for (int i = 0; v > i; i++) {
//		int s;
//		scanf("%d", &s);
//		graph[roads[i].first][roads[i].second].first = s;
//	}
//	for (int i = 0; v > i; i++) {
//		int s;
//		scanf("%d", &s);
//		graph[roads[i].first][roads[i].second].second = s;
//	}
//
//	array<int> 
//
//	return 0;
//}

int main() {
	int n;
	while (scanf("%d", &n)) {
		if (!n)
			return 0;
		array<array<int, 11>, 11> graph = {};
		for(auto itr = graph.begin(); itr != graph.end(); itr++)
			fill(itr->begin(), itr->end() , -1);
		int m = 0;
		for (int i = 0; n > i; i++) {
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);

			graph[a][b] = c;
			graph[b][a] = c;
			m = max({a,b,m});
		}
		m++;
		pii Min = { INT_MAX,INT_MAX };
		for (int i = 0; m > i; i++) {
			priority_queue<pii, vector<pii>, greater<pii>> que;
			vector<int> al(m, -1);
			for (int j = 0; m > j; j++) {
				if (graph[i][j] != -1) {
					que.push({ graph[i][j], j });
				}
			}
			al[i] = 0;
			while (!que.empty()) {
				pii num = que.top();
				que.pop();
				if (al[num.second] != -1)
					continue;
				al[num.second] = num.first;
				for (int j = 0; m > j; j++) {
					if (graph[num.second][j] != -1 && al[j] == -1) {
						que.push({ num.first + graph[num.second][j], j });
					}
				}
			}
			Min = min(Min, { accumulate(al.begin(), al.end(),0),i });
		}
		printf("%d %d\n", Min.second, Min.first);
	}
	return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	while(true){
		
		int n;
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		int ans = 0;
		
		while(true){
			if(n == 1){
				break;
			}
			if(n % 2 == 0){
				n /= 2;
			}else{
				n = 3 * n + 1;
			}
			ans++;
		}
		
		cout << ans << endl;;
		
	}
	return 0;
}

Measured memory_bytes: 3016