akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int fac[100];
int solve(int num){
  if(num <= 0)return 0;
  int ans = 0;
  drep(i,60,0){
    if(fac[i] > num)continue;
    if(num == 2){
      ans += 3;
      break;
    }
    if(num == 3)break;
    num -= fac[i];
    if(num%2 == 0)ans += fac[i];
  }
  return ans;
}

signed main(){
  fac[0] = 1;
  rrep(i,60)fac[i] = fac[i] = fac[i-1] * 2;
  int a, b, ans = 0;
  cin >> a >> b;
  cout << (solve(b) ^ solve(a-1)) << endl;
  return 0;
}





Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int M=100000;
int main()
{
	int a,b,c,a1,b1,c1,k,i;
	while(cin>>a>>b>>c)
	{
		k=0;
		for(i=1;i<M;i++)
		{
			if(a%2==0&&b%2==0&&c%2==0) k++;
			else break;
			a1=a/2;b1=b/2;c1=c/2;
			a=b1+c1;b=a1+c1;c=a1+b1;
		}
		if(i<M) cout<<k;
		else cout<<-1;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
// const ll INF = 1LL << 60;
const ll INF = 100000000000;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second
 
// rep(i, 0, sz(v)) cout << v[i] << " \n"[i==sz(v)-1];
 
////////////////////////////////////////////////////////
 
ll H, W, k;
Vs s;
 
int main() {
    cin >> H >> W >> k;
    s.resize(H);
    rep(i, 0, H) cin >> s[i];

    ll fa = INF;
    for(int tmp = 0; tmp < (1 << H); tmp++){
        bitset<11> div(tmp);
        int id[H];
        ll c[H];
        rep(i, 0, H) c[i] = 0;

        // id 振り分け
        ll now = 0;
        id[0] = now;
        rep(i, 1, H){
            if(div[i]!=div[i-1]){
                now++; id[i] = now;
            }else id[i] = now;
        }
        now++;
        ll ans = now-1;

        bool f = false;

        rep(w, 0, W){
            rep(h, 0, H) c[id[h]] += ll(s[h][w]-'0');

            //check
            rep(i, 0, now){
                if(c[i] > k){
                    ans++;
                    rep(j, 0, now) c[j] = 0;
                    rep(h, 0, H) c[id[h]] += ll(s[h][w]-'0');
                    rep(j, 0, now){
                        if(c[j] > k) f = true;
                    }
                }
            }
        }
        if(f) continue;
        chmin(fa, ans);
        // if(tmp == 2) rep(i, 0, now) co(c[i]);
    }
    co(fa);

    return 0;
}
 

Measured memory_bytes: 3592
while(True):
    d_set = input()
    d_set = d_set.split()
    n,x = int(d_set[0]),int(d_set[1])
    if n == 0 and x == 0:
        break
    c_set = list(range(1,min(n+1,x+1-3)))
    cnt = 0
    for i in range(len(c_set)):
        c1_set = c_set[i+1:]
        for j in range(len(c1_set)):
            c2_set = c1_set[j+1:]
            for k in range(len(c2_set)):
                if c_set[i] +c1_set[j] + c2_set[k] == x:
                    cnt += 1

    else:
        print(cnt)



Measured memory_bytes: 5600
<?php
$define = explode(' ', trim(fgets(STDIN)));
$cities = $define[0];
$routes = $define[1];

$ways = array();
for ($i=1; $i <= $cities; $i++) {
  $ways[$i] = 0;
}
for ($i=0; $i < $routes; $i++) {
  $tmp = explode(' ', trim(fgets(STDIN)));
  foreach ($tmp as $value) {
    $ways[$value]++;
  }
}
foreach ($ways as $count) {
  echo $count."\n";
}


Measured memory_bytes: 3576
#include <stdio.h>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 0;
  scanf("%lld%lld", &n, &k);
  char s[n + 10];
  bool b = false;
  scanf("%s", s);
  for(i = 1; i < n; ++i) {
    if(s[i] == s[i - 1]) ++ans;
    else if(b) ++ans, b = false;
    else if(k) ++ans, b = true, --k;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define L 200

int main(void){
  int i,n,m,a,b,flag=0,xmax=-100,ymin=100,x[L]={0},y[L]={0};
  scanf("%d %d",&n,&m);
  scanf("%d %d",&a,&b);
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
    if(x[i]>xmax){
      xmax=x[i];
    }
  }
  for(i=0;i<m;i++){
    scanf("%d",&y[i]);
    if(y[i]<ymin){
      ymin=y[i];
    }
  }

  for(i=b;i>a;i--){
    if(i>xmax && i<=ymin){
      flag=1;
      break;
    }
  }
  if(flag==1){
    printf("No War\n");
  }else{
    printf("War\n");
  }
  return 0;
}


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

using namespace std;

#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 REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

int N, M;
V A, Amatch;
VL dp;
map<int, int> match = {{1, 2}, {2, 5}, {3, 5}, {4, 4}, {5, 5},
                       {6, 6}, {7, 3}, {8, 7}, {9, 6}};

int main() {
    cin >> N >> M;
    A.resize(M);
    Amatch.resize(M);
    dp.resize(N + 1);
    VECCIN(A);
    sort(All(A), greater<int>());
    REP(i, M) { Amatch[i] = match[A[i]]; }
    fill(All(dp), -LINF);
    dp[0] = 0;
    REP(i, N + 1) REP(j, M) {
        if(i - Amatch[j] >= 0) dp[i] = max(dp[i], dp[i - Amatch[j]] + 1);
    }
    while(N > 0) {
        REP(j, M) {
            if(N - Amatch[j] >= 0 && dp[N] == dp[N - Amatch[j]] + 1) {
                cout << A[j];
                N -= Amatch[j];
                break;
            }
        }
    }
    cout << "\n";
    return 0;
}


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

int main() {
int h,w;
cin>>h>>w;
char c[h][w];
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        cin>>c[i][j];
    }
    }
for(int i=0;i<h;i++){
    for(int x=0;x<2;x++){
    for(int j=0;j<w;j++){
        cout<<c[i][j];   
    }
    cout<<endl;
    }
    }
    
	return 0;
}


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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 200013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N, M, K;
pii arr[MAXN];
ll fact[MAXN], ifact[MAXN];
ll dp[MAXN][2];
ll ans;

ll expo(ll a, ll e)
{
	if (e == 0) return 1;
	return expo(a * a % INF, e >> 1) * (e & 1 ? a : 1) % INF;
}
ll choose(ll a, ll b)
{
	return fact[a + b] * ifact[a] % INF * ifact[b] % INF;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M >> K;
	FOR(i, 0, K)
	{
		cin >> arr[i].fi >> arr[i].se;
		arr[i].fi--; arr[i].se--;
	}
	arr[K] = {0, 0};
	arr[K + 1] = {N - 1, M - 1};
	K += 2;
	sort(arr, arr + K);
	fact[0] = 1;
	FOR(i, 1, N + M + 1)
	{
		fact[i] = fact[i - 1] * i % INF;
	}
	ifact[N + M] = expo(fact[N + M], INF - 2);
	FORD(i, N + M, 0)
	{
		ifact[i] = ifact[i + 1] * (i + 1) % INF;
	}
	dp[0][1] = 1;
	FOR(i, 1, K)
	{
		FOR(j, 0, i)
		{
			if (arr[j].fi > arr[i].fi || arr[j].se > arr[i].se) continue;
			FOR(k, 0, 2)
			{
				dp[i][k] += dp[j][k ^ 1] * choose(arr[i].fi - arr[j].fi, arr[i].se - arr[j].se);
				dp[i][k] %= INF;
			}
		}
	}
	ans = dp[K - 1][0] - dp[K - 1][1];
	if (ans < 0) ans += INF;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			if (op.equals("?")) break;
			else if(op.equals("+")) System.out.println(a + b);
			else if(op.equals("-")) System.out.println(a - b);
			else if(op.equals("*")) System.out.println(a * b);
			else if(op.equals("/")) System.out.println(a / b);
		}
	}
}

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

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    vector<string> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }

    vector<int> cnt_r(h, 0), cnt_c(w, 0);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '.') {
                cnt_r[i]++;
                cnt_c[j]++;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (cnt_r[i] < w && cnt_c[j] < h) {
                cout << a[i][j];
            }
        }

        if (cnt_r[i] < w) {
            cout << endl;
        }
    }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        
        int r = sc.nextInt();
        System.out.println(r * r);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

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

char s[100001] = {0};
bool canPass[100000]={0};

int main(){
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    scanf("%s",s);
    int aCnt=0,bCnt=0;
    for(int i=0;i<n;++i){
        if(s[i] == 'a' && aCnt+bCnt < a+b){
            canPass[i] = true;
            ++aCnt;
        }else if(s[i] == 'b' && aCnt+bCnt < a+b && bCnt < b){
            canPass[i] = true;
            ++bCnt;
        }
    }
    for(int i=0;i<n;++i){
        if(canPass[i])printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 768
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

a,b,x=mint()
print(b//x-(a-1)//x)

Measured memory_bytes: 69160
#include <bits/stdc++.h>
 
using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
const int MOD = 1000000007;
double PI = 4*atan(1);
 
vi a;
int N, K; 
 
bool test(int x) {
	bitset<5000> posi;
	posi[0] = 1;
	F0R(i,N) if (i != x) posi |= (posi << a[i]);
	FOR(i,max(K-a[x],0),K) if (posi[i]) return 1;
	return 0;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> K; 
	a.resize(N); F0R(i,N) cin >> a[i];
	sort(a.begin(),a.end());
	
	int low = 0, high = N;
	while (low<high) {
		int mid = (low+high)/2;
		if (test(mid)) high = mid;
		else low = mid+1;
	}
	cout << low;
}

Measured memory_bytes: 256
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
if (a1>b1 and a2>b2) or (b1>a1 and b2>a2):
  print(0)
elif abs(a1-b1)*t1>abs(a2-b2)*t2:
  print(0)
elif abs(a1-b1)*t1==abs(a2-b2)*t2:
  print('infinity')
else:
  d1=abs(a1-b1)*t1
  d2=abs(a2-b2)*t2
  l=0
  r=10**18+1
  while r-l!=1:
    mid=(l+r)//2
    if d1*(mid+1)-d2*mid<0:
      r=mid
    else:
      l=mid
  if d1*(l+1)-d2*l==0:
    print(2*l)
  else:
    print(2*l+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 2e5;
int a[mxN+3],b[mxN+3];
int n,m;

int main()
{
	n = read(),m = read();
	for(int i=1; i<=n; i++) {a[i] = read();}
	while(m--)
	{
		for(int i=0; i<=n; i++) b[i] = 0;
		for(int i=1; i<=n; i++) {b[max(0,i-a[i])]++,b[min(n+1,i+a[i]+1)]--;}
		a[0] = b[0]; for(int i=1; i<=n; i++) {a[i] = a[i-1]+b[i];}
		bool ok = true;
		for(int i=1; i<=n; i++) if(a[i]!=n) {ok = false; break;}
		if(ok) {break;}
	}
	for(int i=1; i<=n; i++) printf("%d ",a[i]); puts("");
	return 0;
}

Measured memory_bytes: 5296
import sys
sys.setrecursionlimit(10 ** 5)

input = sys.stdin.readline

N, M = map(int, input().split())

ans = list(range(N))
def root(a):
    if a==ans[a]:
        return a
    else:
        ans[a] = root(ans[a]) 
        return ans[a]

for _ in range(M):
    x, y, _ = map(lambda a: int(a)-1, input().split())
    rx, ry = root(x), root(y)
    if rx != ry:
        ans[ry] = rx

count = 0
for i,a in enumerate(ans):
    count += i==a


print(count)


Measured memory_bytes: 6900
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
const ll INF = 1000000007;

int main() {
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int>l(q), r(q);
	rep(i, q) cin >> l[i] >> r[i];
	vector<int> a(n + 1);
	a[0] = 0;
	a[1] = 0;
	for (int i = 1; i < n; i++) {
		if (s[i - 1] == 'A'&&s[i] == 'C') a[i+1] = a[i] + 1;
		else a[i+1] = a[i];
	}
	rep(i, q) {
		int ansi = a[r[i]] - a[l[i]-1];
		if (l[i] > 1 && s[l[i] - 1] == 'C'&&s[l[i]-2] == 'A') ansi--;
		cout << ansi << endl;
	}
}


Measured memory_bytes: 2176
import numpy as np
import sys

def read_data():
    try:
        LOCAL_FLAG
        import codecs
        import os

        lines = []
        file_path = os.path.join(os.path.dirname(__file__), 'data.dat')
        with codecs.open(file_path, 'r', 'utf-8') as f:
            n_lines = int(f.readline())
            for i in range(n_lines):
                lines.append(f.readline().rstrip("\r\n"))

    except NameError:
        lines = []
        n_lines = int(input())
        for i in range(n_lines):
            lines.append(input())
    return lines

raw_data = read_data()
tarray = []
for each in raw_data:
    tarray.append(each.split())
A = np.array(tarray, dtype='int64')
N = A.shape[0]


def Restoring_Road_Network2():

    not_available = False
    for k in range(0, N):
        for i in range(0, N):
            if(k==i): continue
            for j in range(0, N):
                if((i==j) or (j==k)): continue
                if(A[i][k] + A[k][j] < A[i][j]):
                    not_availabel = True
                if(A[i][k] + A[k][j] == A[i][j]):
                    B[i][j] = 1
                    B[j][i] = 1

    try:
        LOCAL_FLAG
        print(B)
    except NameError:
        pass

    if(not_available):
        print(-1)
    else:
        total_dis = 0
        for i in range(0, N):
            for j in range(i, N):
                if(B[i][j] == 0):
                    total_dis += A[i][j]
        print(total_dis)

def Restoring_Road_Network3():

    import scipy.sparse.csgraph as graph

    MAX = [10000000000]*N  # should be > 2*10**9
    d = np.diag(MAX)
    C = A.copy()
    C += d
    total_dis = 0
    n_path = 0
    for i in range(N-1):
        for j in range(i+1, N):
            dis_two_node = np.min(C[i] + C[j])
            if dis_two_node > C[i,j]:
                total_dis += C[i,j]
                # print(i, j)
            elif dis_two_node < C[i,j]:
                print(-1)
                exit()

    print(total_dis)

def AA():
    import numpy as np

    for i in range(N):
        A[i][i] = 10000000000

    result = 0
    for i in range(N-1):
        for j, d1 in enumerate(A[i][i+1:], start=i+1):
            d2 = np.min(A[i]+A[j])
            # print(A[i][i+1:])
            # print (i, j, d1, d2)
            if d1 >= d2:
                if d1 > d2:
                    print(-1)
                    exit()
            else:
                result += d1
    print(result)

Restoring_Road_Network3()

Measured memory_bytes: 26776
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    int n,d;
    cin>>n>>d;
    int x[n][d];
    int a,i=0, j=0;
    while(i < n && j < d && cin>>a){
        x[i][j] = a;
        j++;
        if(j == d){
            j=0;
            i++;
        }
    }

    double dis;
    int c = 0;
    int sum;
    for(i = 0; i < n; i++){
        for(j = n-1; i < j; j--){
            if(i != j){
                sum = 0;
                for(int p = 0; p < d; p++){
                    sum += pow(x[i][p] - x[j][p],2);
                    
                }
                dis = sqrt(sum);
                if(ceil(dis) == floor(dis)){
                    c++;
                }
            }
        }
    }

    cout<<c<<endl;


    return 0;
}

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}


int main()
{
  ios::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  for(int i = 1; i <= 100000; i++)
  {
    int valA = i * 0.08;
    int valB = i * 0.1;
    if(valA == a && valB == b)
    {
      cout << i << endl;
      return 0;
    }
  } 
  cout << "-1\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f[100][10];
int p[100][11];

int main() {
  int N;
  cin>>N;
  int ans=-1000000000;
  int c=0;
  int a,b;
  for(int i=0;i<N;i++)for(int j=0;j<10;j++)cin>>f[i][j];
  for(int i=0;i<N;i++)for(int j=0;j<11;j++)cin>>p[i][j];
  for(int i=1;i<1024;i++){
    c=0;
    for(int j=0;j<N;j++){
      a=0;
      b=i*2;
      for(int k=0;k<10;k++){
        b/=2;
        a+=f[j][k]*(b%2);
      }
      c+=p[j][a];
  }
  if(c>ans)ans=c;
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
int dp[1001];
int main(){
	int m,a,b,g,n;
	while(cin>>m&&m){
		memset(dp,0,sizeof(dp));dp[0]=1;
		for(int i=0;i<m;i++){
			cin>>a>>b;
			for(int j=1000;j>=0;j--){
				for(int k=1;k<=b;k++){
					if(j+a*k>1000)break;
					dp[j+a*k]+=dp[j];
				}
			}
		}
		cin>>g;
		for(int i=0;i<g;i++){
			cin>>n;
			cout<<dp[n]<<endl;
		}
	}
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
int main(void){
  int n;
  cin >> n;
  int item[n+1];
  int max=0;
  int maxi;
  for(int i=1;i<=n;i++){
    cin >> item[i];
    if(item[i]>max){
      max=item[i];
      maxi=i;
    }
  }
  int sum=0;
  for(int i=1;i<=n;i++){
    if(i!=maxi){
      sum += item[i];
    }else{
      sum += item[i]/2;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import kotlin.math.*

fun main() {
    val (a, b, h, m) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val md = m / 60.0 * 360.0
    val hd = (h * 60 + m) / 720.0 * 360
    val dig = if (abs(hd - md) > 180) {
        360 - abs(hd - md)
    } else {
        abs(hd - md)
    }
    val c = a * sin(Math.toRadians(dig))
    val aa = a * cos(Math.toRadians(dig))
    val d = sqrt(c.pow(2.0) + (b - aa).pow(2.0))
    println(d)
}

Measured memory_bytes: 36632
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)

int arr[100000+50000],n,k;

int dp[150000];

int ans(int ind)
{
    if(ind==n)return 0;
    if(ind>n)return MOD*MOD;

    if(dp[ind]>-1)return dp[ind];


//    dp[ind]=min(abs(arr[ind]-arr[ind+1])+ans(ind+1),abs(arr[ind]-arr[ind+2])+ans(ind+2));
  dp[ind]=MOD*MOD;

  forn(i,ind+1,ind+k)
        dp[ind]=min(dp[ind],abs(arr[ind]-arr[i])+ans(i));
    return dp[ind];
}

signed main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    st(dp,-1);
    st(arr,MOD);
    forn(i,1,n)cin>>arr[i];

    cout<<ans(1);

    

     
     




     return 0;

}

//       g++ -g c2.cpp ; ./a.exe

Measured memory_bytes: 5760
use std::io::*;

fn count_digit(n: &i32) -> i32 {
    let mut x = *n;
    let mut count = 0;
    while 0 < x {
        x /= 10;
        count += 1;
    }
    count
}

fn main() {
    let mut input = String::new();
    stdin().read_line(&mut input);

    let n: i32 = input.trim().parse().unwrap();
    let ans = (1..n+1).filter(|x| count_digit(x) % 2 == 1).count();
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.Scanner


object Main{
  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val s = sc.next()
    (n, s)
  }

  def solve(n: Int, s:String) : String = {
    val nb = s.count(c => c =='B')
    val nr = s.count(c => c =='R')
    if(nr > nb) "Yes" else "No"
  }

  def main(args: Array[String]): Unit = {
    val (n,s) = read()
    println(solve(n,s))
  }
}

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

int main(){
    string S;
    cin >> S;
    int n=S.size();
    
    rep(i, (n-1)/2){
        if(S.at(i)!=S.at(n-i-1)){
            cout << "No" << endl;
            return 0;
        }
    }
    if(n%2==0){
        rep(i, ((n-1)/2-1)/2){
            if(S.at(i)!=S.at((n-1)/2-i-1)){
                cout << "No" << endl;
                return 0;
            }
        }
    }else{
        rep(i, (n-1)/4){
            if(S.at(i)!=S.at((n-1)/2-i-1)){
                cout << "No" << endl;
                return 0;
            }
        }
        
    }
    // for(int i=(n+3)/2-1;i<(n+1)/2+((n-1)/2-1)/2;i++){
    //     if(S.at(i)!=S.at((n+1)/2+n-i-1)){
    //         cout << "No" << endl;
    //         return 0;
    //     }
    // }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3580
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int x;

int solve() {
	int k = 1;
	while ((k * x) % 360 != 0) ++k;
	return k;
}

void run() {
	scanf("%d", &x);
	printf("%d\n", solve());
}

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


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int a,b,c,d;
  cin>>a>>b>>c>>d;

  cout<< ( abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) ? "Yes" : "No" )<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    boolean flag = false;
    for (int i = a; i <= b; i++){
      if (i%K==0){
        flag = true;
      }
    }
    if (flag){
      System.out.println("OK");
    }else{
      System.out.println("NG");
    }
  }
}

Measured memory_bytes: 35708
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define all(x) x.begin(),x.end() 
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int INF = 1e15;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    void solve()
    {
        cin>>n>>k;
        n%=k;
        cout<<min(abs(n-k),n)<<endl;
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 256
n = gets.to_i
inputs = gets.split.map(&:to_i)

dp = Array.new(inputs.size, Float::INFINITY)
dp[0] = 0
dp[1] = (inputs[1] - inputs[0]).abs

(2...n).each do |i|
  dp[i] = [(inputs[i] - inputs[i - 1]).abs + dp[i - 1], (inputs[i] - inputs[i - 2]).abs + dp[i - 2]].min
end

puts dp[n - 1]

Measured memory_bytes: 13316
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
map<long long int,long long int> prime;
void prime_fact(long long int n){
    long long int nc=n;
    long long int i=2;
    while(nc!=1){
        if(i*i>nc) {
            if(prime.count(nc)) break;
            else {prime[nc]=1;}
            break;
        }
        if(nc%i==0){
            long long int count=0;
            while(nc%i==0){
                nc/=i;
                count++;
            }
            if(prime.count(i)) prime.at(i)=max(prime.at(i),count); 
            else{prime[i]=count;}
        }
        i++;
    }
};
int main(){
    int n;
    lli ans=0;
    cin>>n;
    rep(i,n){
        int a;
        cin>>a;
        a--;
        ans+=a;
    }
    out(ans);

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, ans, r;
	cin >> n;

	r = n % 1000;
	if (r == 0) ans = 0;
	else ans = 1000 - r;
	cout << ans << "\n";

		
	return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>

using namespace std;

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

  if(((n + 1) / 2) - k >= 0){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,e,t,x[100005];
ll dp[100005];
int main(){
    scanf("%d%d%d",&n,&e,&t);
    for (int i = 1 ; i <= n; i++){
        scanf("%d",&x[i]);
    }
    int pivot = 0;
    ll mn = 1000000000000000000;
    for (int i = 1; i <= n; i++){
        dp[i] = 1000000000000000000;
        while (pivot < i && 2*(x[i]-x[pivot+1]) > t) {
            mn = min(mn,dp[pivot]-2*x[pivot+1]);
            pivot++;
        }
        dp[i] = min(2*x[i]+mn,dp[pivot]+t);
    }
    printf("%lld",dp[n]+e);
}


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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int n, l;
	cin >> n >> l;
	// n--;
	// l++;
	ll ans = 0;
	vector<int> v;
	for (int i = 0; i < n; ++i)
	{
		ans += l;
		v.pb(l);
		l++;
	}
	int min, minval;
	minval = 1e9;
	for (int i = 0; i < n; ++i)
	{
		// cout << abs(v[i]) << ' ' << abs(minval) << '\n';
		if (abs(v[i]) < abs(minval))
		{
			// cout << "Here";
			minval = v[i];
			// min = v[i];
		}
	}
	// cout << ans << '\n';
	cout << ans - minval;
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        arr: [i64; n],
    }
    let s: i64 =  arr.iter().sum();
    let mut acc = 0;
    println!("{}",
        arr.into_iter().fold(i64::MAX, |m, a| {
            acc += a;
            min(m, (s - 2*acc).abs())
        })
    );
}


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

#define INF (1e9)

using namespace std;

int main() {
    int N, K;
    char S[100000] = {0};
    int L[200001] = {0};

    cin >> N >> K;

    cin >> S;

    int idx = 1;
    int cnt = 1;
    char prev = S[0];
    for (int i = 1; i < N; i++) {
        if(prev == S[i]){
            cnt++;
        }else{
            L[idx] = cnt;
            cnt = 1;
            idx++;
            prev = S[i];
        }
    }

    L[idx] = cnt;
    idx++;

    int first = (S[0] == '0') ? 0 : 1;
    int m = 0;
    for(int i = first; i < idx; i += 2){
        int tmp = accumulate(L + i, L + i + (2 * K + 1), 0);
        m = max(m, tmp);
    }

    printf("%d\n", m);
}


Measured memory_bytes: 1152
n = int(input())
s_list = [input() for _ in range(n)]
 
ab_count = 0
b_start = 0
a_end = 0
concat_max = 0
 
for s in s_list:
    is_b = s[0] == 'B'
    is_a = s[-1] == 'A'
    if is_b:
        b_start = b_start + 1
    if is_a:
        a_end = a_end + 1
    if is_a or is_b:
        concat_max = concat_max + 1
    ab_count = ab_count + s.count('AB')
 
print(ab_count + max(min(min(a_end, b_start), concat_max - 1), 0))

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int dp[2][5005];
const int mod=1e9+7;

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  


    int n;
    cin>>n;
    string s;
    cin>>s;
    int len=s.length();
    s="#"+s;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i&1][j]=dp[(i+1)&1][j+1]*2;
            if(j>=1)
                dp[i&1][j]+=dp[(i+1)&1][j-1];
            if(j==0)
                dp[i&1][j]+=dp[(i+1)&1][j];
            dp[i&1][j]%=mod;
        }
    }
    cout<<dp[n&1][len];
} 


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

using namespace std;

using int64 = long long;

template< typename T >
struct LimitInt
{
  T x;
  const T low, high;

  LimitInt() : x(0), low(numeric_limits< T >::min() + 10), high(numeric_limits< T >::max() - 10) {}

  LimitInt(const T &x) : x(x), low(numeric_limits< T >::min() + 10), high(numeric_limits< T >::max() - 10) {}

  LimitInt &operator+=(const LimitInt &y)
  {
    x = (double) x + y.x > high ? high : x + y.x;
    return (*this);
  }

  LimitInt &operator-=(const LimitInt &y)
  {
    x = (double) x - y.x < low ? low : x - y.x;
    return (*this);
  }

  LimitInt &operator*=(const LimitInt &y)
  {
    x = (double) x * y.x > high ? high : x * y.x;
    return (*this);
  }

  LimitInt &operator/=(const LimitInt &y)
  {
    x /= y.x;
    return (*this);
  }

  LimitInt operator-() const
  {
    return -x;
  }

  LimitInt operator+(const LimitInt &y) const
  {
    LimitInt ret(x);
    ret += y;
    return ret;
  }

  LimitInt operator-(const LimitInt &y) const
  {
    LimitInt ret(x);
    ret -= y;
    return ret;
  }

  LimitInt operator*(const LimitInt &y) const
  {
    LimitInt ret(x);
    ret *= y;
    return ret;
  }

  LimitInt operator/(const LimitInt &y) const
  {
    LimitInt ret(*this);
    ret /= y;
    return ret;
  }

  LimitInt operator==(const LimitInt &y) const
  {
    return (x == y.x);
  }

  LimitInt operator!=(const LimitInt &y) const
  {
    return (x != y.x);
  }

  LimitInt operator<(const LimitInt &y) const
  {
    return (x < y.x);
  }

  LimitInt operator>(const LimitInt &y) const
  {
    return (x > y.x);
  }

  LimitInt operator<=(const LimitInt &y) const
  {
    return (x <= y.x);
  }

  LimitInt operator>=(const LimitInt &y) const
  {
    return (x >= y.x);
  }

  T get() const
  {
    return (x);
  }
};

int main()
{
  int N, K;
  int64 W[100000], D[100000];
  cin >> N >> K;
  for(int i = 0; i < N; i++) {
    cin >> W[i] >> D[i];
  }

  auto check = [&](int64 v)
  {
    LimitInt< int64 > x;
    for(int i = 0; i < N; i++) {
      x += max(0LL, (v - W[i]) / D[i] + 1);
    }
    return (x.get() >= K);
  };

  int64 ok = 1999999999000000000LL, ng = -1;
  while(ok - ng > 1) {
    int64 mid = (ok + ng) / 2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }

  cout << ok << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

struct UnionFind{
    vector<ll> par;
    vector<ll> sizes;
    UnionFind(ll n) : par(n), sizes(n, 1) {
        rep(i,n) par[i] = i;
    }
    int find(ll x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(ll x, ll y) {
        return find(x) == find(y);
    }

    ll size(ll x) {
        return sizes[find(x)];
    }
};


queue<int> que[100010];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, n){
        int k;
        cin >> k;
        rep(j, k){
            int l;
            cin >> l;
            l--;
            que[l].push(i);
        }
    }

    UnionFind tree(n);

    rep(i, 100010) {
        int sz = que[i].size();
        if (sz < 2) continue;
        int now = que[i].front();
        que[i].pop();
        while(!que[i].empty()){
            int nxt = que[i].front(); que[i].pop();
            tree.unite(now, nxt);
            now = nxt;
        }
    }

    if (tree.size(0) == n) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 72268
A = []
for _ in range(3):
    a1, a2, a3 = map(int, input().split())
    A += [(a1, a2, a3)]

n = int(input())
B = []
for _ in range(n):
    B += [int(input())]

for i in range(3):
    A += [(A[0][i], A[1][i], A[2][i])]
A += [(A[0][0], A[1][1], A[2][2])]
A += [(A[0][2], A[1][1], A[2][0])]

ans = 'No'
for x in A:
    _ans = [1 for _x in x if _x in B]
    if len(_ans) == 3:
        ans = 'Yes'
        break

print(ans)


Measured memory_bytes: 38256
def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv

def inverse(a, mod):
    a %= mod
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod

n, k = map(int, input().split())
mod = 10 ** 9 + 7
fac, inv = factorial(n, mod)

if k == 1:
    print(n * (n - 1) // 2 % mod)
    quit()

if k >= n:
    k = n - 1
ans = 0
for i in range(0, k + 1):
    nci = fac[n] * inv[n-i] % mod * inv[i] % mod
    mci = fac[n-1] * inv[n-1-i] % mod * inv[i] % mod
    ans = (ans + nci * mci % mod) % mod
print(ans)


Measured memory_bytes: 79320
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{	int n,i;
	cin >> n; int A[n+5];int x=1;
  	for(i=0;i<n;i++)
    {  cin>>A[i];
     	if(A[i]==x)x++;
    }
  	if( x==1)cout<<"-1";
  else cout<< n-x+1;
  
  
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




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

using namespace std;

#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second

typedef long long ll;

const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;
const int mod = N9 + 2;

int n, ans = 999999;

string s, t, f;

int main()
{
    cin >> n >> s >> t;
    for1 (i, n, 0)
    {
        f = s + t.substr(i, n - i);
//        cout << i << " " << f << " " << f.substr(f.size() - n, n) << "\n";
        if (f.substr(f.size() - n, n) == t)
            return !(cout << f.size());
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h> 
int main(){
  int X;
  scanf("%d",&X);
  int i,p,d,m=0;
  for(i=1;i<=X;i++){
    d=i;
    for(p=1;p<=X;p++){
      d=d*i;
      if(m<=d&&d<=X){
      m=d;
      }
      
      }  
    }  
 
  printf("%d",m);       
}

Measured memory_bytes: 128