akhauriyash/Code-Regression huggingface dataset:
def prime_factorize(n):
    res = []
    for i in range(2, int(n**(1/2))+1):
        if n % i != 0: continue
        num = 0
        while n % i == 0:
            num += 1
            n /= i
        res.append((i, num))
    if n != 1:
        res.append((n, 1))
    
    return res

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

prime = prime_factorize(p)

ans = 1
for k, v in prime:
    ans *= k ** (v // n)

print(int(ans))


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;

vector<int> to[100005];
 
int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
 
  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int v = q.front(); q.pop();
    for (int u : to[v]) {
      if (dist[u] != INF) continue;
      dist[u] = dist[v]+1;
      pre[u] = v;
      q.push(u);
    }
  }
 
  cout << "Yes" << endl;
  rep(i,n) {
    if (i == 0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 10636
import java.util.*;

class Main{
  public static int max2(int a,int b){
    return (a>b)?a:b;
  }
  
  public static long max2(long a,long b){
    return (a>b)?a:b;
  }
  
  public static int max3(int a,int b,int c){
    return (max2(a,b)<c)?c:max2(a,b);
  }
  
  public static int min2(int a,int b){
    return (a>b)?b:a;
  }
  
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int W=sc.nextInt();
    int[] w=new int[N];
    Long[] v=new Long[N];
    long[][] ans=new long[N][W+1];
    //ans[i][j]は0からi番目の荷物から、重さj以下になるように選んだときの最大価値
    
    for(int i=0;i<N;i++){
      w[i]=sc.nextInt();
      v[i]=sc.nextLong();
    }
      
    
    for(int i=0;i<W+1;i++){
      if(i<w[0]){
        ans[0][i]=0;
      }else{
        ans[0][i]=v[0];
      }
      
    }
    
    for(int i=1;i<N;i++){
      for(int j=0;j<W+1;j++){
        if(j<w[i]){
          ans[i][j]=ans[i-1][j];
        }else{
          ans[i][j]=max2(ans[i-1][j-w[i]]+v[i],ans[i-1][j]);
        }
      }
    }
    
    System.out.print(ans[N-1][W]);
    
  }
}

Measured memory_bytes: 128212
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pii >
#define all(x) x.begin(), x.end()
#define M vector<VI >
 
const int P = 1e9+7;
 
using namespace std;
 
int rseed(){
	int seed = chrono::duration_cast<chrono::nanoseconds>(
	chrono::high_resolution_clock::now().time_since_epoch()).count();
	srand(seed);
	return seed;
}
 
const int SEED = rseed();
const int A = rand();
const int B = rand();
 
map<ll, VI > mp;
 
int main(){
 
	cin.tie(0);
	ios_base::sync_with_stdio(0);
 
	int n; cin >> n;
	vector<string> s(n);
 
	for(string &i : s){
		cin >> i;
		ll hsha = 0, hshb = 0;
		int j = i.size()-1;
		for(; j>0; j--){
			hsha = (A*hsha+i[j])%P;
			hshb = (B*hshb+i[j])%P;
		}
 
		ll thsh = hsha+(hshb<<32);
		if(mp[thsh].size() == 0) mp[thsh].resize(26, 0);
		
		mp[thsh][i[0]-97]++;
 
	}
 
	ll ans = 0;
	for(string i : s){
 
		int sz = i.size();
		VI c(26, 0);
		for(int j=0; j<sz; j++) c[i[j]-97]++;
 
		ll hsha=0, hshb=0;
		for(int j=sz-1; j>0; j--){
 
			ll thsh = hsha+(hshb<<32);
			
			VI x = mp[thsh];
			if(x.size()){
				for(int i=0; i<26; i++){
					if(c[i]) ans += x[i];
				}
			}
 
			c[i[j]-97]--;
			hsha = (A*hsha+i[j])%P;
			hshb = (B*hshb+i[j])%P;
		}
 
	}
 
	cout << ans << endl;
 
	return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD=1e9+7;

int main() {
    int N;
    bool c=1;
    cin >> N;
    vector<int> A(N);
    rep(i,N)
        cin >> A.at(i);
    sort(A.begin(), A.end());

    if(N%2) {
        if(A.at(0) != 0)
           c=0;
        else
            rep(i,N/2)
                if(A.at((i+1)*2-1)!=(i+1)*2 || A.at((i+1)*2)!=(i+1)*2) {
                    c = 0;
                    break;
                }
    } else {
        rep(i,N/2)
            if(A.at(i*2)!=i*2+1 || A.at(i*2+1)!=i*2+1) {
                c = 0;
                break;
            }
    }

    if(c) {
        ll r = 1;
        rep(i,N/2) {
            r *= 2;
            r %= MOD;
        }
        cout << r;
    } else
        cout << 0;
    cout << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, AC = 0, WA = 0, TLE = 0, RE = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		if(s[0] == 'A')
			++AC;
		else if(s[0] == 'W')
			++WA;
		else if(s[0] == 'T')
			++TLE;
		else
			++RE;
	}

	cout << "AC x " << AC << '\n';
	cout << "WA x " << WA << '\n';
	cout << "TLE x " << TLE << '\n';
	cout << "RE x " << RE << '\n';
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = false;
    if (s.at(0)=='7')
        ans =1;
    if (s.at(1)=='7')
        ans =1;
    if (s.at(2)=='7')
        ans =1;
    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}



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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	ll N, T, time = 0LL;
	
	cin >> N >> T;
	
	ll t[N];
	
	for(int i=0; i<N; i++)
		cin >> t[i];
	
	for(int i=0; i<N-1; i++)
		time += min(T, t[i+1] - t[i]);
	
	cout << time + T;
	
	return 0;
}

Measured memory_bytes: 1792
q = int(raw_input())
for i in range(q):
	n = raw_input()
	num = 0
	while 1:
		length = len(n) 
		if length == 1:
			break
		num += 1
		tmp = 0
		for i in range(1,length):
			tmp = max(tmp, int(n[:i])*int(n[i:]))
		n = str(tmp)
	print num

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

int main() {
  string s;
  cin >> s;
  
  if (s == "MON") {
    cout << 6 << endl;
  }
  else if (s == "TUE") {
    cout << 5 << endl;
  }
  else if (s == "WED") {
    cout << 4 << endl;
  }
  else if (s == "THU") {
    cout << 3 << endl;
  }
  else if (s == "FRI") {
    cout << 2 << endl;
  }
  else if (s == "SAT") {
    cout << 1 << endl;
  }
  else {
    cout << 7 << endl;
  }
}

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

int main() {

  string w;
  cin >> w;
  int count = 1;
  int ans = 0;
  sort(w.begin(), w.end());
  for(int i = 0; i < w.size()-1; i++){
    if(w.at(i) == w.at(i+1)){
      count++;
      if(i != w.size()-2){
      continue;
    }
    }
    if(count % 2 == 0){
      ans += count;
      count = 1;
    }
   count = 1;
  }
  if(ans == w.size()){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
using System;

public class ITP1_1_D
{
    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        var a = int.Parse(Console.ReadLine());

        Solve(a);
    }

    private static void Solve(int a)
    {
        var h = a / 3600;
        var m = (a - h * 3600) / 60;
        var s = a - h * 3600 - m * 60;

        Console.WriteLine("{0:d}:{1:d}:{2:d}", h, m, s);
    }
}



Measured memory_bytes: 17980
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main 
{
	static class C implements Comparator<Fud>
	{
		@Override
		public int compare(Fud o1, Fud o2) {
			return o1.a - o2.a;
		}
	}
	
	static class Fud
	{
		int a;
		int b;
		
		public Fud(int a0, int b0)
		{
			a = a0;
			b = b0;
		}
	}

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int t = sc.nextInt();
		
		long[] score = new long[t];
		long best = 0;
		Fud[] fud = new Fud[n];
		for(int i = 0; i < n; i++)
		{
			int a = sc.nextInt();
			int b = sc.nextInt();
			fud[i] = new Fud(a,b);
		}
		C c = new C();
		Arrays.sort(fud, c);
		
		for(int i = 0; i < n; i++)
		{
			
			//consider this as last
			for(int x = 0; x < t; x++)
			{
				best = Math.max(best, score[x] + fud[i].b);
//				System.out.println("take best " + score[x]);
			}
			
			
			long[] scorenew = new long[t];
			//consider this as non last
			for(int x = 0; x < t; x++)
			{
				if(x + fud[i].a < t)
				{
					scorenew[x+fud[i].a] = Math.max(score[x+fud[i].a], score[x] + fud[i].b);
				}
			}
			for(int x = 0; x < t; x++)
				score[x] = Math.max(score[x],scorenew[x]);
		}

		
		System.out.println(best);
	}

}


Measured memory_bytes: 48912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+7;
char s[N],t[N];
int m,len,ans,nxt[N],suf[N];
void getnxt(int *nxt,char *s)
{
	nxt[0]=-1;
	int i=0,j=-1,len=strlen(s);
	while(i<len)
	{
		if(j==-1||s[i]==s[j])nxt[++i]=++j;
		else j=nxt[j];
	}
}
int main()
{
	scanf("%s",s);
	len=strlen(s);
	for(int i=0;i<len;i++)t[i]=s[len-i-1];
	t[len]='\0';
	getnxt(nxt,s),getnxt(suf,t);
	if(!nxt[len]||len%(len-nxt[len]))m=1;else m=2;
	bool flag=1;
	for(int i=1;s[i];i++)if(s[i]!=s[i-1]){flag=0;break;}
	if(flag)m=len;
	if(m==1||m==len)ans=1;
	else{
		for(int i=0;i<len-1;i++)
		{
			int k=len-i-1;
			if((!nxt[i+1]||(i+1)%((i+1)-nxt[i+1]))&&(suf[k]==0||k%(k-suf[k])))ans++;
		}
	}	
	cout<<m<<endl<<ans<<endl;
}

Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define INF (1<<29)
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  int N,Y;
  bool flag = true;
  cin >> N >> Y;
  for(int i = 0; i <= N; i++){
    for(int j = 0; i+j <= N; j++){
      if(Y == 10000 * i + 5000 * j + 1000 * (N-(i+j))){
        cout << i <<" " << j << " " << N-(i+j) << endl;
        flag = false;
        break;
      }
    }
    if(flag == false) break;
  }
  if(flag){
    cout << -1 <<" " << -1 <<" " << -1 << endl;
  }
}

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

int main() {
  int a,b,sum=0;
  cin>>a>>b;
  vector<int> day(b);
  rep(i,b){
    cin>>day[i];
    sum+=day[i];
  }
  if(sum>a){
    cout<<-1<<endl;
  }
  else
    cout<<a-sum<<endl;
  
      
      
  
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  int w;
  string S;
  cin >> S;
  cin >> w;
  
  int len = S.size();
  for(int i = 0; i < (len + w - 1)/w; i++){
    cout << S.at(w * i);
  }
  cout << endl;
  
}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    __int128_t S = 1, F = 1000'000'000'000'000'000LL;
    vector<ll> A(N);
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(ALL(A));
    for(int i = 0; i < N; ++i) {
        __int128_t B = A[i];
        S *= B;
        corner(S > F,-1); 
    }
    ll C = S;
    cout << C << endl;
    return 0;
}


Measured memory_bytes: 4360
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
class Mat {
 public:
  explicit Mat(int row, int col) : row_(row), col_(col) {
    a_ = std::vector<std::vector<T>>(row, std::vector<T>(col, 0));
  }

  int row() const { return row_; }
  int col() const { return col_; }
  std::vector<T>& operator[](int row) {
    return a_[row];
  }

  Mat& operator=(const Mat &m) {
    a_ = m.a_;
    return *this;
  }

  Mat operator+(const Mat& m) const {
    Mat ret(row_, col_);
    for (int r = 0; r < row_; ++r) {
      for (int c = 0; c < col_; ++c) {
        ret[r][c] = a_[r][c] + m.a_[r][c];
      }
    }
    return ret;
  }

  Mat& operator+=(const Mat& m) {
    for (int r = 0; r < row_; ++r) {
      for (int c = 0; c < col_; ++c) {
        a_[r][c] += m.a_[r][c];
      }
    }
    return *this;
  }

  Mat operator-(const Mat& m) const {
    Mat ret(row_, col_);
    for (int r = 0; r < row_; ++r) {
      for (int c = 0; c < col_; ++c) {
        ret[r][c] = a_[r][c] - m.a_[r][c];
      }
    }
    return ret;
  }

  Mat& operator-=(const Mat& m) {
    for (int r = 0; r < row_; ++r) {
      for (int c = 0; c < col_; ++c) {
        a_[r][c] -= m.a_[r][c];
      }
    }
    return *this;
  }

  Mat operator*(const Mat& m) const {
    Mat ret(row_, col_);
    for (int r = 0; r < row_; ++r) {
      for (int c = 0; c < col_; ++c) {
        for (int k = 0; k < col_; ++k) {
          ret[r][c] += a_[r][k] * m.a_[k][c];
          ret[r][c] %= kMod;
        }
      }
    }
    return ret;
  }

  Mat& operator*=(const Mat& m) {
    *this = (*this) * m;
    return *this;
  }

  std::vector<T> operator*(const std::vector<T> &v) const {
    std::vector<T> ret(row_, 0);
    for (int r = 0; r < row_; ++r) {
      for (int k = 0; k < col_; ++k) {
        ret[r] += a_[r][k] * v[k];
      }
    }
    return ret;
  }

  void Display() {
    for (int r = 0; r < row_; ++r) {
      for (int c = 0; c < col_; ++c) {
        std::cout << a_[r][c] << " ";
      }
      std::cout << std::endl;
    }
  }

  private:
   std::vector<std::vector<T>> a_;
   int row_;
   int col_;
};

template<typename T>
Mat<T> pow(Mat<T> m, LL k) {
  int row = m.row();
  int col = m.col();

  Mat<T> ret(row, col);
  for (int r = 0; r < row; ++r) ret[r][r] = 1;

  LL i = 1;
  while (i <= k) {
    if (i & k) ret *= m;
    i <<= 1;
    m = m * m;
  }
  return ret;
}

int main() {
  LL N, K; cin >> N >> K;
  Mat<LL> m(N, N);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> m[i][j];
    }
  }

  auto m2 = pow(m, K);
  LL total = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      total = (total + m2[i][j]) % kMod;
    }
  }
  cout << total << endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
  string s;
  cin >> s;
  int q;
  cin >> q;

  bool flag = true;
  for (int i = 0; i < q; i++)
  {
    int t;
    cin >> t;
    if (t == 1)
      flag = !flag;
    if (t == 2)
    {
      int f;
      string c;
      cin >> f >> c;
      if (flag)
      {
        if (f == 1)
          s.insert(0, c);
        else
          s += c;
      }
      else
      {
        if (f == 1)
          s += c;
        else
          s.insert(0, c);
      }
    }
  }
  if (flag)
    cout << s << endl;
  else
  {
    reverse(s.begin(), s.end());
    cout << s << endl;
  }
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
int main(){
  int a,n,k,q;cin>>n>>k>>q;
  int o[n];
  rep(i,n)o[i]=0;
  
  rep(i,q){
    cin>>a;
    o[a-1]++;
  }
  
  rep(i,n){
    cout<<(k-q+o[i]>0?"Yes":"No")<<endl;
  }

}

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

const static int MAX = 100000;

std::vector<int> T[MAX];
int parent[MAX], D[MAX];
int N, height;

void setDepth(int node, int d) {
    D[node] = d;
    for (unsigned long i = 0; i < T[node].size(); i++) {
        setDepth(T[node][i], d+1);
    }
}

int main()
{
    std::scanf("%d", &N);
    int node, deg, ch, root = 0;
    for (int i = 0; i < N; i++) {
        parent[i] = -1;
        D[i] = 0;
    }
    for (int i = 0; i < N; i++) {
        std::scanf("%d %d", &node, &deg);
        for (int j = 0; j < deg; j++) {
            std::scanf("%d", &ch);
            parent[ch] = node;
            T[node].push_back(ch);
        }
    }

    for (int i = 0; i < N; i++) {
        if (parent[i] == -1) {
            root = i;
            break;
        }
    }

    setDepth(root, 0);
    for (int i = 0; i < N; i++) {
        std::printf("node %d: parent = %d, depth = %d, ", i, parent[i], D[i]);
        if (i == root) std::printf("root, [");
        else if (T[i].size() == 0) std::printf("leaf, [");
        else std::printf("internal node, [");
        for (int j = 0; j < T[i].size(); j++) {
            if (j) std::printf(", ");
            std::printf("%d", T[i][j]);
        }
        std::printf("]\n");
    }


    return 0;
}



Measured memory_bytes: 7004
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Stack;


class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		while(in.hasNext()){
			int n = in.nextInt();
			if(n == 0) return;
			for(int i = 0; i < n; i++){
				int pm = in.nextInt(), pe = in.nextInt(), pj = in.nextInt();
				if(pm == 100 || pe == 100 || pj == 100) System.out.println("A");
				else if((pm + pe) / 2 >= 90) System.out.println("A");
				else if((pm + pe + pj) / 3 >= 80) System.out.println("A");
				else if((pm + pe + pj) / 3 >= 70) System.out.println("B");
				else if((pm + pe + pj) / 3 >= 50 && Math.max(pm, pe) >= 80) System.out.println("B");
				else System.out.println("C");
			}
		}
	}

	

}

Measured memory_bytes: 39376
#include <iostream>
using namespace std;
const int MAX = 100001;  
 //数据结构
struct node{
	string name;
	int time;
}A[MAX];
int head, tail; //队头和队尾指针
int n, q;

//向队列添加新元素
void enqueue(node x)
{
    A[tail] = x;
    tail = (tail + 1) % MAX;
}
node dequeue()
{
    node t = A[head];
    head = (head + 1) % MAX;
    return t;
}

void solve()
{
	int sum = 0;
	while(head != tail){
		node t = dequeue();
		if(t.time > q){
			sum += q;
			t.time -= q;
			enqueue(t);
		}
		else{
			sum += t.time;
			cout << t.name << " " << sum << endl;
		}
	}
}
int main()
{
	cin >> n >> q;
	for(int i = 1; i <= n; i++){
		cin >> A[i].name >> A[i].time;
	}
	head = 1; tail = n + 1;
	solve();
	return 0;
} 


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

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long n = sc.nextLong();

      long i = 1;
      while(i * i <= n) {
          i++;
          
      }
      i--;

      System.out.println(i * i);
  }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const int limit = 50;
int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
  visited[v] = true;
  REP(v2,n) {
    if (graph[v][v2] == false) continue;
    if (visited[v2] == true) continue;
    dfs(v2);
  }
}

int main () {
  cin >> n >> m;
  REP(i,m) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

  int ans = 0;

  REP(i,m) {
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

    REP(j,n) visited[j] = false;

    dfs(0);

    bool bridge = false;
    REP(j,n) {
      if (visited[j] == false) bridge = true;
    }

    if (bridge) ans++;

    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

  cout << ans << endl;
  return 0;
}

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

using namespace std;
int n, d[N][N+N+5];
double A[N], F[N][N+N+5];

double Magic(int i, int diff)
{
    if(i>n) return diff>0;
    if(d[i][diff+3000]) return F[i][diff+3000]; d[i][diff+3000]=1;
    return F[i][diff+3000] = A[i]*Magic(i+1, diff+1)+(1.0-A[i])*Magic(i+1, diff-1);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(10);
    cin>>n;
    for(int i=1; i<=n; i++) cin>>A[i];
    cout<<Magic(1, 0);
    return 0;
}


Measured memory_bytes: 131800
using System;
using System.Collections.Generic;

class Program
{
  static int _value = 0;
  static void Main()
  {
    var line = Console.ReadLine();
    var _line = line.Split(" ");
    int n = int.Parse(_line[0]);
    int k = int.Parse(_line[1]);
    int[] p = new int[n];
    line = Console.ReadLine();
    _line = line.Split(" ");
    for (int i = 0; i < n; i++)
    {
      p[i] = int.Parse(_line[i]);
    }
    Array.Sort(p);
    for (int i = 0; i< k;i++)
    {
      _value += p[i];
    }
    Console.WriteLine(_value);
  }
}

Measured memory_bytes: 27756
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] a = new int[n];
    String ans = "YES";

    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }

    Arrays.sort(a);

    for(int i = 1; i < n; i++){
      if(a[i] == a[i - 1]){
        ans = "NO";
        break;
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 64016
#![allow(unused_imports, non_snake_case, dead_code)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

const MODULO: u64 = 1_000_000_007;

struct Combination {
    MOD: u64,
    size: usize,
    fact: Vec<u64>,
    inv_fact: Vec<u64>,
}
impl Combination {
    fn new(size: usize, MOD: u64) -> Self {
        let mut fact = vec![1; size + 1];
        let mut inv_fact = vec![1; size + 1];
        for i in 1..size + 1 {
            fact[i] = fact[i - 1] * i as u64 % MOD;
        }
        inv_fact[size] = Self::modpow(fact[size], MOD - 2, MOD);
        for i in (1..size + 1).rev() {
            inv_fact[i - 1] = inv_fact[i] * i as u64 % MOD;
        }
        Combination {
            MOD,
            size,
            fact,
            inv_fact,
        }
    }
    fn modpow(mut x: u64, mut y: u64, m: u64) -> u64 {
        let mut res: u64 = 1;
        while y > 0 {
            if y & 1 > 0 {
                res = res * x % m;
            }
            x = x * x % m;
            y >>= 1;
        }
        res
    }
    fn modinv(x: u64, m: u64) -> u64 {
        Self::modpow(x, m - 2, m)
    }
    fn nPr(&self, n: usize, r: usize) -> u64 {
        if n < r {
            return 0;
        };
        self.fact[n] * self.inv_fact[n - r] % self.MOD
    }
    fn nCr(&self, n: usize, r: usize) -> u64 {
        if n < r {
            return 0;
        };
        self.fact[n] * self.inv_fact[r] % self.MOD * self.inv_fact[n - r] % self.MOD
    }
}

#[fastout]
fn main() {
    input!{
        N: usize
    }
    let ncr = Combination::new(N * 2, MODULO);
    let mut ans = 0;
    for i in 1..N/3+1 {
        ans = (ans + ncr.nCr(N-i*3+i-1, i-1)) % MODULO;
    }
    println!("{}", ans);

}


Measured memory_bytes: 2180
H, W, A, B = map(int, input().split())

def print_masu(masu):
    for h in masu:
        for w in h:
            print(w, end='')
        print()

masu = [[0] * W for _ in range(H)]

for i, h in enumerate(range(H)):
    for j, w in enumerate(range(W)):
        if i < B and j < A or i >= B and j >= A:
            masu[h][w] = 1

print_masu(masu)

Measured memory_bytes: 14708
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <cstdlib> //絶対値整数abs
#include <cmath>   //絶対値少数fbs
#include <math.h>
using namespace std;
#define rep(i, N) for (ll i = 0; i < (N); i++)
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<ll> a(M);
    rep(i, M) cin >> a.at(i);
    ll sum = 0;
    rep(i, M) sum += a.at(i);
    if (sum > N)
    {
        cout << -1 << endl;
        return 0;
    }
    else
    {
        cout << N - sum << endl;
        return 0;
    }
}

Measured memory_bytes: 3720
N = gets.to_i
A = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7
RUI = [0]

A.each do |a|
  RUI << RUI.last + a
end

ans = 0

A[0..-2].each_with_index do |a, idx|
  ans += a * (RUI.last - RUI[idx + 1])
  ans %= MOD
end

puts ans


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long int
#define pb push_back
#define all(a) a.begin(),a.end()

bool func(pair<int,int> a, pair<int,int> b){
	return ((a.second<b.second) || (a.second==b.second) && (a.first<b.first));
}

signed main(){
	IOS;
	int n;
	cin>>n;
	vector<pair<int,int> > v;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		v.pb(make_pair(a,b));
	}
	sort(v.begin(),v.end(),func);
	int t=0;
	for(int i=0;i<n;i++){
		t+=v[i].first;
		if(t>v[i].second){
			cout<<"No";
			return 0;
		}
		// cout<<v[i].first<<" "<<v[i].second<<endl;
	}
	cout<<"Yes";
}

Measured memory_bytes: 6128
n, m = map(int, input().split())
a = list(map(lambda x:int(x) // 2, input().split()))

a = sorted(list(set(a)))

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

if len(a) == 1:
    ans = m // a[0]
    print(ans - ans // 2)
    exit()

temp = lcm(a[0], a[1])
if (temp // a[0]) % 2 == 0 or (temp // a[1]) % 2 == 0:
    print(0)
    exit()

for y in a[2:]:
    temp = lcm(temp, y)
    if (temp // y) % 2 == 0 or temp > m:
        print(0)
        exit()

ans = m // temp
print(ans - ans // 2)

Measured memory_bytes: 64112
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
int main()
{
	dhoom;
	int n;
	cin >> n;
	int x = n;
	int sum = 0;
	while( x != 0){
		sum += (x%10);
		x/=10;
	}
	if(n%sum == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
int main() {
    int n; cin >> n;
    vector<ll> a(n+1), b(n);
    rep(i, n+1) cin >> a.at(i);
    rep(i, n) cin >> b.at(i);
    ll sum = 0;
    rep(i, n){
        sum += min(a.at(i), b.at(i));
        b.at(i) -= min(a.at(i), b.at(i));
        sum += min(a.at(i+1),b.at(i));
        a.at(i+1) -= min(a.at(i+1), b.at(i));
    }
    cout << sum << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  vector<int> b(9);
  vector<bool> a(9,false);
  int n,c;
  rep(i,9) cin >> b.at(i);
  cin >> n;
  rep(i,n){
    cin >> c;
    rep(j,9){
      if(b.at(j)==c) a.at(j)=true;
    }
  }
  bool ans = false;
  rep(i,3){
    if(a.at(i*3) && a.at(i*3+1) && a.at(i*3+2)) ans=true;
    if(a.at(i) && a.at(i+3) && a.at(i+6)) ans=true;
  }
  if(a.at(0) && a.at(4) && a.at(8)) ans=true;
  if(a.at(2) && a.at(4) && a.at(6)) ans=true;
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main() {
    int N;
    scanf("%d", &N);
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &d.at(i));
    }
    sort(d.begin(), d.end());
    int diameter = d.at(0);
    int hight = 1;
    for (int i = 1; i < N; i++) {
        if (d.at(i) > diameter) {
            hight++;
            diameter = d.at(i);
        }
    }
    printf("%d", hight);
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main(){
	string s,t;
	int s1=0,i;
	cin>>s>>t;
	for(i=0;i<s.size();i++){
		if(s[i]!=t[i]) s1++;
	} 
	cout<<s1;
	return 0;
}

Measured memory_bytes: 3848
// abc108_a
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;

int main(void){
  int K;
  cin >> K;
  vector<int> even;
  vector<int> odd;

  for (int i = 1; i <= K; i++) {
	  if (i % 2 == 0) {
		  even.push_back(i);
	  }
	  else {
		  odd.push_back(i);
	  }
  }
  cout << even.size() * odd.size() << endl;

  return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    vector<int> a(n + 1), ans(n + 1);
    FOR(i, 1, n + 1) cin >> a[i];

    for (int i = n; i > 0; i--) {
        int s = 0;
        for (int k = 2 * i; k <= n; k += i) s += ans[k];
        if (s % 2 != a[i]) ans[i] = 1;
    }
    vector<int> v;
    for (int i = 1; i <= n; i++) {
        if (ans[i] == 1) v.push_back(i);
    }
    cout << v.size() << endl;
    for (auto e: v) cout << e << " ";
    cout << endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')
	{
		cout<<s<<"es";
		return 0;
	}
	else
	{
		cout<<s<<"s";
	}
	return 0;
}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var T = sc.ReadInt();
        var A = sc.ReadInt();
        var H = sc.ReadIntArray(N);
        var ans = 0;
        var anst = double.MaxValue;
        for (int i = 0; i < N; i++)
        {
            var t = T - H[i] * 0.006;
            if (anst >= Math.Abs(A - t))
            {
                ans = i;
                anst = Math.Abs(A - t);
            }
        }
        Console.WriteLine(ans + 1);
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 13140
s = list(input())
len_list = []
ans_list = []
count = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        count += 1
    else:
        len_list.append(count)
        count = 1
len_list.append(count)
for i in range(0,len(len_list),2):
    a = (len_list[i]+1)//2 + len_list[i+1] // 2
    b = (len_list[i+1]+1)//2 + len_list[i] // 2
    for j in range(len_list[i]-1):
        ans_list.append(0)
    ans_list.append(a)
    ans_list.append(b)
    for j in range(len_list[i+1]-1):
        ans_list.append(0)
print(*ans_list)


Measured memory_bytes: 7844
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/* func */
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
 
//#define int ll
//#define int long long
 
int main(){
   string n; cin>>n;
   int ans=0;
   int i=0;

  for(i=1;n[i]=='0' || n[i]=='\0' ;i++){
    if(n[i]=='\0'&&n[0]=='1'){
      cout<<10;
      return 0;
    }
  }
  
   for(i=0;i<n.size();i++){
     ans+=(n[i]-'0');
   }
   cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int a[200000], b[200000],c[200000];
int main() {
	queue<int>q;
	int n; cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(j, 29) {
		int m = 1 << j; int d = m << 1;
		rep(i, n) {
			c[i] = b[i] % d;
		}
		sort(c, c + n);
		int sum = 0;
		rep(i, n) {
			int x = a[i] % d;
			x = m - x;
			if (x > 0) {
				int le = lower_bound(c, c + n, x) - c;
				int ri = lower_bound(c, c + n, x + m) - c;
				sum += ri - le;
			}
			else {
				int le = lower_bound(c, c + n, x + d) - c;
				int ri = lower_bound(c, c + n, x + m) - c;
				ri += n;
				sum += ri - le;
			}
			sum %= 2;
		}
		if (sum)q.push(j);
	}
	int out = 0;
	while (!q.empty()) {
		int x = q.front(); q.pop();
		out += (1 << x);
	}
	cout << out << endl;
	stop
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h){
    cin >> s[i];
  }
  int ans=0;
  for (int bith = 0; bith < (1<<h); ++bith)
  {
    for (int bitw = 0; bitw < (1<<w); ++bitw){
      int sum=0;
      rep(i, h){
        rep(j, w){
          if((bith >> i) & 1==1 && (bitw >> j) & 1==1 && s[i][j]=='#'){
            sum++;
          }
        }
      }
      if(sum==k){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define reint register int
#define coint const int

using namespace std;

typedef long long ll;

coint SIZE = 200000 + 5;

int li[SIZE], ans[SIZE];

inline int getint(void) {
    reint x = 0, ch = getchar();
    for (; ch < '0' || ch > '9'; ch = getchar());
    for (; ch >= '0' && ch <= '9';
        x = (x << 1) + (x << 3) + (ch - '0'), ch = getchar());
    return x;
}

int main(void) {
    coint n = getint();
    for (reint i = 1; i <= n; ++i) li[i] = getint();

    int cnt = 0;
    for (reint i = n; i; --i) {
        ll sum = 0;
        for (reint j = i; j <= n; j += i) sum += ans[j];
        coint tmp = ((sum & 1) ^ li[i]);
        ans[i] = tmp;
        cnt += ans[i];
    }

    printf("%d\n", cnt);
    int tcnt = 0;
    for (reint i = 1; i <= n; ++i)
        if (ans[i]) printf("%d%c", i, " \n"[++tcnt == cnt]);

    return 0;
}



Measured memory_bytes: 2432
#include <stdio.h>

int main(){
    int A,B;
    
    scanf("%d %d",&A,&B);
    
    if((A>0 && A<10)&&(B>0 && B<10) ){
        printf("%d\n",A*B);
    }
    else{
        printf("-1\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-04 15:44:42 +0900
# LastModified: 2020-09-13 16:06:20 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    A = list(map(int, input().split()))
    A_4 = [x for x in A if x % 4 == 0]
    A_2 = [x for x in A if x % 4 != 0 and x % 2 == 0]
    A_0 = [x for x in A if x % 2 != 0]
    if len(A_2) == 0 and len(A_0) <= len(A_4) + 1:
        print("Yes")
    elif len(A_0) <= len(A_4):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 19984
#include<cstdio>
#include<cstring>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
const int INF=10000000;
typedef struct N
{
	int x,y,c,p;
}N;

struct Order
{
	bool operator ()(N const& a, N const& b) const
	{
		return a.c>b.c;
	}
};


typedef pair<int,int> P;
int X,Y,nx[6]={0,2,3,4,5,1},a,b,mc[6][1005];
vector<P> M[9];//y x

int dis(N a,P b)
{
	return abs(a.y-b.first)+abs(a.x-b.second);
}

int f(int p)
{
	N tmp={M[0][0].second,M[0][0].first,0,p};
	priority_queue<N,vector<N>,Order>Q;
	for(int i=0;i<6;i++)
		for(int j=0;j<M[i].size();j++)
			mc[i][j]=INF;
	Q.push(tmp);
	while(!Q.empty())
	{
		tmp=Q.top();Q.pop();
		if(tmp.p==6)
			break;
		if(nx[tmp.p]==p)
		{
			N ins={M[6][0].second,M[6][0].first,tmp.c+dis(tmp,M[6][0]),6};
			Q.push(ins);
		}
		int np=nx[tmp.p];
		for(int i=0;i<M[np].size();i++)
		{
			if(mc[np][i]>tmp.c+dis(tmp,M[np][i]))
			{
				mc[np][i]=tmp.c+dis(tmp,M[np][i]);
				N ins={M[np][i].second,M[np][i].first,mc[np][i],np};
				Q.push(ins);
			}
		}
	}
	if(tmp.p!=6)return -1;
	return tmp.c;
}

int main()
{
	for(;scanf("%d%d\n",&X,&Y),X;)
	{
		for(int i=0;i<9;i++)M[i].clear();
		for(int i=0;i<Y;i++)
			for(int j=0;j<=X;j++)
			{
				char c;
				c=getchar();
				if(c=='S')M[0].push_back(make_pair(i,j));
				if(48<c&&c<54)M[c-'0'].push_back(make_pair(i,j));
				if(c=='G')M[6].push_back(make_pair(i,j));
			}
		a=INF;
		for(int i=1;i<6;i++)
		{
			int t=f(i);
			if(t!=-1&&a>t)
			{
				a=t;b=i;
			}
		}
		if(a==INF)puts("NA");
		else printf("%d %d\n",b,a);
	}
	return 0;
}

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

namespace ABC122A
{
    class Program
    {
        static void Main(string[] args)
        {
            string b = Console.ReadLine();
            if (b == "A")
            {
                Console.WriteLine("T");
            }
            else if (b == "T")
            {
                Console.WriteLine("A");
            }
            else if (b == "G")
            {
                Console.WriteLine("C");
            }
            else
            {
                Console.WriteLine("G");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int K,X;
  cin >> K>> X;
  if (K*500 >=X){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main (){
  int n;
  cin >>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >>a[i];
  int minimum=a[0];
  int maximum=a[0];
  long long sum=0;
  for (int i=0;i<n;i++){
    minimum=min(minimum,a[i]);
    maximum=max(maximum,a[i]);
    sum+=a[i];
  }
  cout<<minimum<<" "<<maximum<<" "<<sum<<endl;
}


Measured memory_bytes: 3112
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

		int x = sc.nextInt();
		int n = sc.nextInt();
		if (n == 0) {
			System.out.println(x);
			return;
		}
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		sc.close();

		Integer underPos = null;
		Integer upwardPos = null;

		// 下方向探索
		int startPos = x;
		while (underPos == null) {
			if (p.contains(startPos) != true) {
				underPos = startPos;
			}
			startPos--;
		}
		// 上方向探索
		startPos = x;
		while (upwardPos == null) {
			if (p.contains(startPos) != true) {
				upwardPos = startPos;
			}
			startPos++;
		}
		// 差分を出す
		int underDist = Math.abs(x - underPos);
		int upwardDist = Math.abs(x - upwardPos);
		if (underDist == upwardDist) {
			System.out.println(underPos);
			return;
		}

		if (underDist < upwardDist) {
			System.out.println(underPos);
		} else {
			System.out.println(upwardPos);
		}

	}
}


Measured memory_bytes: 27192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;
const int maxbit = 60;
const ll mod = 1e9 + 7;

ll gcd(ll a,ll b){
    if(a == 0 && b == 0) return 0;
    else if(a == 0|| b == 0) return 1;
    else{
        if(a < 0) a = -a;
        if(b < 0) b = -b;
        if(a < b) swap(a,b);
        while(true){
            ll p = a % b;
            a = b;
            b = p;
            if(p == 0)break;
        }
        return a;
    }
}

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n){
        if(n % 2){
            ans = ans * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return ans;
}

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
    int N; cin >> N ;
    vector<ll> A(N);
    vector<ll> bit(maxbit);
    REP(i,N){
        ll a;
        cin>>a;
        A[i] = a;
        REP(k,maxbit){
            if(((a >> k) & 1))bit[k]++;
        }
    }
    ll ans = 0;
    REP(i,maxbit){
        //cout << bit[i] << endl;
        ll now = (bit[i] * (N - bit[i]) ) % mod;
        ans += now * mpow(2,i);
        ans %= mod;
    }

    cout << ans << endl;
}



Measured memory_bytes: 5548
#include <iostream>

using namespace std;

int cnt, n, s;

void dfs(int num, int d, int sum) {
    if (d == n) {
        if (sum == s) {
            cnt++;
        }
        return;
    }
    if (num == 10) {
        return;
    }
    
    dfs(num + 1, d, sum);
    dfs(num + 1, d + 1, sum + num);
}

int main() {
    while (1) {
        cin >> n >> s;
        if (n == 0) {
            break;
        }
        cnt = 0;
        dfs(0, 0, 0);
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1160