akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factorial(int n){
  if(n == 0) return 1;
  return n*factorial(n-1);
}

int divisor(int a){
  int cnt = 0;
  for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
  return cnt;
}

int comb(int n, int k){
  return factorial(n) / (factorial(n-k)*factorial(k));
}

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}






int main(){
  int N;
  cin >> N;
  cout << (N-1)/2 << endl;
  
  return 0;
}









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

int main() {
  int n, count = 0;
  string s;
  cin >> n >> s;
  
  for (int i = 0; i < n - 2; i++){
    if (s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C'){
      count++;
    }
  }
  cout << count << endl;
} 

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf

#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)

#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()

#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))

#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >

#define endl "\n";
#define line puts("-------");
#define dbb(x) cout<<#x<<" : "<<x<<"\n";

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

template<typename T, typename V> void __print(const pair<T, V> &x)
{cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T> void __print(const queue<T> &x)
{queue<T>temp=x;cerr<<"\n-----\n";while(!temp.empty())
{cerr << temp.front() << endl;temp.pop();}cerr<<"-----\n";}
template<typename T> void __print(const stack<T> &x)
{stack<T>temp=x;cerr<<"\n-----\n";while(!temp.empty())
{cerr << temp.top() << endl;temp.pop();}cerr<<"-----\n";}
template<typename T> void __print(const T &x)
{int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v)
{__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
    #define db(x...) cerr << "[" << #x << "] = [", _print(x)
#endif
using ll = long long;
const int N = 100005;
const int MOD = 1000000007;

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt","w",stdout);
    #endif
    int i,n,k;
    vector<int>vec;
    rep0(i,5)
    {
        sf(k);
        vec.pb(k);
    }
    rep0(i,5)
    {
        if(vec[i]==0)
        {
            cout<<i+1;
            return 0;
        }
    }
}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	const double EPS=1e-10;
	double x=0,y=0;
	double dir=M_PI/2;
	for(int a,d;scanf("%d,%d",&a,&d),a|d;){
		x+=a*cos(dir);
		y+=a*sin(dir);
		dir-=d*M_PI/180;
	}
	printf("%d\n%d\n",int(x+EPS),int(y+EPS));
	
	return 0;
}

Measured memory_bytes: 0
def main():
    L, R = (int(x) for x in input().split())
    if R - L > 2018:
        print(0)
    else:
        ans = 2018
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % 2019)
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

  vector<bool> dir(4, false);
  for (auto c : S) {
    if (c == 'N') dir[0] = true;
    if (c == 'S') dir[1] = true;
    if (c == 'W') dir[2] = true;
    if (c == 'E') dir[3] = true;
  }

  if (!(dir[0] ^ dir[1]) && !(dir[2] ^ dir[3]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define len(v) ((int)v.size())
#define fa(a,c) for(auto &a:c)
#define endl '\n'


vector<vector<int>> pt;

ll sqr(ll a){
  return a*a;
} 

bool check(vector<int> &a, vector<int> &b, int d){
  ll sum=0;
  for(int i=0;i<d;i++){
    sum+= sqr(a[i]-b[i]);
  }

  ll ss = sqrt(sum);
  return ss*ss==sum;

}

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

  int n,d;
  cin>>n>>d;
  for(int i=0;i<n;i++){
    vector<int> p(d);
    fa(a,p)cin>>a;
    pt.pb(p);
  }

  int ans = 0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      ans+= check(pt[i],pt[j],d);
    }
  } 

  cout<<ans<<endl;

}


Measured memory_bytes: 892
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> row;
typedef vector<row> matrix;
typedef pair<double, double> point;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };

void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	fast();
	string str; cin >> str;
	sort(all(str));
	if (str[0] != str.back())
		cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;
    if(A*B%2==0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> d;
vector<int> f;
vector<bool> used;
vector< vector<int> > v;
int n;
int cnt = 0;

class myqueue{
  public:
  int size;
  int begin;
  int end;
  int v[111111];
  myqueue(){
    size = 111111;
    begin = 0;
    end = 0;      //[begin, end)
  }

  void push(int a){
    v[end] = a;
    end = (end + 1) % size;
  }
  int front(){
    return v[begin];
  }
  void pop(){
    begin = (begin + 1) % size;
  }
  bool isEmpty(){
    return begin == end;
  }
};

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

  cin >> n;
  d = f = vector<int>(n, -1);
  used = vector<bool>(n, false);
  v = vector< vector<int> >(n, vector<int>(n, 0));
  for(int i = 0; i < n; i++){
    int u, k; cin >> u >> k;
    u--;
    for(int j = 0; j < k; j++){
      int a; cin >> a;
      a--;
      v[u][a] = 1;
    }
  }

  myqueue que;
  que.push(0);
  d[0] = cnt;
  used[0] = true;
  while(!que.isEmpty()){
    cnt++;
    int q = que.front(); que.pop();
    for(int i = 0; i < n; i++){
      if(v[q][i] && !used[i]){
        used[i] = true;
        que.push(i);
        d[i] = d[q]+1;
      }
    }
  }

  for(int i = 0; i < n; i++){
    cout << i+1 << " " << d[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1312
#include <iostream>

int main() {
  int e, y;

  std::cin >> e >> y;

  if (false) {
  } else if (e == 0 && y <= 1911) {
    std::cout << "M" << y - 1868 + 1 << std::endl;
  } else if (e == 0 && y <= 1925) {
    std::cout << "T" << y - 1912 + 1 << std::endl;
  } else if (e == 0 && y <= 1988) {
    std::cout << "S" << y - 1926 + 1 << std::endl;
  } else if (e == 0 && y <= 2016) {
    std::cout << "H" << y - 1989 + 1 << std::endl;
  } else if (e == 1) {
    std::cout << 1868 + y - 1 << std::endl;
  } else if (e == 2) {
    std::cout << 1912 + y - 1 << std::endl;
  } else if (e == 3) {
    std::cout << 1926 + y - 1 << std::endl;
  } else if (e == 4) {
    std::cout << 1989 + y - 1 << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





int main(){
  string S,T;
  cin>>S>>T;
  bool ok=false;
  for(int i=0;i<S.size();i++){
    for(int j=0;j<S.size();j++){
      if(i+j<S.size()){
        if(S.at(i+j)!=T.at(j)){
          break;

        }
      }else{
        if(S.at(i+j-S.size())!=T.at(j)){
          break;

        }

      }
      if(j==S.size()-1){
        ok=true;
      }

    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }




}


  
  

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

int main()
{
  long long int n,k;
  cin>>n>>k;

  long long int h[n],dp[n],i,mi,temp=1,ans;
  mi=(1LL<<40LL);

  for(i=0;i<n;i++)
    cin>>h[i];

  dp[0]=0;

  for(i=1;i<n;i++)
  {
    while(temp<=k && (i-temp)>=0)
    {
      ans=dp[i-temp]+abs(h[i]-h[i-temp]);
      mi=min(mi,ans);
      temp++;
    }
    dp[i]=mi;
    mi=(1LL<<40LL);
    temp=1;
  }

  cout<<dp[n-1]<<endl;

return 0;
}


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

int func( int n ){
    if(n % 2 == 0){
    	return n / 2;
    }else{
    	return 3 * n + 1;
    }
}


int f(int s, int n){
	int fn = s;

	if(n == 0){
		return fn;
	}else{
		for(int i = 0; i < n; ++i){
			fn = func(fn);
		}
		return fn;
	}
}

int main() {
    int s;
    int A[100000] = {0};
    int m = 1000000;
    int i = 0;
    cin >> s;

    while(true){
    	int x = f(s, i);
 //   	cout << i << endl;
  //  	cout << x << endl;
    	if(A[x] == 1){
    		m = i;
    		break;
    	}else{
    		A[x] = 1;
    	}
    	i = i + 1;
    }

    cout << m+1 << endl;
}

Measured memory_bytes: 640
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)] 

# print(a)

score=[0]*n
for i in a:
    score[i-1]+=1
# print(score)

for j in range(len(score)):
    if int(score[j])>=q-k+1:
        score[j]='Yes'
    else:
        score[j]='No'

L=[str(a) for a in score]
L="\n".join(L)
print(L)

Measured memory_bytes: 8992
#include <iostream>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

static const int N = 100;
static const int WHITE = 0;
static const int GREY = 1;
static const int BLACK = 2;

int n, m[N][N], color[N], nxtNei[N];
int t, t1[N], t2[N];

int nxt(int u){
	for (int v = nxtNei[u]; v < n; ++v) {
		nxtNei[u] = v + 1;
		if (color[v] == WHITE && m[u][v] == 1) {
			return v;
		}
	}
	return -1;
}

void dfs(int r){
	//for (int i = 0; i < n; ++i) nxtNei[i] = 0;
	stack<int> s;
	color[r] = GREY;
	s.push(r);
	t1[r] = t++;
	while (!s.empty()) {
		int u = s.top();
		int v = nxt(u);
		if (-1 == v){
			color[u] = BLACK;
			s.pop();
			t2[u] = t++;
			continue;
		}

		color[v] = GREY;
		s.push(v);
		t1[v] = t++;
	}
}

void search(){
	t = 1;
	for (int i = 0; i < n; ++i){
		color[i] = WHITE;
		nxtNei[i] = 0;
	}
	for (int i = 0; i < n; ++i) {
		if (color[i] == WHITE) dfs(i);
	}
	for (int i = 0; i < n; ++i){
		cout << i + 1 << " " << t1[i] << " " << t2[i] << endl;
	}
}


int main()
{
	cin >> n;

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) m[i][j] = 0;
	}

	for (int i = 0; i < n; ++i) {
		int u, d; cin >> u >> d;
		for (int j = 0; j < d; ++j) {
			int v; cin >> v;
			m[u - 1][v - 1] = 1;
		}
	}

	search();

	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <unordered_map>
#include <algorithm>
#include <iomanip>

using namespace std;

vector<int> parent;

int find(int n) {
	int p = parent[n];
	return p == n ? p : parent[n] = find(p);
}

void unite(int x, int y) {
	int xx = find(x);
	int yy = find(y);
	if(xx != yy) parent[xx] = yy;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m, ans = 0;

	cin >> n >> m;
	parent.resize(n);

	for (int i = 0; i < n; ++i) parent[i] = i;

	for (int i = 0; i < m; ++i) {
		int x, y, z;
		cin >> x >> y >> z;
		unite(x - 1, y - 1);
	}
	
	for (int i = 0; i < n; ++i) {
		if (i == find(i)) ++ans;
	}

	cout << ans << endl;

	
	return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int n;
    cin >> n;
    map<string, LL> ans;
    rep(i, n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        ans[s]++;
    }
    LL sum = 0;
    for (auto e : ans) {
        LL tmp = e.second * (e.second - 1) / 2;
        sum += tmp;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 8064
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main() {
	int n,m,r;
	cin >> n >> m >> r;
	int inf = 100000 * 200 * 10;
	vector<vector<int>> route(n, vector<int>(n, inf));

	vector<int> towns;
	for (int i = 0; i < r; ++i) {
		int ri;
		cin >> ri;
		ri--;
		towns.push_back(ri);
	}
	sort(towns.begin(), towns.end());

	for (int i = 0; i < m; ++i) {
		int ai, bi, ci;
		cin >> ai >> bi >> ci;
		ai--; bi--;
		route[ai][bi] = route[bi][ai] = ci;
	}
	for (int k = 0; k < n; ++k) {
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if (route[i][j] > route[i][k] + route[k][j]) {
					route[i][j] = route[j][i] = route[i][k] + route[k][j];
				}
			}
		}
	}

	int minval = inf;
	do {
		int sum = 0;
		for (int i = 0; i+1 < towns.size(); ++i) {
			sum += route[towns[i]][towns[i + 1]];
		}
		minval = min(sum, minval);
	} while (next_permutation(towns.begin(), towns.end()));
	cout << minval << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  int R[n];

  for ( int i = 0; i < n; i++ ) scanf("%d", &R[i]);

  int maxv = -2000000000; //十分小さい値を初期値に設定
  int minv = R[0];
  
  for ( int i = 1; i < n; i++ ) { //ここで毎回R[i]を読み込めば、配列は不要
    maxv = maxv < (R[i] - minv) ?  R[i] - minv : maxv; //最大値を更新
    minv = minv > R[i] ? R[i] : minv;        //ここまでの最小値を保持しておく
  }
  
  printf("%d\n", maxv);
  return 0;
}


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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    int a =0;
    int c =0;
    while (A>0){
        A -= D;
        a++;
    }
    while (C>0){
        C -= B;
        c++;
    }
    //cout << a << c << endl;
    if((a+1)<=c) cout << "No" << endl;
    else cout << "Yes" << endl;

    
}

Measured memory_bytes: 3596
// Problem : C - H and V
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_c
// Memory Limit : 1024 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n,m,k;
    cin>>n>>m>>k;
    string s[n];
    for(int i=0;i<n;i++) cin>>s[i];
    int cnt = 0;
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<(1<<m);j++){
            int cur = 0;
            for(int a=0;a<n;a++){
                for(int b=0;b<m;b++){
                    if((i>>a)&1 || (j>>b)&1) continue;
                    if(s[a][b] == '#') cur++;
                }
            }
            if(cur == k) cnt++;
        }
    }
    cout<<cnt<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int n2[100001];
int main() {
	int n, k;
	int cnt = 0, cnt_max = -10001;
	while (1) {
		cin >> n >> k;
		if (n == 0 && k == 0)return 0;
		for (int i = 1; i <= n; i++) {
			cin >> n2[i];
		}
		for (int i = 1; i <= n - k + 1; i++) {
			cnt = n2[i];
			for (int j = 1; j < k; j++) {
				cnt += n2[i + j];
			}
			if (cnt_max < cnt) {
				cnt_max = cnt;
			}
		}
		cout << cnt_max << endl;
		cnt_max = 0;
	}
}

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

int	main()
{
	int	N;
	cin >> N;
	int	times = 0;
	while (N /= 2)
		++times;
	int	ans = 1;
	for (int i = 0; i < times; ++i)
		ans *= 2;
	cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var H int
	var N int
	var a int
	fmt.Scan(&H, &N)
	sum := 0
	for n := 0; n < N; n++ {
		fmt.Scanf("%d", &a)
		sum += a
	}
	if sum >= H {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

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

using ll = long long;
using Graph = vector<vector<int>>;

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

vector<ll> cnt;
vector<pair<ll,ll>> pls;

void dfs(const Graph &g, ll x, ll y) {
  cnt[x] += cnt[y];
  for(auto nv:g[x]) {
    if(nv==y)continue;
    dfs(g,nv, x);
  }
}

int main() {
  ll N, Q;
  cin >> N >> Q;
  Graph g(N+1LL);
  pls.resize(Q);
  cnt.assign(N+1LL,0LL);
  for(ll i = 0LL; i < N-1LL; i++) {
    ll x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for(ll i = 0LL; i < Q; i++) {
    ll x, y;
    cin >> x >> y;
    cnt[x] += y;
  }
  dfs(g,1LL,0LL);
  ll ans = N;
  for(ll i = 1LL; i < N+1LL; i++) {
    cout << cnt[i] << " ";
  }
}

Measured memory_bytes: 27392
#b
r, g, b, n = (int(_) for _ in input().split())
red = n // r
sets = []
ans = 0
for i in range(red + 1):
    remainder = n - (r*i)
    green = remainder // g
    if remainder == 0:
        ans += 1
    else:
        for j in range(green+1):
            nremainder = remainder - j*g
            if nremainder == 0:
                ans += 1
            elif nremainder > 0 and nremainder % b == 0:
                k = nremainder // b
                ans += 1

print(ans)

Measured memory_bytes: 40684
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int A = sc.nextInt();
  int B = sc.nextInt();
  int C = sc.nextInt();
  if(A == B)System.out.println(C);
  else if(B == C)System.out.println(A);
  else System.out.println(B);
}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define mx 10e7
#define ll long long int
using namespace std;
//int sum_of_digit (int a){
//    int x=a, r,sum=0;
//    while(a!=0){
//        r=a%10;
//        dsum+=r;
//        a/=10;
//    }
//   return sum;
//}
int main(){
ll a,b,x,cnt=0;
cin>>a>>b;
x=a;
while(x!=0){
    x=x/b;
    cnt++;
}
cout<<cnt<<endl;
return 0;
}


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

int main() {
	int p[14][14] = {};
	int x, y, s;
	int ca = 0;
	int a = 0;
	while (scanf("%d,%d,%d", &x, &y, &s) + 1) {
		if (s == 1) {
			p[x + 2][y + 2] += 1;
			p[x + 3][y + 2] += 1;
			p[x + 2][y + 1] += 1;
			p[x + 2][y + 3] += 1;
			p[x + 1][y + 2] += 1;
		}

		if (s == 2) {
			p[x + 2][y + 2] += 1;
			p[x + 3][y + 2] += 1;
			p[x + 2][y + 1] += 1;
			p[x + 2][y + 3] += 1;
			p[x + 1][y + 2] += 1;
			p[x + 3][y + 3] += 1;
			p[x + 3][y + 1] += 1;
			p[x + 1][y + 1] += 1;
			p[x + 1][y + 3] += 1;
		}

		if (s == 3) {
			p[x + 2][y + 2] += 1;
			p[x + 3][y + 2] += 1;
			p[x + 2][y + 1] += 1;
			p[x + 2][y + 3] += 1;
			p[x + 1][y + 2] += 1;
			p[x + 3][y + 3] += 1;
			p[x + 3][y + 1] += 1;
			p[x + 1][y + 1] += 1;
			p[x + 1][y + 3] += 1;
			p[x + 4][y + 2] += 1;
			p[x][y + 2] += 1;
			p[x + 2][y + 4] += 1;
			p[x + 2][y] += 1;
		}
	}
	a = p[2][2];
	for (int i = 2; i < 12; i++) {
		for (int j = 2; j < 12; j++) {
			if (p[i][j] == 0) {
				ca++;
			}
			if (p[i][j] > a) {
				a = p[i][j];
			}
		}
	}
	cout << ca << endl << a << endl;
}

Measured memory_bytes: 3124
#include<iostream>
#include<string>
using namespace std;
int main(){
  string S;
  cin>>S;
  if(S[0]!='A'){
    cout<<"WA"<<endl;
  }else{
    int count=0;
    int len=S.size();
    int placec;
    for(int i=2;i<len-1;i++){
      if(S[i]=='C'){
        placec=i;
        count++;
      }
    }
    if(count!=1){
      cout<<"WA"<<endl;
      return 0;
    }else{
      for(int i=1;i<len;i++){
        if(i!=placec){
          if(S[i]<97){
            cout<<"WA"<<endl;
            return 0;
          }
        }
      }
    }
    cout<<"AC"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
"""
ワーシャルフロイド風に全探索で-1を炙り出す

条件を満たすとき:
A→Bの経路 == A→C→Bの経路
ならA→Bを合計から引く？
残るのは隣り合ったやつだけ？？

完全グラフから不要物を取り除いていく
A→C→B == A→Bだった場合、AB間は絶対に不要

"""

import sys

N = int(input())

A = []
s = 0

for i in range(N):
    a = list(map(int,input().split()))
    s += sum(a)
    A.append(a)

s //= 2
#print (A)

for k in range(N):

    for i in range(N):
        for j in range(N):

            if A[i][j] > A[i][k] + A[k][j]:
                print (-1)
                sys.exit()

for k in range(N):

    for i in range(N):
        for j in range(N):

            if i == j or i == k or j == k:
                continue
            if 0 in [ A[i][j] ,A[i][k] ,A[k][j]]:
                continue

            if A[i][j] == A[i][k] + A[k][j]:
                s -= A[i][j]
                A[i][j] = 0
                A[j][i] = 0
                #print (i,j,k)
                
#print (A)
print (s)



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

int main() {
    int N, K; cin >> N >> K;
    int A[N]; REP(i, N) cin >> A[i];

    int dp1[N][K];
    REP(i, K) dp1[0][i] = 0;
    dp1[0][0] = 1;
    REP(n, N-1) REP(k, K){
        if (k < A[n]){
            dp1[n+1][k] = dp1[n][k];
        }
        else{
            dp1[n+1][k] = dp1[n][k] | dp1[n][k-A[n]];
        }
    }

    int dp2[N][K];
    REP(i, K) dp2[N-1][i] = 0;
    dp2[N-1][0] = 1;
    for (int n=N-1; n>0; n--) REP(k, K){
        if (k < A[n]){
            dp2[n-1][k] = dp2[n][k];
        }
        else{
            dp2[n-1][k] = dp2[n][k] | dp2[n][k-A[n]];
        }
    }

    int ans = 0;
    REP(n, N){
        if (K-A[n] <= 0) continue;
        bool need = false;
        int k2 = K-1;
        REP(k1, K){
            if (!dp1[n][k1]) continue;
            while (!dp2[n][k2] || k1+k2>=K){
                k2 -= 1;
            }
            if (k1+k2 >= K-A[n]){
                need = true;
                break;
            }
        }
        if (!need) ans += 1;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 195584
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
P1 = [p for p in P if p <= A]
P2 = [p for p in P if A < p <= B]
P3 = [p for p in P if B < p]

print(min(len(P1), len(P2), len(P3)))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int flag1=0,flag2=0,l=0;
	string a;
	cin>>a;
	for(int i=0;i<a.length();i++) if(a[i]=='C') flag1=1,l=i;
	for(int i=l;i<a.length();i++) if(a[i]=='F') flag2=1;
	if(flag1&&flag2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int num;
	cin >> num;
	cin.ignore();
	while(num--)
	{
		string s,_s;
		getline(cin,s);

		bool flag = true;
        _s = s;
        for(int x=1;x<=26;x++)
		{
			for(int y=1;y<=26;y++)
			{
				if(_s.find("that") == string::npos && _s.find("this") == string::npos)
				{
			        for(int i=0;i<s.length();i++)
					{
					   if(s[i]>='a'&&s[i]<='z')
					   {
						   _s[i]=((((s[i]-'a')*x)+y)%26)+'a';
                       }
                    }
		        }
	            else
				{
				   cout<<_s<<endl;
				   flag = false;
				   break;
                }
			}
            if(flag == false)
			{
				break;
			}
        }
	}
	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <string.h>
int main(){
  int h,w,i,j,k,l,c;
  char s[100][101];
  scanf("%d%d",&h,&w);
  for(i=0;i<h;i++)scanf("%s",s[i]);
  for(i=0;i<h;i++){
    c=0;
    for(j=0;j<w;j++)if(s[i][j]=='.')c++;
    if(c==w){
      for(k=i;k<h;k++)strcpy(s[k],s[k+1]);
      i--;
      h--;
    }
  }
  for(i=0;i<w;i++){
    c=0;
    for(j=0;j<h;j++)if(s[j][i]=='.')c++;
    if(c==h){
      for(k=i;k<w;k++)for(l=0;l<h;l++)s[l][k]=s[l][k+1];
      i--;
    }
  }
  for(i=0;i<h;i++)printf("%s\n",s[i]);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

#define reg register
#define MAX_N 100007
#define rep(i, l, r) for(int i = l; i <= r; ++i)
typedef long long ll;

template <typename _T>
inline bool read (_T& x) {
    x = 0;
    _T y = 1;
    char c = getchar();
    while ((c < '0' || '9' < c) && c != EOF) {
        if (c == '-') y = -1;
        c = getchar();
    }
    if (c == EOF) return false;
    while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
    x *= y;
    return true;
}

int N, M, top;
int head[MAX_N], to[MAX_N << 1], nxt[MAX_N << 1], cap;
int ansu[MAX_N], ansv[MAX_N];
int sum[MAX_N];
bool vis[MAX_N];

inline void addEdge (int u, int v) {
    nxt[++cap] = head[u];
    head[u] = cap;
    to[cap] = v;
}

void dfs (int x, int fa) {
    vis[x] = true;
    for (int i = head[x]; i; i = nxt[i])
        if (vis[to[i]] && to[i] != fa) {
            sum[x]++;
            ansu[++top] = x, ansv[top] = to[i];
        }
    for (int i = head[x]; i; i = nxt[i])
        if (!vis[to[i]]) dfs(to[i], x);
    if (x == 1 && sum[x] & 1) { puts("-1"); exit(0); }
    if (x != 1) {
        if (sum[x] & 1) sum[x]++, ansu[++top] = x, ansv[top] = fa;
        else sum[fa]++, ansu[++top] = fa, ansv[top] = x;
    }
}

int main () {
    // freopen ("in", "r", stdin);
    read(N), read(M);
    int u, v;
    rep (i, 1, M) {
        read(u), read(v);
        addEdge(u, v);
        addEdge(v, u);
    }
    dfs(1, 0);
    rep (i, 1, top) printf("%d %d\n", ansu[i], ansv[i]);
    return 0;
} 


Measured memory_bytes: 9344
H,W,i,j,k,l,t;
main(){
    char S[51][51] = {};
    char T[51][51] = {};
    scanf("%d%d",&H,&W);
    for(i=0;i<H;i++)scanf("%s",S[i]);
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            if(S[i][j]=='.'){
                for(k=i-1;k<=i+1;k++){
                    for(l=j-1;l<=j+1;l++){
                        if(S[k][l] == '#')t++;
                    }
            }
            S[i][j]=t+48;
            t=0;
            }
         }
     }
    for(i=0;i<H;i++)printf("%s\n",S[i]);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;
int UF[1100000];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
char str[1100][1100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a*b;i++)UF[i]=-1;
	for(int i=0;i<b;i++){
		scanf("%s",str[i]);
	}
	int gx,gy;
	for(int i=0;i<b;i++)for(int j=0;j<a;j++){
		if(str[i][j]=='#')continue;
		if(str[i][j]=='t'){gx=i;gy=j;}
		for(int k=0;k<4;k++){
			if(0<=i+dx[k]&&i+dx[k]<b&&0<=j+dy[k]&&j+dy[k]<a&&str[i+dx[k]][j+dy[k]]!='#')
				UNION((i+dx[k])*a+j+dy[k],i*a+j);
		}
	}
	if(FIND(0)==FIND(gx*a+gy)){printf("0\n");return 0;}
	int c;scanf("%d",&c);
	for(int i=0;i<c;i++){
		int p,q;scanf("%d%d",&q,&p);
		str[p][q]='.';
		for(int j=0;j<4;j++){
			if(0<=p+dx[j]&&p+dx[j]<b&&0<=q+dy[j]&&q+dy[j]<a&&str[p+dx[j]][q+dy[j]]!='#')
				UNION((p+dx[j])*a+q+dy[j],p*a+q);
		}
		if(FIND(0)==FIND(gx*a+gy)){
			printf("%d\n",i+1);
			return 0;
		}
	}
	printf("-1\n");
}

Measured memory_bytes: 6000
#include<stdio.h>
#include<string.h>
int main()
{
    char str[101];
    scanf("%s",str);
    int len=strlen(str);
    for(int i=0;i<len;i++)
    {
        if(str[i]=='A' && str[i+1]=='R')
    {
        printf("ABC");
        break;
    }
    else
    {
        printf("ARC");
        break;
    }
    }


    return 0;
}


Measured memory_bytes: 1728
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long INF = 1L << 59;
immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto X = readln.chomp.to!long;
    auto G = new Tuple!(int, long)[][](N);
    auto E = new Tuple!(int, int, long)[](M);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        G[s[0]-1] ~= tuple(s[1]-1, s[2].to!long);
        G[s[1]-1] ~= tuple(s[0]-1, s[2].to!long);
        E[i] = tuple(s[0]-1, s[1]-1, s[2].to!long);
    }
    auto T = new Tuple!(int, long)[][](N);

    E.sort!"a[2] < b[2]"();
    auto uf = new UnionFind(N);
    long mst_cost = 0;

    foreach (e; E) {
        if (uf.find(e[0]) == uf.find(e[1]))
            continue;
        T[e[0]] ~= tuple(e[1], e[2]);
        T[e[1]] ~= tuple(e[0], e[2]);
        uf.unite(e[0], e[1]);
        mst_cost += e[2];
    }

    auto max_edge_cost = new long[][](N, N);

    void dfs(int n, int p, int root, long d) {
        max_edge_cost[root][n] = d;
        foreach (e; T[n]) {
            int m = e[0];
            long c = e[1];
            if (m != p) 
                dfs(m, n, root, max(d, c));
        }
    }

    bool is_safe_edge(Tuple!(int, int, long) e) {
        return max_edge_cost[e[0]][e[1]] >= e[2];
    }

    foreach (i; 0..N)
        dfs(i, -1, i, 0);
    long ans = 0;

    if (mst_cost == X) {
        long safe_edges_cnt = E.map!(e => is_safe_edge(e)).sum;
        ans = (powmod(2, safe_edges_cnt, MOD) - 2) * powmod(2, M - safe_edges_cnt, MOD) % MOD; 
        ans = (ans + MOD) % MOD;
    } else if (mst_cost < X) {
        long diff = X - mst_cost;
        long a = E.map!(e => e[2] - max_edge_cost[e[0]][e[1]] < diff).sum;
        long b = E.map!(e => e[2] - max_edge_cost[e[0]][e[1]] == diff).sum;
        long c = E.map!(e => e[2] - max_edge_cost[e[0]][e[1]] > diff).sum;
        ans = 2 * (powmod(2, b, MOD) - 1) % MOD * powmod(2, c, MOD) % MOD;
        ans = (ans + MOD) % MOD;
    }

    ans.writeln;
}


class UnionFind {
    int N;
    int[] table;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }
}


long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}


Measured memory_bytes: 10876
# -*- coding: utf-8 -*-

import sys

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

N,M,K=MAP()

for i in range(N+1):
    for j in range(M+1):
        if i*(M-j)+j*(N-i)==K:
            Yes()
            exit()
No()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<int(N);I++)
#define REPP(I, N) for(int I=1;I<=int(N);I++)
#define ll long long
#define SZ(x) (int)(x).size()
#define F first
#define S second
#define PB(x) push_back(x)
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
using namespace std;
typedef pair<int,int> P;
int mx,mn,n,num;
int main(void){
	mn = 1005;
	RI(n);
	REP(i,n){
		RI(num);
		mn = min(mn, num);
		mx = max(mx, num);
	}
	printf("%d\n",mx-mn);
}

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

int main(){
  int N, M;
  cin >> N >> M;
  N--, M--;
  vector<bool> from_1(N+1, false);
  vector<bool> to_N(N+1, false);
  rep(i, M+1){
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a == 0) from_1[b] = true;
    if (b == N) to_N[a] = true;
  }
  
  bool judge = 0;
  rep(i, N+1){
    if (from_1[i] && to_N[i]) judge = 1;
  }
  
  if (judge) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
    
}

Measured memory_bytes: 256
/*
 * Since g++10 is released, some characters is not valid inside #if 0 :(
 * So, why not using clang++? :D

 * Date:
  echo -n '  ' && date +%Y.%m.%d # Just Run this (Type !!sh in Vim).

 * Solution:
  To be updated after "Accept".

 * Digression:

 * CopyRight:
          ▁▃▄▄▄▃▃▃▃▄▶
        ▗▇▀▔    ▔▔▔▔
       ▄▛   ▃▅━━■▄▂
      ▟▊   ▐▘     ▀▙
     ▟▜▌   ▐▖   ▋  ▐▍
    ▟▘ ▜   ▝▀▇▆●▘  ▐▌
  ▗▟▘   ▜▃       ▁▅▛
  ▔▀▼▅▄▃▃██▅▄▄▄▅■▀▔
        ▔▔▔▔▔▔
 */

#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

const int maxn = 205, maxk = 61;
ll bas[maxk];
ll a[maxn];
char s[maxn];

void insert (ll x) {
	for (int k = 0; k < maxk; k ++)
		if (x >> k & 1) {
			if (bas[k]) x ^= bas[k];
			else return bas[k] = x, void();
		}
}

bool query (ll x) {
	for (int k = 0; k < maxk; k ++)
		if (x >> k & 1) {
			if (bas[k]) x ^= bas[k];
			else return 0;
		}
	return 1;
}

int main () {
	int T = read;
	while (T --) {
		int n = read;
		for (int i = 1; i <= n; i ++) read(a[i]);
		std::fill(bas, bas + maxk, 0);
		scanf("%s", s + 1);
		for (int i = n; i; i --)
			if (s[i] == '0')
				insert(a[i]);
			else {
				if (!query(a[i])) {
					puts("1");
					goto fail;
				}
			}
		puts("0");
fail:;
	}
}


Measured memory_bytes: 1588
X = int(input())
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
xlist = primes(X)

for i in range(X,2*X+1):
    flag = True
    for j in xlist:
        if j != X and i%j == 0:
            flag = False
    if flag:
        print(i)
        break

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

int main(void) {
  int n, m;
  cin >> n >> m;

  for (int i = m/n; i > 0; i--) {
    if(m%i==0 && m/i>=n){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
N=int(input())

M=[[0]*N for n in range(N)]
for n in range(N):
    input_temp = list(map(int,input().split()))
    for m in range(input_temp[1]):
        ad = input_temp[m+2]
        M[n][ad-1] = 1 
        
for m in M:
    print(' '.join(map(str,m)))


Measured memory_bytes: 5676
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  ll X, Y;
  cin >> X >> Y;
  int ans = 0;
  while (X <= Y)
  {
    X = X * 2;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
	
	long long n;
	cin >> n;
	
	string a,b;
	cin >> a >> b;
	
	long long fp = 0;
	long long i;
	for(i = 0 ; i < a.length() ; i++){
		
		long long count = i;
		long long count1 = 0;
		
		while(count < n && a[count] == b[count1]){
			count++;
			count1++;
		}
		if(count == n){
			
			fp = i;
			break;
		}
	}
	if(i == n){
		
		fp = n;
	}
	
	cout << n +  fp << endl;
}

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

int dp[223456][3];
bool used[223445][3];
int n, a[312312], b[312312], c[312312];
int mx;
vector <int> v[5];
int mn = 50102031;

string s;
int main() {
    cin >> n;
    long long ana = 1, anb = 1;
    for(int i = 1; i <= n; i++) {
    	long long f, ss;
    	cin >> f >> ss;
    	if(i == 1) ana = f, anb = ss;
    	else {
        	long long lo = 1, hi = (long long)1e18 / max(f, ss);
        	long long anaa = ana, anbb = anb;
        	while(lo <= hi) {
        		long long mid = (lo + hi) / 2;
        		if(f * mid  >= anaa && ss * mid >= anbb) {ana = f * mid; anb = ss * mid; hi = mid - 1;  }  //cout << hi << ' ' <<;}
        		else lo = mid + 1;
        	}
    	}
    }
	cout << ana +anb;
}



Measured memory_bytes: 2304
N = int(input())
H = list(map(int, input().split()))
result = 1
h = H[0]

for i, h1 in enumerate(H):
    if i < len(H)-1:
        h2 = H[i+1]
    else:
        break
    if h <= h2 and h1 <= h2:
        h = h2
        result += 1

print(result)

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <vector>

int main() {
  std::vector<std::pair<int, int>> vec;

  int N, M, A, B, C;
  scanf("%d %d", &N, &M);

  for (int i = 0; i < N; i++) {
    scanf("%d", &A);
		vec.push_back(std::make_pair(A, 1));
  }

  for (int i = 0; i < M; i++) {
    scanf("%d %d", &B, &C);
		vec.push_back(std::make_pair(C, B));
  }

	std::sort(vec.begin(), vec.end());

  long long t = 0;
  for (auto it = vec.rbegin(); N != 0; it++) {
		int n = std::min(N, it->second);
		t += it->first * (long long)n;
		N -= n;
  }

  printf("%lld\n", t);
}


Measured memory_bytes: 2548
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long b = 1;
        long a = 0;
        for (int i = 0; i < n; i++) {
            int q = sc.nextInt();
            int x = sc.nextInt();
            if (q == 1) {
                b *= x;
                a *= x;
            } else if (q == 2) {
                a -= x;
            } else {
                a += x;
            }
        }
        System.out.println(a + " " + b);
    }
}



Measured memory_bytes: 26412
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)
#define fore(i,x) for(int i = head[x] ; i ; i = e[i].next)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define PII pair<int,int>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
#define int long long 
int a[10];
int N;
int f[3005];
signed main()
{rep(i,1,3) cin>>a[i];  cin>>N;
 f[0]=1;
 rep(i,1,3)
 rep(j,a[i],N)
   f[j]=f[j]+f[j-a[i]];
	
cout<<f[N]<<endl;	
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int a;
cin>>a;
int jkl[a];
for(int i=0;i<a;i++)cin>>jkl[i];
reverse(jkl,jkl+a);
for(int i=0;i<a-1;i++){
cout<<jkl[i]<<" ";
}
cout<<jkl[a-1]<<endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <set>
#define LL long long
using namespace std;

LL N,a[2010],x;
multiset<LL> st;

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

    LL i,k,res=(1LL<<60),aux,r;
    for (i=1; i<=N; i++) cin >> a[i];

    for (k=0; k<N; k++){
        aux=0;
        st.clear();
        r=1+k;
        for (i=1; i<=k+1; i++) st.insert(a[i]);
        aux+=*(st.begin());
        for (i=2; i<=N; i++){
            st.erase(a[i-1]);
            r++;
            if (r>N) r=1;
            st.insert(a[r]);
            aux+=*(st.begin());
        }

        res=min(res,k*x+aux);
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 512
n,m = map(int,input().split())
mod = 1000000007
fact = [1]*150000
for i in range(1,150000):
  fact[i] = fact[i-1]*i % mod
if abs(n-m) > 1:
  print(0)
elif abs(n-m) == 1:
  print(fact[n]*fact[m]%mod)
else:
  print(fact[n]*fact[m]*2%mod)

Measured memory_bytes: 8948
INF = 10**15
N, W = map(int, input().split())
value, weight = [0], [0]
for _ in range(N):
  w, v = map(int, input().split())
  weight.append(w)
  value.append(v)
dp = [[INF]*100100 for _ in range(N+1)]
dp[0][0] = 0

for i in range(1, N+1):
  for j in range(100100):
    dp[i][j] = min(dp[i][j], dp[i-1][j])
    if 0 <= j-value[i]:
      dp[i][j] = min(dp[i][j], dp[i-1][j-value[i]] + weight[i])

ans = 0
for i in range(100100):
  if dp[N][i] <= W:
    ans = i
print(ans)

Measured memory_bytes: 152884
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  string c;
  cin>>c;
  string fir_c=c;
  sort(c.begin(),c.end());
  string sec_c=c;
  int cnt=0;
  for(int i=0;i<n;i++){
    if(fir_c.at(i)!=sec_c.at(i))cnt++;
  }
  cout<<cnt/2<<endl;
  return 0;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define MAX 1000000007
ll n,m,i,j,k,t,vis[sz],a,b,c,arr[sz],brr[sz];
vector<ll>v[sz];
void bfs(ll node)
{
    queue<ll>q;
    q.push(node);
    arr[node]=0;
    vis[node]=1;
    while(!q.empty())
    {
        ll x=q.front();
        q.pop();
       // vis[x]=1;
        for(int ii=0; ii<v[x].size(); ii++)
        {
            ll y=v[x][ii];
            if(vis[y]==0 || (arr[y]>(arr[x]+1)))
            {
                arr[y]=arr[x]+1;
                vis[y]=1;
                q.push(y);
            }

        }
    }
    return;
}
int main()
{
    scanf("%lld %lld %lld",&n,&m,&k);
    for(i=1; i<n; i++)
    {
        v[i].push_back(i+1);
        v[i+1].push_back(i);
    }
    v[m].push_back(k);
    v[k].push_back(m);
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
            arr[j]=0,vis[j]=0;
        bfs(i);
        for(j=1; j<=n; j++)
        {
           // printf("%lld\n",arr[j]);
            brr[arr[j]]++;
        }
    }
    for(i=1; i<n; i++)
    {
        printf("%lld\n",brr[i]/2);
    }

}


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

int main(){
    string s, t; cin >> s >> t;
    vector<int> salpha(26, 0), talpha(26, 0);
    for(int i = 0; i < s.size(); i++){
        salpha[s[i]-'a']++;
        talpha[t[i]-'a']++;
    }
    vector<int> lis1(3*1e5, 0), lis2(3*1e5, 0);
    for(int i = 0; i < 26; i++){
        lis1[salpha[i]]++;
        lis2[talpha[i]]++;
    }
    for(int i = 0; i < lis1.size(); i++){
        if(!(lis1[i] == lis2[i])){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}
  

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

int main() {
  int64_t h,n,sum=0;
  cin >> h >> n;
  int64_t a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) sum += a[i];
  cout << (sum >= h ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1024