akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld DINF = 1e12;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

template <typename T = ll>
struct dijkstra
{
  static const int MAX_V = 200010;
  const T INF_d;
  dijkstra(T INF_d_ = LINF) : INF_d(INF_d_) {}

  struct edge
  {
    int to;
    T cost;
  };

  vector<edge> E[MAX_V];
  T d[MAX_V];
  using pt = pair<T, int>;

  void add_edge(int a, int b, T c, bool undirected = false)
  {
    E[a].push_back(edge{b, c});
    if (undirected)
      E[b].push_back(edge{a, c});
  }

  void calc(int s)
  {
    priority_queue<pt, vector<pt>, greater<pt>> que;
    fill(d, d + MAX_V, INF_d);
    que.emplace(0LL, s);
    d[s] = 0;
    while (!que.empty())
    {
      pt p = que.top();
      que.pop();
      int v = p.second;
      if (d[v] < p.first)
        continue;
      for (auto &&e : E[v])
      {
        if (d[e.to] > d[v] + e.cost)
        {
          d[e.to] = d[v] + e.cost;
          que.emplace(d[e.to], e.to);
        }
      }
    }
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  int h, w;
  cin >> h >> w;
  string s[110];
  rep(i, h) cin >> s[i];
  dijkstra<> ds;
  rep(i, h) rep(j, w)
  {
    if (i + 1 < h)
      ds.add_edge(i * w + j, (i + 1) * w + j, s[i][j] != s[i + 1][j]);
    if (j + 1 < w)
      ds.add_edge(i * w + j, i * w + j + 1, s[i][j] != s[i][j + 1]);
  }
  ds.calc(0);
  int d = ds.d[h * w - 1];
  if (d % 2 == 0 && s[0][0] == '#')
    cout << d / 2 + 1 << endl;
  else
    cout << (d + 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 7040
//C - Sum of product of pairs
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353
#define M 1000000007 //10^9+7
#define pi 3.1415926535897932384626433832

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;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  ll n,a[200010]={},x[200010]={},ans=0;
  scanf("%lld", &n);
  for(ll i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    x[i]=(x[i-1]+a[i]+M)%M;
  }

  for(ll j=1; j<n; j++){
    ans=(ans+x[j]*a[j+1]+M)%M;
  }

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

  return 0;
}


Measured memory_bytes: 4856
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
#define read            ZXBs_fast_input
#define write           ZXBs_fast_output
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool write(int x){
	if(x >= 10) write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ll k, A, B;
	cin >> k >> A >> B;
	if(A + 1 >= B || k + 1 < A){
		cout << k + 1 << endl;
		return 0;
	}
	ll dist = B - A;
	ll ans = 1;
	ans += (A - 1), k -= (A - 1);
	ans += ((k / 2) * dist + (k % 2));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
type t = { v : int; w : int }

let solve a n w =
  let dp = Array.make_matrix (n + 1) (w + 1) 0 in
  for i = 1 to n do
    for j = 1 to w do
      dp.(i).(j) <-
        if j - a.(i-1).w < 0 then dp.(i-1).(j)
        else max dp.(i-1).(j) (dp.(i-1).(j - a.(i-1).w) + a.(i-1).v);
    done
  done;
  dp.(n).(w)

let () =
  let (n, w) = Scanf.scanf "%d %d " (fun n w -> n, w) in
  let a = Array.init n (fun _ -> Scanf.scanf "%d %d " (fun v w -> { v; w })) in
  solve a n w |> Printf.printf "%d\n"

Measured memory_bytes: 10440
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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);
    return a/g *b;
}

int main(){
    long long r,D,x;
    cin >> r >> D >> x;
    long long num=x;
    for(int i=0;i<10;++i){
        num=r*num-D;
        cout << num << endl;
    }
    }

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

typedef struct {
	int height;
	int num1, num2;
} Rail;

#define MAX_M 1000

int n, m, a;
Rail rail[MAX_M];

int int_sort( const void *a, const void *b )
{
	Rail rail_a, rail_b;
	int tmp_a, tmp_b;
	rail_a = *(Rail *)a;
	rail_b = *(Rail *)b;
	tmp_a = rail_a.height;
	tmp_b = rail_b.height;
	if ( tmp_a > tmp_b ) {
		return -1;
	}
	if ( tmp_a < tmp_b ) {
		return 1;
	}
	return 0;
}

int main(void)
{
	int i;
	
	while(1) {
		
		scanf( "%d %d %d", &n, &m, &a );
		
		if ( n == 0 ) break;
		
		for( i=0; i<m; i++ ) {
			scanf( "%d %d %d", &rail[i].height, &rail[i].num1, &rail[i].num2 );
		}
	
		qsort( (void *)rail, m, sizeof( rail[0] ), int_sort );
		
		for( i=0; i<m; i++ ) {
			if ( a == rail[i].num1 )
				a = rail[i].num2;
			else
				if ( a == rail[i].num2 )
					a = rail[i].num1;
		}
		
		printf( "%d\n", a );
	}
	return 0;
}

Measured memory_bytes: 672
#coding: utf-8
from math import tan, pi
eps = 10**(-12)

def binary_search(a, b, x):
    l = pi / 2
    r = 0.0
    if x <= a ** 2 * b / 2:
        while l - r > eps:
            mid = (r + l) / 2
            if a * b**2 / tan(mid) / 2 == x:
                return x
            elif a * b**2 / tan(mid) / 2 > x:
                r = mid
            else:
                l = mid
        return l
        
    else:
        while l - r > eps:
            mid = (r + l) / 2
            if a**2 * b - a**3 * tan(mid) / 2 == x:
                return x
            elif a**2 * b - a**3 * tan(mid) / 2 > x:
                r = mid
            else:
                l = mid
        return l

a, b, x = map(int, input().split())
print("{:.10f}".format(binary_search(a, b, x) * 180 / pi))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define pb push_back
#define in(x) int x; cin>>x;
#define ln(x) long long x; cin>>x;
#define memf(a) memset(a,false,sizeof(a))
#define F first
#define S second
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main()
{
	fast
	ll n;
	cin>>n;
	ll M=1e9+7;
	ll ans=0;
	ans=power(10,n,M)-2*power(9,n,M)+power(8,n,M);
	ans+=(5*M);
	ans%=M;
	cout<<ans;
	return 0;
}

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

const int N = 1e5 + 100, inF = N;

int n, k, ans, out[N], dis[N];
bool mark[N];
vector<int> in[N];

void dfs(int v, bool change = false) {
	mark[v] = change;
	for (int u: in[v]) 
		if(mark[u] == false) {
			dis[u] = dis[v] + 1;
			dfs(u, change);
		}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	cin >> out[0];
	ans += (out[0] != 1);
	
	for (int i = 1; i < n; i++) {
		cin >> out[i];
		in[--out[i]].push_back(i);
	}
	dfs(0);
	vector<int> vec(n);
	iota(vec.begin(), vec.end(), 0);
	sort(vec.begin(), vec.end(), [](int a, int b) {
		return dis[a] > dis[b];
	});
	for (int u: vec) {//
		if(mark[u] || dis[u] <= k)
			continue;
		for (int i = 0; i < k - 1; i++)
			u = out[u];
		ans++;
		dfs(u, true);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 11648
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n;
  cin>>n;
  int length = n;
	string s;
  string t;
  cin>>s;
  cin>>t;

  string u;
  int i = 0 ,j = 0;
  

  while( i < length){
  	u = u + s[i];

    u = u + t[i];

    i++;
  }
  cout<< u<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1e9+5
#define int long long
#define LINF 1000000000000000005

int n,x,y,k[100005],r,v[100005],t[100005],ans,f;

vector <int> g[100005];

void DFS(int nod){
    v[nod]=1;
    for(int i : g[nod]){
        if(!v[i]) DFS(i), t[nod]+=(!t[i]);
    }
    if(t[nod]>1) f=1;
}

int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> n;
    for(int i=1;i<n;i++){
        cin >> x >> y;
        g[x].pb(y); g[y].pb(x);
    }
    DFS(1);
    if(f || !t[1]) cout << "First";
    else cout << "Second";
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int rel = 0;

    for (int i  = 1; i <= N; i++) {
        int j = i;
        int sum = 0;
        while(j > 0) {
            sum += j % 10;
            j /= 10;
        }

        if (sum >= A && sum <= B) {
            rel += i;
        }
    }

    cout << rel << endl;
}

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 4000000000; //4*10^9;
constexpr auto MOD = 1000000007; //10^9+7;

int main(){

	int n,k,r,s,p;
	cin >> n>>k>>r>>s>>p;
	string t;
	cin >> t;
	
	vs A(k);
	rep(i,k)A[i]="n";

	int ans = 0;

	rep(i, n) {

		if (t[i] == A[i % k][0]) {
			A[i% k][0]= 'n';
			continue;
		}

		if (t[i] == 'r') {
			ans += p;
			A[i%k] = "r";
		}
		if (t[i] == 'p') {
			ans += s;
			A[i % k] = "p";
		}
		if (t[i] == 's') {
			ans += r;
			A[i % k] = "s";
		}
	}
	cout << ans << endl;
}

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

int main(){
  ll a,b; cin>>a>>b;
  ll ans=1;
  for(int i=2;i<1000000;i++){
    if(a%i==0 && b%i==0) ans++;
    while(a%i==0) a/=i;
    while(b%i==0) b/=i;
  }
  if(a>1 && a==b) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
#endif

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Extra --------------------------------------------------------------------

#define fast                ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double
#define endl                '\n'
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Template -----------------------------------------------------------------

template <typename T> 
inline bool inrange(T a, T l, T r) {
    if(l>r) swap(l,r);
    return (a>=l and a<=r);
}
template <typename T, typename U> 
inline bool exist(T val, U &any) {
    return (any.find(val) != any.end());
}
// multiple input
template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n, m;
    std::cin>>n>>m;

    vector<ll> a(n);
    std::cin>>a;

    ll sm =  accumulate(all(a),0LL);
    if(sm<=n) {
        std::cout<<n-sm<<endl;
    }
    else {
        cout<<-1<<endl;
    }
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif
    
    fast;
    int t = 1;
    loop(i,1,t+1)
    {
        cerr<<"Case #"<<i<<"\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 11128
#include <bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
int main() {
	bool prime[1000001];
	for(int i=0;i<=1000000;i++)prime[i]=true;
	prime[0]=prime[1]=false;
	for(int i=2;i<=1000000;i++){
		if(prime[i]){
			for(int j=i*2;j<=1000000;j+=i)prime[j]=false;
		}
	}
	int n,x;
	while(cin>>n>>x&&n&&x){
		bool data[2000001];
		memset(data,false,sizeof(data));
		data[0]=true;
		for(int i=0;i<n;i++){
			int a;
			cin>>a;
			for(int i=0;i<=x;i++){
				if(data[i])data[i+a]=true;
			}
		}
		int ans=-1;
		for(int i=x;i>=0;i--){
			if(data[i]&&prime[i]){
				ans=i;
				break;
			}
		}
		if(ans==-1)cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
		
}

Measured memory_bytes: 4096
S = input()

if S == "SUN":
    print("7")
elif S == "MON":
    print("6")
elif S == "TUE":
    print("5")
elif S == "WED":
    print("4")
elif S == "THU":
    print("3")
elif S == "FRI":
    print("2")
elif S == "SAT":
    print("1")    

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>

using namespace std;

bool linearSearch(int *A, int length, int key){
  for(int i = 0;i < length;i++){
    if(A[i] == key) return true;
  }
  return false;
}

int main(){

  int n, q, cnt = 0;
  int s[10000], t[500];

  cin >> n;
  for(int i = 0;i < n;i++) cin >> s[i];
  cin >> q;
  for(int i = 0;i < q;i++) cin >> t[i];

  for(int i = 0;i < q;i++){
    if(linearSearch(s, n, t[i])) cnt++;
  }

  cout << cnt << endl;

  return 0;
}




Measured memory_bytes: 3108
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	let A = parseInt(input[0][0], 10);
	let B = parseInt(input[0][1], 10);
	let C = parseInt(input[0][2], 10);
	let K = parseInt(input[1][0], 10);
	let count = 0;
	while (A >= B){
		count++;
		B *= 2;
	}
	while (B >= C){
		count++;
		C *= 2;
	}
	let ans;
	if (count <= K) ans = 'Yes';
	else ans = 'No';

	console.log(ans);

}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29664
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

const double pi = acos(-1);

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double ta = (h * 60.0 + m) / 720.0 * pi * 2.0;
    double tb = (m / 60.0) * pi * 2.0;
    //cout << ta << " " << tb << endl;
    double ang = abs(ta - tb);
    cout << fixed << setprecision(12) << sqrt(a*a+b*b-2.0*a*b*cos(ang)) << endl;
}



Measured memory_bytes: 4236
#!/usr/bin/env python

def main():
    N, M = list(map(int, input().split()))
    ks = [list(map(int, input().split())) for _ in range(M)]
    p = list(map(int, input().split()))
    ans = 0
    
    for i in range(1 << N):
        switch = [None] * N
        for j in range(N):
            switch[j] = 1 if ((i >> j) & 1) else 0
        
        flag = True
        for m in range(M):
            tmp = 0
            k = ks[m][0]
            s = list(map(lambda x: x-1, ks[m][1:]))
            for idx in s:
                tmp += switch[idx]
            if tmp % 2 != p[m]:
                flag = False
                break
        if flag:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 42732
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn main() {
    input! { n, a: [i64; n] };
    let s = a.iter().sum::<i64>() as usize;
    let mut ans = true;
    if s % (n * (n + 1) / 2) != 0 {
        ans = false;
    } else {
        let m = (s / (n * (n + 1) / 2)) as i64;
        let mut c = 0;
        for i in 0..n {
            let ni = (i + 1) % n;
            let d = a[i] - a[ni] + m;
            c += d / n as i64;
            if d < 0 || d % n as i64 != 0 {
                ans = false;
            }
        }
        if c != m {
            ans = false;
        }
    }
    println!("{}", if ans { "YES" } else { "NO" });
}


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

constexpr ll mod = 1000000007;

int main() {
    int n;
    scanf("%d",&n);
    vector<int> a(n);
    rep(i,n) scanf("%d",&a[i]);
    sort(a.begin(),a.end());
    vector<int> v;
    if(n % 2 == 1) {
        v.push_back(0);
        for(int i = 2; i < n; i+=2) {
            v.push_back(i);
            v.push_back(i);
        }
        if(v != a) {
            printf("%d\n",0);
            return 0;
        }
        int h = (n-1) / 2;
        ll ans = 1;
        rep(i,h) {
            ans *= 2;
            ans %= mod;
        }
        printf("%ld\n",ans);
        return 0;
    } else {
        for(int i = 1; i < n; i+=2) {
            v.push_back(i);
            v.push_back(i);
        }
        if(v != a) {
            printf("%d\n",0);
            return 0;
        }
        int h = n / 2;
        ll ans = 1;
        rep(i,h) {
            ans *= 2;
            ans %= mod;
        }
        printf("%ld",ans);
        return 0;
    }
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
//repetition
//------------------------------------------
#define FOR(i, p, b) for (int i = (p); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \<< " " << __FILE__ << endl;

int main() {
    int N;
    int min = 99999999;
    int cnt = 0;
    cin >> N;
    int A[N];

    int i = 0;
    REP(i, N) {
        cin >> A[i];
    }

    i = 0;
    REP(i, N) {
        cnt = 0;

        while (A[i] % 2 == 0) {
            A[i] /= 2;
            cnt++;
        }

        if (cnt < min) {
            min = cnt;
        }
    }
    cout << min << endl;

}

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

int main(void) {
	int X;
	scanf("%d", &X);
	if (X == 1) {
		printf("1\n");
		return 0;
	}
	int b = 2;
	int ans = 0;
	while (1) {
		int a = b;
		while (1) {
			a *= b;
			if (a <= X) {
				ans = max(ans, a);
				// cout << ans << "\n";
			} else {
				break;
			}
		}
		if (b > 40) {
			break;
		} else {
			b++;
		}
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 3728
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var s=sc.Ia;
		int p=s[0]-(s[0]%n);
		Console.WriteLine("{0}",(p<s[0]&&p+n>s[1])?"NG":"OK");
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27500
package main

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

func mapf(f interface{}, list interface{}) interface{} {
	fv, listv := reflect.ValueOf(f), reflect.ValueOf(list)

	if fv.Kind() != reflect.Func || listv.Kind() != reflect.Slice {
		return nil
	}

	len := listv.Len()
	ret := reflect.MakeSlice(reflect.SliceOf(fv.Type().Out(0)), len, listv.Cap())

	for i := 0; i < len; i++ {
		v := fv.Call([]reflect.Value{listv.Index(i)})
		ret.Index(i).Set(v[0])
	}

	return ret.Interface()
}

func ifval(cond bool, a interface{}, b interface{}) interface{} {
	return map[bool]interface{}{true: a, false: b}[cond]
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()

	arr, _ := mapf(strconv.Atoi, strings.Split(scanner.Text(), " ")).([]int)
	a, b := arr[0], arr[1]

	fmt.Printf("a %s b\n", ifval(a > b, ">", ifval(a < b, "<", "==")))
}



Measured memory_bytes: 1280
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 1000000000000

using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

ll dp[101][301];
int main () {
	int N, W;
	cin >> N >> W;
	vector<ll> w(N), v(N);
	rep(i,N) {
		cin >> w[i] >> v[i];
	}
	ll offset = w[0];
	vector<ll> w0, w1, w2, w3;
	rep(i,N) {
		w[i] -= offset;
		if (w[i] == 0)
			w0.push_back(v[i]);
		else if (w[i] == 1)
			w1.push_back(v[i]);
		else if (w[i] == 2)
			w2.push_back(v[i]);
		else
			w3.push_back(v[i]);
	}
	sort(w0.rbegin(), w0.rend());
	sort(w1.rbegin(), w1.rend());
	sort(w2.rbegin(), w2.rend());
	sort(w3.rbegin(), w3.rend());
	ll ans = 0;
	rep (i,w0.size() + 1)
		rep (j,w1.size() + 1)
			rep(k,w2.size() + 1)
				rep(m,w3.size() + 1) {
					int all = i + j + k + m;
					ll cur_weight = all * offset + j + 2*k + 3*m;
					if (cur_weight > W)
						continue;
					ll sum_of_elems = accumulate(w0.begin(), w0.begin() + i, (ll)0)
									+ accumulate(w1.begin(), w1.begin() + j, (ll)0)
									+ accumulate(w2.begin(), w2.begin() + k, (ll)0)
									+ accumulate(w3.begin(), w3.begin() + m, (ll)0);
					ans = max(ans, sum_of_elems);
				}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string.h>
#include <set>
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N,M;

struct Info{
	char from[9],to[9];
	int rank;
	bool erased;
};

struct Data{
	char from[9],to[9],message[51];
};

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}


bool ambiguousCmp(char* base, char* comp){

	bool FLG = true;
	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i]){
			if(base[i] == '?'){
				//Do nothing
			}else{
				FLG = false;
				break;
			}
		}
	}
	if(FLG)return true;
	else{
		return false;
	}
}

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

void func(){

	int ok_index = 0,not_index = 0;
	Info OK[N],NOT[N];
	for(int i = 0; i < N; i++){
		OK[i].erased = false;
		NOT[i].erased = false;
	}

	char buf[10],from[9],to[9];
	bool FLG;

	for(int i = 0; i < N; i++){
		scanf("%s %s %s",buf,from,to);
		if(buf[0] == 'p'){

			strcpy(OK[ok_index].from,from);
			strcpy(OK[ok_index].to,to);
			OK[ok_index].rank = i;
			ok_index++;
		}else{

			strcpy(NOT[not_index].from,from);
			strcpy(NOT[not_index].to,to);
			NOT[not_index].rank = i;
			not_index++;
		}
	}

	for(int i = not_index -1; i >= 0; i--){
		for(int k = ok_index-1; k >= 0; k--){
			if(NOT[i].rank < OK[k].rank || OK[k].erased == true)continue;

			if(strCmp(NOT[i].from,OK[k].from) == true && strCmp(NOT[i].to,OK[k].to) == true){
				OK[k].erased = true;
			}
		}
	}

	for(int i = ok_index -1; i >= 0; i--){
		//if(OK[i].erased == true)continue;
		for(int k = not_index-1; k >= 0; k--){
			if(OK[i].rank < NOT[k].rank || NOT[k].erased == true)continue;

			if(strCmp(OK[i].from,NOT[k].from) == true && strCmp(OK[i].to,NOT[k].to) == true){
				NOT[k].erased = true;
			}
		}
	}


	queue<Data> Q;

	for(int loop = 0; loop < M; loop++){
		Data data;

		scanf("%s %s %s",data.from,data.to,data.message);

		FLG = false;

		for(int i = 0; i < ok_index; i++){
			if(OK[i].erased == true)continue;
			if(ambiguousCmp(OK[i].from,data.from) == true &&  ambiguousCmp(OK[i].to,data.to) == true){
				FLG = true;
				break;
			}
		}

		if(!FLG)continue;

		FLG = true;

		for(int i = 0; i < not_index; i++){
			if(NOT[i].erased == true)continue;
			if(ambiguousCmp(NOT[i].from,data.from) == true &&  ambiguousCmp(NOT[i].to,data.to) == true){
				FLG = false;
				break;
			}
		}

		if(FLG){
			Q.push(data);
		}
	}

	printf("%d\n",Q.size());

	while(!Q.empty()){
		printf("%s %s %s\n",Q.front().from,Q.front().to,Q.front().message);
		Q.pop();
	}

}

int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;

int main(){

    int ans=0;
    int a,b;
    cin>>a>>b;

    ans=(b-1)/(a-1);

    if((b-1)%(a-1)!=0){
        ans++;
    }
    
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

#define FOR0(i, a, b, s) for (int i = a; s > 0 ? i < b : i > b; i += s)
#define FOR1(n) FOR0(i, 0, n, 1)
#define FOR2(i, n) FOR0(i, 0, n, 1)
#define FOR3(i, a, b) FOR0(i, a, b, 1)
#define FOR4(i, a, b, s) FOR0(i, a, b, s)
#define GET5(_1, _2, _3, _4, _5, ...) _5
#define FOR(...) GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  int ans;
  if (x < 600)
    ans = 8;
  else if (x < 800)
    ans = 7;
  else if (x < 1000)
    ans = 6;
  else if (x < 1200)
    ans = 5;
  else if (x < 1400)
    ans = 4;
  else if (x < 1600)
    ans = 3;
  else if (x < 1800)
    ans = 2;
  else
    ans = 1;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3588
from collections import defaultdict
d1=defaultdict(int)
d2=defaultdict(int)
n=int(input())
a=list(map(int,input().split()))
s=0
for i in range(n):
    d1[a[i]+i+1]+=1
    d2[i+1-a[i]]+=1
for v in d1.keys():
    s+=d1[v]*d2[v]
print(s)

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

int main(){
	int a,b;
	int ans=0;
	int tmp=0;

	cin>>a>>b;

	tmp= a+b;
	ans= tmp/2;

	if(tmp%2 ==1){
		ans++;
	}


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

Measured memory_bytes: 256
s = gets.chomp
ans = false
if s[0] == "A"
  s.slice!(0)
  if s[1..-2].include?("C")
    s.slice!(s.index("C"))
    ans = true
    s.codepoints do |t|
      if t < 97
        ans = false
      end
    end
  end
end
if ans
  puts "AC"
else
  puts "WA"
end

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

int main() {
    long long a, b, c, k;  cin >> a >> b >> c >> k;
    long long ans = 0;
    if (k <= a) {
        cout << k << endl;
        return 0;
    }
    ans += a;
    k -= a;
    if (k <= b) {
        cout << ans << endl;
        return 0;
    }
    k -= b;
    cout << ans - k << endl;
}


Measured memory_bytes: 3632
MOD = 10**9+7

fact = [1]*(2*10**6+10)
for i in range(1, len(fact)):
    fact[i] = (fact[i-1]*i)%MOD

def comb(n, k):
    return fact[n]*pow(fact[n-k], MOD-2, MOD)*pow(fact[k], MOD-2, MOD)

def path(x, y):
    return comb(x+y+2, min(x+1, y+1))-1

r1, c1, r2, c2 = list(map(int, input().split()))
print((path(r2, c2)-path(r1-1, c2)-path(r2, c1-1)+path(r1-1, c1-1))%(10**9+7))

Measured memory_bytes: 55660
#include <stdio.h>
int main(void){
    char a;
    scanf("%c",&a);
    
    if(a == 'A') printf("T");
    if(a == 'T') printf("A");
    if(a == 'G') printf("C");
    if(a == 'C') printf("G");
    
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>

using namespace std;
using ll = long long;

int main() {

	ll n, sum = 1000000000, num = 0;
	cin >> n ;
	vector<ll> x(n),sm(110);

	for (int i = 0; i < n; i++)
		cin >> x[i];
	for (int i = 0; i < 100; i++)
		sm[i] = 0;

	for (int j = 1; j <= 100; j++) {
		for (int k = 0; k < n; k++) {
			sm[j] += pow((x[k] - j),2);
		}
		if (sum > sm[j] && sm[j] >= 0)
			sum = sm[j];
	
	}
	cout << sum << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int dp[1000][3];
int main() {
  int N; cin>>N;
  int A, B; cin>>A>>B;
  vector<int> cnt(3,0);
  REP(i,N) {
    int	P; cin>>P;
    if(P <= A) cnt[0]++;
    else if(P <= B) cnt[1]++;
    else cnt[2]++;
  }
  int ans = cnt[0];
  ans = min(ans, cnt[1]);
  ans = min(ans, cnt[2]);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

#define rep(i,x) for(int i=0;i<x;i++)
using namespace std;

int main() {
    long long n; cin >> n;
    vector<int> ab(2);
    int sqn = sqrt(n);
    rep(i, sqn){
        if(n % (i + 1) == 0){
            int a = i + 1;
            int b = n / a;
            ab[0] = a; ab[1] = b;
        }
    }
    string s = to_string(ab[0]);
    string t = to_string(ab[1]);
    int ans = max(s.size(), t.size());
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[1]:


S = input()


# In[4]:


f = True
s_reversed = S[::-1]
words = ['maerd', 'remaerd', 'esare', 'resare']
while s_reversed:
    length = len(s_reversed)
    for i in [7,6,5]:
        while s_reversed[:i] in words:
            s_reversed = s_reversed[i:]
    if length == len(s_reversed):
        print("NO")
        f = False
        break
if f:
    print("YES")


# In[ ]:






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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s, t;cin >> s >> t;
    int n = s.size();
    int m = t.size();
    string ans = s;
    if(n < m){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for(int i=n-m+1-1;i>=0;i--){
        bool flag = true;
        for(int j=0;j<m;j++){
            if(s[i+j] == '?' || s[i+j] == t[j]) continue;
            flag = false;
            break;
        }
        if(flag){
            for(int j=0;j<m;j++){
                ans[i+j] = t[j];
            }
            for(int j=0;j<n;j++){
                if(ans[j] == '?'){
                    ans[j] = 'a';
                }
            }
            cout << ans << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
"use strict";
const main = arg => {
  const [a,b,c,d] = arg.trim().split(' ').map(x => BigInt(x));
  let max = a * c
  if (a * d > max) max = a * d
  if (b * c > max) max = b * c
  if (b * d > max) max = b * d
  console.log(max.toString())
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29512
# union find
def find_root(x):
    if parent[x] == x:
        return x
    else:
        return find_root(parent[x])


def unite(x, y):
    '''x,yの属する集合の併合'''
    x = find_root(x)
    y = find_root(y)

    if x != y:
        if rank[x] < rank[y]:
            parent[x] = y
            size[y] += size[x]
        else:
            parent[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1


def roots():
    '''rootリストを返す'''
    roots = []
    for i in range(N):
        roots.append(find_root(i))
    return roots


def group_size(x):
    '''xが所属するグループのサイズ'''
    return size[find_root(x)]


# 入力
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

# 初期化
parent = [i for i in range(N)]  # 根
rank = [1] * N  # 深さ
size = [1] * N  # iを根とするグループのサイズ

# 前処理
edge = [[ab[M - 1 - i][0] - 1, ab[M - 1 - i][1] - 1] for i in range(M)]

# 結合
for i in range(M):
    unite(edge[i][0], edge[i][1])

ans = 0
for i in range(N):
    ans = max(ans, group_size(i))
print(ans)


Measured memory_bytes: 86476
function main(input) {
    "use strict";
    //N個
    const splitByN = input.split('\n');
    //数字の配列
    let numbers = splitByN[1].split(' ');
    //操作数
    let count = 0;
    grid_loop:
    while(true){
        //一時的な配列保存
        const tempList = [];
        for(let i = 0; i < splitByN[0]; i++) {
            //最後尾の数字が奇数の場合終了。
            let lastOfNumber = (numbers[i].toString()).slice(-1);
            //偶数の場合
            if(lastOfNumber % 2 == 0) {
                //2で割った数を一時的なリストに移植する
                tempList.push(numbers[i] / 2);
            }else {
                //whileループを抜けるため、フラグを立ててからbreak;
                break grid_loop;
            }
        }
        count++;
        //元の配列に移植
        numbers = tempList.slice();
    }
    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    ll A, B_100, ans;
    double B;
    cin >> A >> B;
    B += 0.0001;
    B_100 = ll(B * 100);
    ans = A * B_100;
    cout << ans / 100 << endl;
}

Measured memory_bytes: 3688
#include <stdio.h>

int main(void)
{
	int x, y, i, j;
	char op=0;


	for(;;){
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0) {
			break;
		}

		for (i = 0; i < x; i++) {
			
			for (j = 0; j < y; j++) {
				if (j == 0 || j == y - 1 || i == 0 || i == x-1) {
					printf("#");
				}

					
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];
//平方根　= sqrt




void solve() {
  int r,d,exit;
  cin >> r >> d >> exit;
  int before=0;
  int cnt = 9;
  while(cnt>=0){
    before = r*exit - d;
    exit = before;
    cout << before << endl;
    --cnt;
  }
  return ;
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n, a := nextInt(), nextInt()
	if n%500 <= a {
		fmt.Println("Yes")
	} else if n%500 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

        int main() {
          ll N;
          cin>> N; 
          ll M = N; 
          vector<int> A(35);
          ll c=1;
          
          for(int i=0; i<35; i++){
            ll a =  max(N,-N);
            ll b =  max(2*c, -2*c); 
            if( (a%b) == 0 ) A.at(i)=0;
            if( (a%b) != 0 ) A.at(i)=1;
            N = N - A.at(i)*c;  
            c=c*(-2);
          }
          
          if(M==0){
            cout<< 0 << endl;
          }else{
                  int flag =0; 
                  for(int i=34; i>=0; i--){
                    if(A.at(i)==1) flag=1; 
                    if(flag==1) cout<< A.at(i); 
                  }
          }
          
          

        }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    REP(i, N) cin >> P[i];
    REP(i, N) cin >> Q[i];

    vector<int> v(N);
    iota(v.begin(), v.end(), 1);  

    int a = -1, b = -1;
    //REP(i, N) cout << v[i] <<endl;
    for(int i = 0;;i++){
        bool o = true;
        REP(i, N) if (v[i] != P[i]) {
            o = false;
            break;
        }
        if (o) a = i;

        o = true;
        REP(i, N) if (v[i] != Q[i]) {
            o = false;
            break;
        }
        if (o) b = i;
        if (a >= 0 && b >= 0) break;

        next_permutation(v.begin(), v.end());
    }
    //cout << a << " " << b << endl;
    cout << abs(a - b) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

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

bool comp(vector<int> a, vector<int> b) {
  return a[0] < b[0];
}

int main(void){
  int n, m, x;
  bool is_success;
  cin >> n >> m >> x;
  vector<VI> books(n, vector<int>(m+1, 0));

  rep(i, n) {
    cin >> books[i][0];
    rep(j, m) {
      cin >> books[i][j+1];
    }
  }

  sort(books.begin(), books.end(), comp);

  int best_price = INT_MAX;
  rep(i, pow(2, n)) {
    int price = 0;
    string b = bitset<12>(i).to_string();
    VI skill(m, 0);

    rep(k, n) {
      vector<int> book = books[k];
      if (b[11 - k] == '1') {
        rep(j, m) {
          skill[j] += book[j+1];
        }
        price += book[0];
      };
    }

    is_success = true;
    rep(j, m) {
      if (skill[j] < x) {
        is_success = false;
      }
    }

    if (is_success && (price < best_price)) {
      best_price = price;
    }
  }

  if (best_price == INT_MAX) {
    cout << "-1";
  } else {
    cout << best_price;
  }

  return 0;
};

Measured memory_bytes: 4060