akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
const int N = 5e5 + 5;
const int mod = 998244353;
int n, k;
ll fac[N], inv[N], ans;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
ll ksm(ll x, int y)
{
	ll res = 1;
	for(; y; y >>= 1, x = x * x % mod)
		if(y & 1) res = res * x % mod;
	return res;
}
void init(int n)
{
	fac[0] = 1;
	for(int i = 1; i <= n; i ++) fac[i] = fac[i - 1] * i % mod;
	inv[n] = ksm(fac[n], mod - 2);
	for(int i = n - 1; i >= 0; i --) inv[i] = inv[i + 1] * (i + 1) % mod;
}
ll C(int n, int m)
{
	if(n < m || n < 0 || m < 0) return 0;
	return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); k = read(); init(k);
	if(k < n) {puts("0"); return 0;}
	for(int R = 0; R <= k; R ++)
	{
		int B = k - R; if(R < B) continue;
		if(R == B) B --;
		ans = ((ans + C(R + B, R) - C(R + B, 2 * R - n + 1)) % mod + mod) % mod;
	}
	printf("%lld\n", ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 8192
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ull n;
    cin >> n;
    stack<char> work;
    while (n > 0) {
        --n;
        work.push('a' + (n % 26));
        n /= 26;
    }
    while (!work.empty()) {
        cout << work.top();
        work.pop();
    }
    cout << endl;
    return 0;
}


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

int main() {
    vector<int> v;
    int q; cin >> q;
    while (q--) {
        int com; cin >> com;
        if (com == 0) {
            int x; cin >> x; v.push_back(x);
        } else if (com == 1) {
            int p; cin >> p; cout << v[p] << endl;
        } else if (com == 2) {
            v.pop_back();
        }
    }
	return 0;
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  cout << fixed << setprecision(10) << (double)(n * m) / 2 << " "
       << (2 * x == n && 2 * y == m) << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 3720
from collections import Counter
N = int(input())
V = list(map(int,input().split()))
E = Counter(V[0::2]).most_common()+[(0,0)]
O = Counter(V[1::2]).most_common()+[(0,0)]

if E[0][0]!=O[0][0]:
  print(N-E[0][1]-O[0][1])
else:
  print(N-max(E[0][1]+O[1][1],E[1][1]+O[0][1]))

Measured memory_bytes: 20572
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int K, A, B;
    cin >> K >> A >> B;
    bool flag = false;
    for(int i = A; i < B + 1; i++){
        if(i % K == 0) flag = true;
    }
    if(flag) puts("OK");
    else puts("NG");
}


Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	int n, x, t;
	cin >> n >> x >> t;
	printf("%d\n", (n + x - 1) / x * t);
	return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    string s;
    cin>>s;
    if(s.length()==2){
        cout<<s<<endl;
    }else{
        char a=s[0];
        s[0]=s[2];
        s[2]=a;
        cout<<s<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define FO(i,a,b) for (int i = a; i <= b; i++)
#define FOb(i,a,b) for(int i=b;i>=a;i--)
#define vi vector<int>
#define vulli vector<unsigned long long int>
using namespace std;
typedef unsigned long long int ulli;
void solve()
{ 
  ulli n,a,b;
  cin >> n >> a >> b;
  ulli count_both = n / (a+b);
  ulli count = count_both*a;
  ulli left = n % (a+b);
  if (left >= (a))  count += a;
  else  count += (left%(a+b));
  cout << count ;
}
int main()
{
    std::ios_base::sync_with_stdio(false);
    ulli t=1;
   // cin>>t;   
    while(t--){ solve(); cout<<"\n"; }
    return 0;
}

Measured memory_bytes: 3664
# -*- coding: utf-8 -*-
"""
B - String Rotation
https://beta.atcoder.jp/contests/abc103/tasks/abc103_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s, t):
    for _ in range(len(s)):
        if s == t:
            return 'Yes'
        s = s[1:] + s[0]
    return 'No'


def main(args):
    s = input().strip()
    t = input().strip()
    ans = solve(s, t)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

ll S,W;
int main(){
    cin>>S>>W;
    if(S>W)cout<<"safe";
    if(S<=W)cout<<"unsafe";
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(void){
  int k;
  scanf("%d",&k);
  if(k==16)
    printf("14");
  else if(k==24)
    printf("15");
  else if(k==32)
    printf("51");
  else if(k==28||k==30)
    printf("4");
  else if(k==8||k==12||k==18||k==20||k==27)
    printf("5");
  else if(k==4||k==6||k==9||k==10||k==14||k==21||k==22||k==25||k==26)
    printf("2");
  else
    printf("1");
  return 0;
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
ll cum[401][401];
int main()
{
	ios_base::sync_with_stdio(false);
	ll n,i,j,k;
	cin>>n;
	ll a[n+2];
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
		for(j=i;j<n;j++)
			for(k=i;k<=j;k++)
				cum[i][j] += a[k];
	ll dp[n+2][n+2];	
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			dp[i][j] = 1e18;
	}
	for(i=0;i<n;i++)
		dp[i][i] = 0;
	for(i=n-1;i>=0;i--)
	{
		for(j=0;j<n;j++)
		{
			for(k=i;k<j;k++)
			{
				ll su = cum[i][k] + cum[k+1][j];
				if(i!=k)
					su += dp[i][k];
				if(k+1!=j)
					su += dp[k+1][j];
				dp[i][j] = min(dp[i][j], su);
			}
			// cout<<i<<" "<<j<<" "<<dp[i][j]<<nl;
		}
	}
	cout<<dp[0][n-1]<<nl;
	return 0;
}

Measured memory_bytes: 6160
#include<bits/stdc++.h>
#define pd(n) printf("%.10lf", n)
using namespace std;
const int N=3000;
double v[N];
double arr[N][N];
double fun(long l,long x,long sz,long ct)
{
	if(x==sz)
	{
		return 1.0;
	}
	if(arr[x][ct]!=-1.0)
	{
		return arr[x][ct];
	}
	arr[x][ct]=1.0;
	arr[x][ct]=v[x]*fun(l,x+1,sz,ct);
		if(ct<l)
	{
		arr[x][ct]+=(1.0-v[x])*fun(l,x+1,sz,ct+1);
	}
	return arr[x][ct];

}
int main()
{
		//IT'S GRV......
		ios_base::sync_with_stdio(false);
	 	cin.tie(NULL);
	 	long n;
	 	cin>>n;
	 	for(long i=0;i<n;i++)
	 	{
	 		double x;
	 		cin>>x;
	 		v[i]=x; 
	 	}
	 		 	for(long i=0;i<n;i++)
	 	{
	 		for(long j=0;j<=n/2+1;j++)
	 		{
	 			arr[i][j]=-1;
	 		}
	 	}
	 	long k=0;long l1;
	 	if(n%2==0)
	 	{
	 		l1=n/2-1;
	 	}
	 	else
	 	{
	 		l1=n/2;
	 	}

	 	pd(fun(l1,0,n,0));
	 	//cout<<ans<<"\n";
}


Measured memory_bytes: 69888
#include<iostream>
using namespace std;
int main()
{
	int k;
	int a, b;
	cin >> k;
	cin >> a >> b;
	int i;
	for (i = a; i <= b; i++) {
		if (i%k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(a, value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
 
typedef long long LL;
typedef pair<int, int> PII;

const int INF = 1000 * 1000 * 1000 + 7;
const int MAX = 1 << 17;

int n, t;
int a[MAX];

int solve()
{
	int d = 0, mn = INF, res = 0;
	FOR(i, 0, n)
	{
		if(a[i] - mn > d)
		{
			d = a[i] - mn;
			res = 0;
		}
		if(a[i] - mn == d)
			res++;
		mn = min(mn, a[i]);
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> t;
	FOR(i, 0, n)
		cin >> a[i];
	int ans = solve();
	reverse(a, a + n);
	FOR(i, 0, n)
		a[i] = -a[i];
	ans = min(ans, solve());
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

from fractions import gcd
from functools import reduce

L = A[0]
for i in range(1,N):
  L=(L*A[i])//gcd(L,A[i])

ans = 0

for i in range(N):
  ans += (L // A[i])

print(ans % mod)


Measured memory_bytes: 5596
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define MOD 1000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, m, fact[maxN];

int main () {
    fact[0] = 1;
    fto(i, 1, maxN-1) fact[i] = (1LL*fact[i-1]*i)%MOD;

    scanf("%d%d", &n, &m);
    if (n > m) swap(n, m);

    if (n == m) printf("%d", (2LL*fact[n]*fact[n])%MOD);
    else if (n+1 == m) printf("%d", (1LL*fact[n]*fact[m])%MOD);
    else puts("0");

    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    // #ifdef LOCAL
    //     freopen("in.txt", "r", stdin);
    //     freopen("out.txt", "w", stdout);
    // #endif
    ll k;
    sf(k);
    ll a, b;
    sf(a, b);
    bool ok = false;
    rep(i, a, b) {
        if (i % k == 0)  {
            ok = true;
            break;
        }
    }
    if (ok) puts("OK");
    else puts("NG");
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define MAX 1000000
class UnionFind{
  vector<int> v,deep;
  public:

  UnionFind(){
    v.resize(MAX);
    deep.resize(MAX);
    for(int i=1;i<MAX;i++){

      v[i]=i;

      deep[i] = 0;

    }

  }
    
  UnionFind(int num){
    v.resize(num+10);
    deep.resize(num+10);
    for(int i=1;i<num+10;i++){

      v[i]=i;

      deep[i] = 0;

    }
  }
   

  int root(int x){

    if(v[x]==x)return x;

    else return v[x] = root(v[x]);

  }



  bool same(int x, int y){

    return (root(x) == root(y));

  }



  void unite(int x,int y){

    x = root(x);

    y = root(y);

    if(deep[x] > deep[y]){

            v[y] = x;

    }else{

      if(deep[x] == deep[y])deep[y]++;

      v[x] = y;

    }

    return;

  }

};

int main(){
  int n,m;
  cin >> n >> m;
  UnionFind uf(n+m);
  for(int i=1;i<=n;i++){
      int j;
      cin >> j;
      for(int k = 0;k<j;k++){
          int l;
          cin >> l;
          uf.unite(i,n+l);
      }
  }
  for(int i=1;i<n;i++){
      if(!uf.same(i,i+1)){
          cout << "NO" << endl;
          return 0;
      }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,m;
	cin>>n>>m;
	int ans[4]={-1,-1,-1,-1};
	bool f=true;
	if(m==0)
	{
		if(n==1)
		cout<<0;
		else
		{
			cout<<1;
			for(int i=2;i<=n;i++)
			cout<<0;
		 } 
		 return 0;
	}
	while(m--)
	{
		int s,c;
		cin>>s>>c;
		if(n!=1&&s==1&&c==0)
		f=false;
		if(ans[s]==-1)
		ans[s]=c;
		else
		{
			
			if(ans[s]!=c)
			{
				f=false;
			}
		}	
	}
	    if(!f)
		cout<<-1<<endl;
		else
		{
			int t[100];
			for(int i=1;i<=n;i++)
			{
				if(ans[i]==-1&&i==1)
				cout<<1;
				else if(ans[i]==-1&&i!=1)
				cout<<0;
				else if(ans[i]!=-1)
				cout<<ans[i];
			}
			cout<<endl;
		}
} 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            char[] chars = reader.readLine().toCharArray();

            if (chars[0] == chars[1] || chars[1] == chars[2] || chars[2] == chars[3]) {
                System.out.println("Bad");
            } else {
                System.out.println("Good");
            }
        }
    }

}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

/**
 * @brief Divisor(約数列挙)
 * @docs docs/divisor.md
 */
vector< int64 > divisor(int64 n) {
  vector< int64 > ret;
  for(int64 i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

template< typename T >
T extgcd(T a, T b, T &x, T &y) {
  T d = a;
  if(b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 n;
  cin >> n;
  int64 ans = llinf;
  auto divs = divisor(2*n);
  for(auto d : divs){
    int64 e = 2*n/d;
    if(gcd(d,e) > 1)continue;
    int64 x,y;
    extgcd(d,e,x,y);
    while(x < 0){
      x += e;
      y -= d;
    }
    while(x >= 0){
      x -= e;
      y += d;
    }
    chmin(ans,-d*x);
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e6 + 4;
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;

long double x[N], y[N];

int p[N];

int main () {
	boost;
	int n;
	cin >> n;
	for (int i = 0 ; i < n ; ++ i) {
		cin >> x[i] >> y[i];
		p[i] = i;
	}
	long double sum = 0, cnt = 0;
	do {
		for (int i = 1 ; i < n ; ++ i) {
			sum += sqrt ((x[p[i]] - x[p[i - 1]]) * (x[p[i]] - x[p[i - 1]]) + (y[p[i]] - y[p[i - 1]]) * (y[p[i]] - y[p[i - 1]]));
		}
		++cnt;
	} while (next_permutation (p, p + n));
	cout << fixed << setprecision (8);
	cout << sum / cnt;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int A, B;
	cin >> A >> B;
	for (int i = 1; i <= 100000; i++) {
		if (i * 8 / 100 == A && i / 10 == B) {
			cout << i << endl;
			return;
		}
	}
	cout << -1 << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <functional>
#include <iomanip>
#include <algorithm>
using namespace std;
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()

int main() {
  int a,sum=0;
  cin >> a;
  vi sco(a);
  rep(i,a){
    cin >> sco.at(i);
    sum += sco.at(i);
  }
  int dri,tmp1,tmp2;
  cin >> dri;
  rep(i,dri){
    cin >> tmp1 >> tmp2;
    tmp1--;
    cout << sum - sco.at(tmp1) + tmp2 << endl;
  }
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/


signed main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (i % 2 == 0)cout << s[i];
	}
	cout << endl;
	endre;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int x,t;
    cin >> x >> t;
    cout  << max(x-t,0) << endl;
    return 0;
}

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

/*int linearSearch(int x,int S[],int n){
  int i=0;
  S[n]=x;
  while(S[i]!=x){
    i++;
  }
  if(i==n)
    return -1;
  return i; 
}*/
 
int main(){
    int i,n,S[10000],q,T[10000],sum=0;
    cin>>n;
    for(i=0; i<n; i++){
        cin>>S[i];
    }
    cin>>q;
    for(i=0; i<q; i++){
        cin>>T[i];
    }
    for (int i=0;i<q;i++){
        for (int j=0;j<n;j++){
            if (T[i]==S[j]){
                sum++;
                break;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}   

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
void solve()
{
	int s,w;
  	cin>>s>>w;
  	if(w>=s) cout<<"unsafe";
      else cout<<"safe";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
return 0;
}

Measured memory_bytes: 3616
import math
a = list(map(int,input().split()))
ans = -1
n = a[0] * 12 - 1
for i in range(n,1001):
    a0 = i * 0.08
    a0 = math.floor(a0)
    a1 = i * 0.1
    a1 = math.floor(a1)
    if (a0 == a[0]) and (a1 == a[1]):
        ans = i
        break
print(ans)

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

char s[101];

int main(){
    int n; cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> s[i];
    }
    deque<char> ss;
    vector<char> sp;
    for (int i = 0; i < n; ++i){
        if (s[i] == '('){
            sp.push_back('(');
            ss.push_back('(');
            if (ss.back() == ')'){
                for (char c : ss)
                    cout << c;
                ss.clear();
            }
        }
        if (s[i] == ')'){
            if (sp.empty()){
                ss.push_front('(');
            }
            else{
                sp.pop_back();
            }
            ss.push_back(')');
        }
    }
    if (not sp.empty()){
        for (int i = 0; i < (int)sp.size(); ++i){
            ss.push_back(')');
        }
    }
    for (char c : ss){
        cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, k;
  int i;
  
  scanf("%d %d", &n, &k);
  
  for( i = 0; n > 0; i++ ){
    n /= k;
  }
  
  printf("%d\n", i);
  
  return 0;
}

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

int main(){
    int n ;
    cin >> n ;
    int DP[100005] ;
  	rep(i,100005) DP[i] = 1e9 ;
  	DP[0] = 0 ;
  	int i = 0 ;
  	while( pow(6,i) < 100005 ){
    	rep(j,100005){
          int a = pow(6,i) ;
          int nj = min( j + a, 100005 ) ;
          DP[nj] = min( DP[nj] , DP[j] + 1 ) ;
        }
      	i++ ;
    }
  	i = 0 ;
  	while( pow(9,i) < 100005 ){
    	rep(j,100005){
          int a = pow(9,i) ;
          int nj = min( j + a, 100005 ) ;
          DP[nj] = min( DP[nj] , DP[j] + 1 ) ;
        }
      	i++ ;
    }
  	cout << DP[n] << endl ;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void)
{
	int h, w;
	int i, j;
	int k = 0;	//??¶?\???????.

	scanf("%d %d", &h, &w);

	while (h != 0 && w != 0)
	{
		for (i = 0; i < h; i++)
		{
			for (j = 0; j < w; j++)
			{
				if (k % 2 == 0)
					printf("#");
				else
					printf(".");
				k++;
			}
			printf("\n");
			if (i % 2 == 1)
				k = 0;
			else
				k = 1;
		}
		k = 0;	//?????????
		printf("\n");
		scanf("%d %d", &h, &w);
	}

	return 0;
}

Measured memory_bytes: 572
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		if(k%2==0){
			System.out.print((long)(Math.pow(n/k,3)+Math.pow(n/(k/2)-n/k,3)));
		}else{
			System.out.print((long)(Math.pow(n/k,3)));
		}
	}
}


Measured memory_bytes: 23380
#one, two, three, four, five = map(int, input().split())
#li = list(map(int, input().split()))
def Levenshtein(str1,str2):
  count = 0
  for i in range(len(str1)):
    if str1[i] != str2[i]:
      count += 1
  return count

S = input()
T = input()
min_ = 9999999
for i in range(len(S)-len(T)):
  str1 = S[i:i+len(T)]
  str2 = T
  #print(str1,str2)
  leven = Levenshtein(str1,str2)
  if(leven < min_):
    min_ = leven
if len(S)==len(T):
  if S==T:
    min_=0
  else:
    min_=Levenshtein(S,T)
print(min_)

Measured memory_bytes: 9140
S=input()
N=len(S)
SS=S[0:(N-1)//2]
SSS=S[(N+1)//2:N+1]

for i in range((N-1)//2):
  if S[i]!=S[-1-i]:print('No');exit()
  if SS[i]!=SS[-1-i]:print('No');exit()
  if SSS[i]!=SSS[-1-i]:print('No');exit()
print('Yes')

Measured memory_bytes: 9136
import numpy as np

A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

a = np.array(A)

for i in b:
    a = np.where(a == i, 0, a)

for i in range(3):
    if sum(a[i]) == 0:
        print('Yes')
        exit()
    if sum(a[:,i]) == 0:
        print('Yes')
        exit()

if a[0,0] + a[1,1] + a[2,2] == 0:
    print('Yes')
    exit()

if a[0,2] + a[1,1] + a[2,0] == 0:
    print('Yes')
    exit()

print('No')
        
      

Measured memory_bytes: 27300
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #a = r.split()
    #a, b, c = r.split()
    #a = list(map(int, r.split()))
    a,b = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0

    if a == b:
        print('Draw')
    else:
        if a == 1:
            print('Alice')
        elif b == 1:
            print('Bob')
        elif a > b:
            print('Alice')
        else:
            print('Bob')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
vector<long long> fac;

long long power(long long x,long long y,long long p){
    long long res=1;
    x%=p;
    while(y>0){
        if(y%2)res=(res*x)%p;
        y/=2;
        x=(x*x)%p;
    }
    return res;
}

long long modinverse(long long a,long long p){
    return power(a,p-2,p)%p;
}

long long ncrfermat(int n,int r,int p){
    if(r==0)return 1;
    
    return (((fac[n]*modinverse(fac[r],p))%p)*(modinverse(fac[n-r],p)%p))%p;
}
int main(){
    long long n,k;
    cin>>n>>k;
    fac.resize(n+1);
    fac[0]=1;
    for(long long i=1;i<n+1;i++)fac[i]=(fac[i-1]*i)%1000000007;
    vector<long long > c(n),v(n);
    for(long long z=k-1;z<n;z++){c[z]=ncrfermat(z,k-1,1000000007);}
    for(int z=0;z<n;z++){cin>>v[z];v[z]%=1000000007;}
    sort(v.begin(),v.end());
    long long ans=0;
    for(long long i=n-1;i>=k-1;i--){
        ans+=(c[i]*v[i])%1000000007;
        ans%=1000000007;
    }
    for(long long i=0;n-i>=k;i++){
        ans-=(c[n-i-1]*v[i])%1000000007;
        ans%=1000000007;
    }
    if(ans<0)ans+=1000000007;
    cout<<ans;
    
}

Measured memory_bytes: 2560
import math


def dist(X1, X2):
    distSq = 0
    for x1, x2 in zip(X1, X2):
        d = x1 - x2
        distSq += d * d
    return math.sqrt(distSq)


def main():
    N, D = map(int, input().split())
    pts = []
    for i in range(N):
        X = [int(v) for v in input().split()]
        pts.append(X)

    count = 0
    for i in range(N):
        X1 = pts[i]
        for j in range(i + 1, N):
            X2 = pts[j]
            d = dist(X1, X2)
            if d == int(d):
                count += 1
    print(count)


main()


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

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

    int n = S.length();
    bool tiles[n];
    REP(i, n) tiles[i] = S[i] == '1';

    bool color0 = 1;
    bool color1 = 0;

    int ret0 = 0;
    int ret1 = 0;
    REP(i, n)
    {
        if (tiles[i] != color0)  ++ret0;
        if (tiles[i] != color1)  ++ret1;
        color0 = !color0;
        color1 = !color1;
    }

    cout << min(ret0, ret1) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
	int N;
	cin >> N;
	vector <int> as(N, 1), bs(N, 1), ps(N);
	rep(N, i) {
		cin >> ps[i];
		ps[i]--;
	}

	reverse(all(ps));

	rep(N, i) {
		if (ps[i] != N-1) as[ps[i]+1]+=i+1;
		if (ps[i] != 0) bs[ps[i]-1]+=i+1;
	}
	rep(N-1, i) {
		as[i+1] += as[i];
		bs[N-2-i] += bs[N-1-i];
	}
	rep(N, i) {
		cout << as[i] << ' ';
		if (i == N-1) cout << endl;
	}
	rep(N, i) {
		cout << bs[i] << ' ';
		if (i == N-1) cout << endl;
	}
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 896
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    
    divisors.sort()
    return divisors

n = int(input())
div = make_divisors(n)

ans = float("inf")
for d in div:
    A = d
    B = n // d
    ans = min(ans, max(len(str(A)), len(str(B))))

print(ans)


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	VI h(n);
	rep(i,n) cin >>h[i];
	
	vector<ll> dp(n+4, 1LL<<50); dp[0]=0;
	rep(i, n){
		if(i<n-1) dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] -h[i+1]));
		if(i<n-2) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] -h[i+2]));
	}
	//for(auto x :dp) printf("%lld, ",x); puts("");
	cout << dp[n-1] <<"\n";
	return 0;
}


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

class Program
{

    public static void Main(string[] args)
    {
        Program pg = new Program();
        pg.Exe();
    }

    public void Exe()
    {
        string str = Console.ReadLine();
        string[] strary = str.Split(' ');
        int[] ary = Array.ConvertAll(strary, int.Parse);
        
        int h = ary[0];
        int w = ary[1];
        int k = ary[2];


        char[,] figure = new char[h, w];
        
        int k_cnt = 0;
        int ans = 0;
        for(int i = 0; i < h; i++)
        {
            str = Console.ReadLine();
            for(int m = 0; m < w; m++)
            {
                figure[i, m] = str[m];

            }
        }

        for(int i = 0; i < (1 << h); i++)
        {
            for(int m = 0; m < (1<<w); m++)
            {
                k_cnt = 0;
                for(int h_i = 0; h_i < h; h_i++)
                {
                    for(int w_i = 0; w_i < w; w_i++)
                    {
                        if(((i >> h_i) & 1) == 0 && ((m >> w_i) & 1) == 0 &&
                          figure[h_i, w_i] == '#')
                          {
                              k_cnt++;
                          }
                    }
                }
                if(k_cnt == k)
                {
                    ans++;
                }
            }
        }
        Console.WriteLine(ans);

    }

}



Measured memory_bytes: 27328
N = int(input())
S = str(input())

def count_need(string, from_left=True):
    savings = 0
    ng = 0
    
    if from_left == False:
        key = '('
    else :
        key = ')'

    for s in string:
        if (s == key):
            if savings <= 0: 
                ng += 1
            else:
                savings -= 1
        else:
            savings += 1
    return ng

left_num = count_need(S, from_left=True)
right_num = count_need(S[::-1], from_left=False)

print("("*left_num + S + ")"*right_num)

Measured memory_bytes: 3064
import sys
import collections

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def is_bridge(n, pi, to_info):
	is_a=[-1]*n
	q =collections.deque()
	q.append(0)
	#ex = [p[0]-1, p[1] - 1]
	while q:
		pos = q.popleft()
		for to in to_info[pos]:
			if pos in pi and to in pi:
				continue
			if is_a[to] != -1:
				continue
			is_a[to]=1
			q.append(to)
	
	return min(is_a) == -1


def main():
	#a = int(input())
	n, m = tin()
	#s = input()
	path = []
	to_info = [[] for _ in range(n)]
	for _ in range(m):
		a, b = tin()
		path.append([a-1, b-1])
		to_info[a-1].append(b-1)
		to_info[b-1].append(a-1)
		
	ret = 0
	#pa(path)
	for pi in path:
		if is_bridge(n, pi, to_info):
			#pa(pi)
			ret += 1
	print(ret)
	
	
#+++++
isTest=False

def pa(*vl):
	if not isTest:
		return
	for v in vl:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 68436
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a;
	int test[123456] = { 0 }; cin >> n;
	for (int h = 1; h <= n; h++) {
		cin >> a;
		test[a] = h;
	}
	for (int h = 1; h <= n; h++) {
		cout << test[h] << ' ';
	}
	cout << endl;
	cin >> n;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;
ll dp[105][2][5];
int main(){
  ll x,n; cin >> x >> n;
  set<ll> s;
  rep(i,n){
    ll p; cin >> p;
    s.insert(p);
  }
  rep(i,105){
    ll ans = x - i;
    if(!s.count(ans)){
      cout << ans;
      break;
    }
    ll ans2 = x + i;
    if(!s.count(ans2)){
      cout << ans2;
      break;
    }   
  }
  return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		double k = 100000;
		int T = 0;
		for(int a = 0;a < n;a++){
			k = Math.ceil((k*1.05)/1000);
			k = k*1000;
			T = (int)k;
		}
		System.out.println(T);
	}
}

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

using namespace std;

const int N = 2010;

int d[N], n, x, y;

int f(int l, int r) {
	return (l <= x && r <= x) || (l >= y && r >= y) ? r - l :
		   l <= x && r >= y ? x - y - l + r + 1 : 
		   l >= x && r <= y ? min(l - r - x + y + 1, r - l) : 
		   l <= x           ? x - l + f(x, r) : 
		                      r - y + f(l, y) ; 
}

int main() {
	cin >> n >> x >> y;
	for (int l = 1; l < n; l++)
		for (int r = l + 1; r <= n; r++) {
				d[f(l, r)]++;
		}
	for (int i = 1; i < n; i++)
		cout << d[i] << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] cnt = new int[N];
        for (int i=0;i<M;i++) {
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            cnt[a]++;
            cnt[b]++;
        }
        for (int i=0;i<N;i++) {
            if (cnt[i]%2==1) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
        return;
    }
}

Measured memory_bytes: 50672
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
int fact(int n) 
{ 
    return (n <= 1) ? 1 : n * fact(n - 1); 
} 
  
// A utility function to count smaller characters on right 
// of arr[low] 
int findSmallerInRight(string str, int low, int high) 
{ 
    int countRight = 0, i; 
  
    for (i = low + 1; i <= high; ++i) 
        if (str[i] < str[low]) 
            ++countRight; 
  
    return countRight; 
} 
  
// A function to find rank of a string in all permutations 
// of characters 
int findRank(string str) 
{ 
    int len = (str).size(); 
    int mul = fact(len); 
    int rank = 1; 
    int countRight; 
  
    int i; 
    for (i = 0; i < len; ++i) { 
        mul /= len - i; 
  
        // count number of chars smaller than str[i] 
        // fron str[i+1] to str[len-1] 
        countRight = findSmallerInRight(str, i, len - 1); 
  
        rank += countRight * mul; 
    } 
  
    return rank; 
} 
int main()
{
	int n,i,j;
	cin>>n;
	string s,t;
	char x;
	for(i=0;i<n;i++)
	{
		cin>>x;
		s.pb(x);
	}
	for(i=0;i<n;i++)
	{
		cin>>x;
		t.pb(x);
	}
	cout<<abs(findRank(s)-findRank(t))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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

















int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632