akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define debug(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 4005;

inline int input() {
	int x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = (ll) res * x % mod;
		x = (ll) x * x % mod, y >>= 1;
	} return res;
}

inline void chkmin(int &x, int y) { x = x < y ? x : y; }
template <class T> T sqr(T x) { return x * x; }

struct DSU {
	int fa[N];
	void init(int n) { for (int i = 1; i <= n; ++i) fa[i] = i; }
	int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
	bool con(int x, int y) { return find(x) == find(y); }
	void merge(int x, int y) { fa[find(x)] = find(y); }
};

DSU S;
int n, m, tot;
long long sum, x, cnt2, cnt3;
int head[N], ne[N], to[N], val[N], cnte;
struct Edge { int u, v, len; } e[N];
bool vis[N];

inline void AddEdge(int x, int y, int z) {
	ne[++cnte] = head[x], head[x] = cnte, to[cnte] = y, val[cnte] = z;
	ne[++cnte] = head[y], head[y] = cnte, to[cnte] = x, val[cnte] = z;
}

inline bool cmp(Edge x, Edge y) { return x.len < y.len; }

int dfs(int u, int v, int fa) {
	int tmp;
	if (u == v) return 0;
	for (int i = head[u]; i; i = ne[i]) {
		if (to[i] == fa) continue;
		if (~(tmp = dfs(to[i], v, u)))
			return max(val[i], tmp);
	}
	return -1;
}

inline int get_max(int x, int y) {
	return dfs(x, y, 0);
}

signed main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
//	freopen("log", "w", stderr);
#endif
	ios::sync_with_stdio(false);

	cin >> n >> m >> x;
	for (int i = 1; i <= m; ++i)
		cin >> e[i].u >> e[i].v >> e[i].len;
	if (n == 1 || m < n - 1) return puts("0"), 0;

	S.init(n);
	sort(e + 1, e + m + 1, cmp);
	for (int i = 1; i <= m; ++i) {
		if (!S.con(e[i].u, e[i].v)) {
			AddEdge(e[i].u, e[i].v, e[i].len);
			S.merge(e[i].u, e[i].v);
			sum += e[i].len;
			vis[i] = true;
		}
	}

	if (sum > x) return puts("0"), 0;

	for (int i = 1; i <= m; ++i)
		if (!vis[i]) {
			ll New = sum + e[i].len - get_max(e[i].u, e[i].v);
			if (New == x) ++cnt2;
			else if (New > x) ++cnt3;
		}

	ll res = (ll) (Power(2, cnt2) - 1) * Power(2, cnt3) % mod * 2 % mod;
	if (x == sum) (res += (Power(2, m) + mod - Power(2, m - n + 2)) % mod) %= mod;
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 384
# coding: utf-8

if __name__ == "__main__":
    
    raw = input()
    N, L = [int(f) for f in raw.split(" ")]
    
    str_list = []
    for i in range(N):
        raw = input()
        str_list.append(raw)
        
    sorted_str = sorted(str_list)
    join_str = "".join(sorted_str)
    
    print(join_str)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
int H;
void MaxHeap(int *A, int root){
  int l=2*root;
  int r=2*root+1;
  int largest;
  // choice left, myself, and right
  if((l<=H) && (A[l] > A[root])) largest=l;
  else largest=root;
  if((r<=H) && (A[r] > A[largest])) largest=r;

  //exchange node in case of child is bigger than node of i
  if(largest!=root) {
    //    cout << "hoge" << endl;
    swap(A[root], A[largest]);
    MaxHeap(A, largest);
  }
}

int main(){
  cin >> H;
  int A[2*H];
  A[0]=0;
  for(int i=1;i<=H;i++) cin >> A[i];
  for(int i=H/2;i>0;i--) MaxHeap(A,i);
  for(int i=1;i<=H;i++) cout << " " << A[i];
  cout << endl;
  return 0;
}



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

// #define int long long
#define endl '\n'
int32_t main()
{

   int a,b;
   cin>>a>>b;
   int ans=0;
   if(a>b)
   	{ans+=a;a--;
   	}
   	else
   	{
   		ans+=b;
   		b--;
   	}
   	ans+=max(a,b);
   	cout<<ans;
   	return 0;
}


Measured memory_bytes: 3640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
 
using namespace std;
 
#define INF 1000000000
#define EPS 1e-9
#define PI acos(-1)
 
typedef long long ll;
typedef pair<int, int> P;
 
#define MAX_N 200001

int N;
struct Edge{
  int a,b,cost;
}edge[MAX_N];

bool comp(const Edge& e1, const Edge& e2){
  return e1.cost < e2.cost;
}

int par[MAX_N], R[MAX_N], sz[MAX_N];

void init(){
  for(int i = 0; i < N; i++){
    par[i] = i;
    R[i] = 0;
    sz[i] = 1;
  }
}

int find(int x){
  if(x == par[x])
    return x;
  else
    return par[x] = find(par[x]);
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y)
    return;
  if(R[x] < R[y]){
    par[x] = y;
    sz[y] += sz[x];
  }
  else{
    par[y] = x;
    sz[x] += sz[y];
    if(R[x] == R[y])
      R[x]++;
  }
}

ll solve(){
  init();
  ll ans = 0;
  sort(edge, edge+N-1, comp);

  for(int i = 0; i < N-1; i++){
    int a = edge[i].a;
    int b = edge[i].b;
    int cost = edge[i].cost;
    ans += (ll)sz[find(a)] * (ll)sz[find(b)] * (ll)cost;
    unite(a,b);
  }

  return ans;

}


int main(){

  cin >> N;
  for(int i = 0; i < N-1; i++){
    cin >> edge[i].a >> edge[i].b >> edge[i].cost;
  }

  cout << solve() << endl;

  return 0;

}

Measured memory_bytes: 5864
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	if (n < 1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI l,r;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  l=r=VI(n+2,0);
  forn(i,n)
    cin>>l[i+1];
  forn(i,n)
    cin>>r[i+1];
  r[0]=r[1];
  l[n+1]=l[n];
  const in mdl=1000000007LL;
  in w=1;
  in ex;
  in mx;
  for(in i=1;i<=n;++i){
    ex=-1;
    mx=1e18;
    if(l[i]>l[i-1])
      ex=l[i];
    else
      mx=l[i];
    if(r[i]>r[i+1]){
      if(ex!=-1 && ex!=r[i])
	w=0;
      ex=r[i];
    }
    else
      mx=min(mx,r[i]);
    if(ex!=-1){
      if(ex>mx)
	w=0;
    }
    else
      w*=mx;
    w%=mdl;
  }
  cout<<w<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
int mod=1000000007;
int main()
{
    int n,m;
    int a[100005]= {0};
    cin>>n>>m;
    int b,c[100005];
    int f=1;
    for(int i=1; i<=m; i++)
    {
        scanf("%d",&b);
        a[b]=1;
        if(a[b-1]==1)
        {
            f=0;
            break;
        }
    }
    if(a[1]==0)
    {
        c[1]=1;
        if(a[2]==0)
            c[2]=2;
        else
            c[2]=0;
    }
    else
    {
        c[1]=0;
        if(a[2]==0)
            c[2]=1;
        else
            c[2]=0;
    }
    for(int i=3; i<=n; i++)
    {
        if(a[i]==0)
            c[i]=(c[i-1]+c[i-2])%mod;
        else
            c[i]=0;
    }
    if(!f)
        cout<<0;
    else
        cout<<c[n];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

vector<int> adja[101];
int d[101], f[101], cnt;

void dfs(int u) {
    d[u] = ++cnt;
    for (auto v : adja[u]) {
        if (d[v] > 0)
            continue;
        dfs(v);
    }
    f[u] = ++cnt;
}

int main() {
    int n, k, u;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        adja[u].resize(k);
        for (int j = 0; j < k; ++j) {
            cin >> adja[u][j];
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (d[i] == 0)
            dfs(i);
        cout << i << " " << d[i] << " " << f[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
L = [INT() for _ in range(5)]

C = min(L)
l = L.index(C) 
r = 4 - l

print(-(-N//C)+l+r)

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) A[i] -= (i + 1);
  sort(A.begin(), A.end());

  int64_t answer = 0;
  int b = 0;
  if (A.size() % 2 == 0) {
    b = (A[A.size() / 2 - 1] + A[A.size() / 2]) / 2;
  } else {
    b = A[A.size() / 2];
  }

  for (int i = 0; i < N; i++) {
    answer += abs(A[i] - b);
  }
  printf("%ld\n", answer);

  return 0;
}


Measured memory_bytes: 1792
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);　iをstringでsに変換

  char　小文字のほうが32大--------------------大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

  int i = sqrt (n) で、ｎの平方根(9に対する3)をiに入れる

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除
  */
int a=0, b=0, c = 0;
string s = "";

int main(void) {
	//vector,set,map,stack,queue,deque,priority_queue

	int n, five = 0, two = 0,ten = 0;
	cin >> n;
	vint s(n);
	int sum = 0, min = 0;
	rep(i, n) {
		cin >> s[i];
		sum += s[i];
	}
	sort(s);
	reve(s);
	int i = 0;
	while (true) {
		if (s[i] % 10 != 0)min = s[i];
		if (n-1==i)break;
		i++;
	}
	if (sum % 10 != 0)cout << sum << rt;
	else {
		if(min==0){cout<<0<<endl;return 0;}
      if ((sum - min) >= 0) cout << sum - min << rt;
      		
    }

	please AC;
}


Measured memory_bytes: 256
x, n = map(int, input().split())

if n == 0:
    print(x)
    exit()

pn = list(map(int, input().split()))

diff = 0

while True:
    if x - diff not in pn:
        print(x-diff)
        exit()
    elif x + diff not in pn:
        print(x+diff)
        exit()
    diff += 1

Measured memory_bytes: 8952
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int k;
  cin >> k;
  if(k%2 == 0 || k%5 == 0){
    cout << "-1" << endl;
    return 0;
  }
  //  long long int l;
  long long int box;
  long long int h=1;
  long long int f=1;
  long long int v = 9*k;
  long long int s;
  if(k%7 == 0){
    v = v/7;
  }else{
    v = v;
  }
  
  for(int i=1; i<1000000; i++){
    // h = h*10;
    // h = h+1;
    // box = h*7;
    f = f*10;
    f = f%v;
    if(f == 1){
      cout << i << endl;
      return 0;
    }
  }
}


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

int main(void){
    string s;
    cin>>s;
    int n = s.size();
    int l,r;
    rep(i,n){
        if(s[i]=='A') {
            l=i;
            break;
        }
    }
    rep(i,n){
        if(s[i]=='Z') r=i;
    }
    cout<<r-l+1<<endl;
    return 0;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int x[200005], y[200005], suff[200005], id[200005], sz[200005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    vector<int> perm(n);
    iota(perm.begin(), perm.end(), 0);
    sort(perm.begin(), perm.end(), [&] (int a, int b) {
        return x[a] < x[b];
    });

    for (int i=n-1; i>=0; i--)
        suff[i] = max(y[perm[i]], suff[i+1]);
    int cur = -1, mn = INT_MAX;
    for (int i=0; i<n; i++) {
        if (mn > suff[i])
            cur++;
        id[perm[i]] = cur;
        sz[cur]++;
        mn = min(mn, y[perm[i]]);
    }

    for (int i=0; i<n; i++)
        cout << sz[id[i]] << "\n";

    return 0;
}


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

int main(){
    while(1){
        int E;
        cin >> E;
        int mn = INF;
        if(E==0) break;
        for(int z=0;z*z*z<=E;++z){
            int z3 = z*z*z;
            for(int y=0;y*y<=E-z3;++y){
                int y2 = y*y;
                int x = E - z3 - y2;
                if(x < 0) continue;
                mn = min(mn,y+z+x);
            }
        }
        cout << mn << endl;
    }
    return 0;
}


Measured memory_bytes: 3000
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    map<int, int> cnt;
    for(int a : A){
        cnt[a]++;
    }

    vector<int> B;
    for(auto p : cnt){
        B.push_back(p.second);
    }

    sort(B.begin(), B.end());

    int ans = 0;
    if(B.size() <= K){
        ans = 0;
    }else{
        for(int i = 0; i < B.size()-K; i++){
            ans += B[i];
        }
    }

    cout << ans << endl;


    return 0;
}

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

#define MP make_pair
#define PB push_back
#define ll long long int
#define F first
#define S second
#define MAX(x,y) (x)>(y)?(x):(y)
#define MIN(x,y) (x)<(y)?(x):(y)
#define REP(i,n) for(i=0;i<(n);i+=1)
#define REP1(i,n) for(i=1;i<(n);i+=1)
#define REPr(i,n) for(i=n-1;i>=0;i-=1)
#define LOOP(i,n) for(i=1;i<=(n);i+=1)

typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int>::iterator sit;
typedef unordered_set<int>::iterator usit;
typedef multiset<int>::iterator msit;
typedef unordered_multiset<int>::iterator umsit;
typedef vector<ll>::iterator vllit;

ll MAX3(ll x, ll y, ll z){
    ll temp = max(x,y);
    return max(temp,z);
}

//cin.ignore(numeric_limits<streamsize>::max(),'\n');

const int N = 100001;
ll dp[3][N];
vi v[3];
int n;

/*void solve(){

    int i,j,x;
    dp[0][0]=v[0][0];
    dp[1][0]=v[1][0];
    dp[2][0]=v[2][0];
    REP1(i,n){
        REP(x,3){
            for(j=0;j!=x && j<3;j+=1){
                dp[x][i] = max(dp[x][i], dp[j][i-1] + v[x][i] );
            }
        }
    }
}*/
void solve(){

    int i,j;
    dp[0][0]=v[0][0];
    dp[1][0]=v[1][0];
    dp[2][0]=v[2][0];
    REP1(i,n){
        dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + v[0][i];
        dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + v[1][i];
        dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + v[2][i];
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    int i,a,b,c;
    REP(i,n){
        cin>>a>>b>>c;
        v[0].PB(a);
        v[1].PB(b);
        v[2].PB(c);
    } 
    solve();
    ll ans = 0;
    REP(i,3){
        ans = max(ans, dp[i][n-1]);
    }
    cout<<ans<<endl;
    
    return 0;
}

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

#define int long long
#define LCM(x,y) ((x*y)/__gcd(x,y))

using namespace std;

int solve(int x, int a, int b){
	
	return x - (x/a + x/b - x/LCM(a,b));
	
}


int32_t main()
{
int a,c,b,d; cin>>a>>b>>c>>d;

int ans1 = solve(a - 1,c,d);
int ans2 = solve(b,c,d);

cout << ans2 - ans1;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define M 1000000007
#define allv v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define mx 1000010

int main(){
	IOS;
	string s;cin>>s;
	ll c=0;vll v;
	rep(i,0,s.length()){
		if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')c++;
		else c=0;v.pb(c);
	}v.pb(c);
	ll mx1=-1;
	rep(i,0,v.size())mx1=max(mx1,v[i]);
	cout<<mx1;
	return 0;
}



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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    string X;
    cin >> X;
    int N = X.size();
    stack<char> st;
    for(char x : X){
        if(x == 'T' and (st.empty() or st.top() == 'T')){
            st.push(x);
        }else if(x == 'T' and st.top() == 'S'){
            st.pop();
        }else if(x == 'S'){
            st.push(x);
        }
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 720
import math
import numpy as np

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

pq = [map(int, input().split()) for _ in range(N)]
p, q = [list(i) for i in zip(*pq)]

d=[]
for i in range(N):
    ans = p[i]*p[i]+q[i]*q[i]
    d.append(ans)


ans1 = np.sqrt(d)



ans2 = [i for i in ans1 if i <= D]

final = len(ans2)
print(final)

Measured memory_bytes: 148576
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

int main(){
    int h,w; cin>>h>>w;
    int a;
    vector<int> v[4];
    int l=0;
    FOR(i,0,h){
        int k=0;
        FOR(j,0,w){
            cin>>a;
            a+=k;
            if(j==w-1){a+=l; l=0;}
            if(a%2){
                if(j==w-1){
                    if(i<h-1){
                        v[0].PB(i+1);
                        v[1].PB(j+1);
                        v[2].PB(i+2);
                        v[3].PB(j+1);
                        l++;
                    }
                }else{
                    v[0].PB(i+1);
                    v[1].PB(j+1);
                    v[2].PB(i+1);
                    v[3].PB(j+2);
                }
                k=1;
            }else{
                k=0;
            }
        }
    }
    co(v[0].size());
    FOR(i,0,v[0].size()){
        printf("%d %d %d %d\n",v[0][i],v[1][i],v[2][i],v[3][i]);
    }
}


Measured memory_bytes: 4196
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int cnt;
bool first;
const int INF = 1000000;

class Park{
public:
  int leftTime[2];
  int ID[2];
  bool car[2];

  Park(){
    rep(i, 2)car[i] = false;
  }
  
  void next(){ 
    rep(i, 2){
      if(car[i]){
	leftTime[i]--;
      }
    }
    rep(i, 2){
      if(car[i] && leftTime[i] <= 0){
	if(first){
	  first = false;
	}
	else cout << ' ';
	cnt++;
	cout << ID[i]+1;
	car[i] = false;
      }
      if(car[i])return;
    }
    return;
  }
  
  void put(int id, int time){
    int tmp = 1;
    if(car[1])tmp = 0;
    car[tmp] = true;
    ID[tmp] = id;
    leftTime[tmp] = time;
    return;
  }

  int diff(int time){
    return abs(time - leftTime[1]);
  }
};
  
main(){
  
  int n, m;
  while(cin >> m >> n){
    if(m + n == 0)break;
    Park p[m];
    first = true;
    int time = 0, id = 0;
    cnt = 0;
    queue<int> ID, Data;
    while(cnt < n){
      if(id < n && time == 0){
	int tmp;
	cin >> tmp;
	ID.push(id);
	Data.push(tmp);
	id++;
      }

      while(!ID.empty()){
	int next = -1;
	rep(i, m){
	  if(p[i].car[1])continue;
	  next = i;
	  break;
	}
	if(next != -1){
	  p[next].put(ID.front(), Data.front());
	  ID.pop();Data.pop();
	  continue;
	}
	
	int mini = INF, nTime = Data.front();
	rep(i, m){
	  if(p[i].car[0])continue;
	  if(p[i].leftTime[1] < nTime)continue;
	  if(mini > p[i].diff(nTime)){
	    mini = p[i].diff(nTime);
	    next = i;
	  }
	}
	if(next != -1){
	  p[next].put(ID.front(), Data.front());
	  ID.pop();Data.pop();
	  continue;
	}
	
	rep(i, m){
	  if(p[i].car[0])continue;
	  if(mini > p[i].diff(nTime)){
	    mini = p[i].diff(nTime);
	    next = i;
	  }
	}
	if(next != -1){
	  p[next].put(ID.front(), Data.front());
	  ID.pop();Data.pop();
	  continue;
	}
	break;
      }
      time++;
      if(time == 10)time = 0;
      rep(i, m)p[i].next();
    }
    cout << endl;
  }	  
}

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define FILL(a, b) memset(a, b, sizeof(a))

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
const int INF = 0x3F3F3F3F;
const int MOD = 1e9 + 7;
const int MAX = 2e5 + 5;

int R;

int main() {
    
    scanf("%d", &R);
    if (R < 1200) {
        printf("ABC\n");
    } else if (R < 2800) {
        printf("ARC\n");
    } else {
        printf("AGC\n");
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int n;
	cin >> n;
	rep(i, n) {
    	cout << "ACL"; 
    }
  	cout << endl;
}

Measured memory_bytes: 3580
//coded b vishal mourya - the legendary coder
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define f(a,b) for(ll i = a ; i < b ; i++ )
#define fj(a,b) for(ll j = a ; j < b ; j++ )
#define fk(a,b) for(ll k = a ; k < b ; k++ )
#define fasthoja ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

ll highestPowerof2(ll n) { 
   ll p = (ll)log2(n); 
   return (ll)pow(2, p);  
} 

int main(void){
    fasthoja;
    
    ll h; cin >> h;
    if( h == 1 ) cout << "1\n";
    else {
//    	while( __builtin_popcount(h) != 1 ) {
//    		h--;	
//		}
		
		cout <<  highestPowerof2(h) * 2 - 1 << "\n";
	} 

 return 0;
}


Measured memory_bytes: 4088
//PLUS ULTRA

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define mp make_pair
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)

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

const int N = 1e5 + 10 , mod =  1000000007;



int main(){
    SPEED;

    int n , k; cin >> n >> k;

    ll h[n];

    forn(i,0,n){
    	cin >> h[i];
    }

    ll dp[n]  ;
    dp[0] = 0;
    // forn(i,1,min(k+1,n)){
    // 	dp[i] = abs(h[i] - h[0]);

    // 	forn(j,1,i){
    // 		dp[i] = min(dp[i] , dp[i-1] + abs(h[i] - h[j]));
    // 	}

    // }

    forn(i,1,n){
    	dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
    	nfor(j,i-2,max(i-k ,0 )){
    		dp[i] = min(dp[i] , dp[j] + abs(h[i] - h[j]));
    	} 
    }


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



    
    return 0;
}
      
       


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define N 100000
typedef long long int lli;
lli a[3][N];
lli dp[3][N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	for(int i=0; i<n; i++)
		for(int j=0; j<3; j++) cin>>a[j][i];
	for(int j=0; j<3; j++) dp[j][0] = a[j][0];
	for(int  i=1; i<n; i++){
		for(int j=0; j<3; j++)
			for(int k=0; k<2; k++)
				dp[j][i] = max(dp[j][i], dp[(j+k+1)%3][i-1] + a[j][i]);
	}
	lli ans = -1;
	for(int i=0; i<3; i++) ans = max(ans, dp[i][n-1]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <complex>
#include <ctime>
#include <cstdlib>
using namespace std;

// * XY座標
#define X real()
#define Y imag()

// * 点の表現
typedef complex<double> P;

// * 許容する誤差ε
const double EPS = 1e-8;
// * Infinity
const double INF = 1e12;
// * 円周率
const double PI = acos(-1.0);

// * 2つのスカラーが等しいかどうか
bool equal(double a, double b){
	return ( fabs( a - b ) < EPS );
}

// * 内積 (dot product) : a・b = |a||b|cosΘ
double dot(P a, P b){
	return (a.real() * b.real() + a.imag() * b.imag());
}

// 外積 (cross product) : a×b = |a||b|sinΘ
double cross(P a, P b){
	return (a.real() * b.imag() - a.imag() * b.real());
}

// a1,a2を通る直線 と b1,b2を通る直線 が平行かどうか返す.
bool is_parallel(P a1, P a2, P b1, P b2){
	return equal( cross(a1-a2, b1-b2), 0.0 );
}

// a1,a2を通る直線 と b1,b2を通る直線の交点計算
P intersection(P a1, P a2, P b1, P b2){
	P a = a2 - a1;
	P b = b2 - b1;
	return a1 + a * cross(b, b1-a1) / cross(b, a);
}

int main(){
	int n;
	scanf("%d", &n);
	
	vector<P> vp(n);
	for(int i=0 ; i < n ; i++ ){
		double x, y;
		scanf("%lf %lf", &x, &y);
		vp[i] = P(x,y);
	}
	// used[i] := 辺 i について平行で長さが等しい辺が存在するかどうか
	bool used[51] = {false};
	for(int i=0 ; i < n/2 ; i++ ){
		if( used[i] ) continue;
		int j = i + n/2;
		// 辺の長さ
		double a = abs(vp[i] - vp[(i+1)%n]);
		double b = abs(vp[j] - vp[(j+1)%n]);
		bool flag = is_parallel( vp[i], vp[(i+1)%n], vp[j], vp[(j+1)%n]);
		if( flag && equal(a,b) ){
			used[i] = used[j] = true;
		}
	}
	
	int k = 0;
	for(int i=0 ; i < n ; i++ ){
		if( used[i] ){
			k++;
		}
	}
	// 頂点数が奇数 かつ すべての辺について平行で長さの等しい辺が存在するときは点Pが存在する.
	if( n%2 == 1 ){
		printf("NA\n");
	}else if( k == n ){
		P p = intersection(vp[0], vp[n/2], vp[1], vp[n/2+1]);
		printf("%.6f %.6f\n", p.X, p.Y);
	}else{
		printf("NA\n");
	}
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll M=3002;
const ll mod=998244353;
ll a[M];
ll dp[M],tp[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,s;
	cin>>n>>s;
	for(ll i=1;i<=n;i++)
		cin>>a[i];
	ll ans=0;
	dp[0]=1;
	for(ll i=1;i<=n;i++)
	{
		memset(tp,0,sizeof(tp));
		tp[a[i]]=i;
		for(ll j=a[i]+1;j<=s;j++)
			tp[j] = dp[j-a[i]];
		for(ll j=0;j<=s;j++)
			dp[j]=(dp[j]+tp[j])%mod;
		ans=(ans+dp[s])%mod;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 384
// Don't be dead serious about your life --  it's just like a program
//while(!(succeed==try()));

// Program showing a policy-based data structure. 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
using namespace std; 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
//value at 3rd index in sorted array==*p.find_by_order(3) p.insert()
//index of number 6 ==p.order_of_key(6)
typedef  long long  int ll;
typedef long double ld;
//fundamentals
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back
#define lb(v,val)  (lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (upper_bound(v.begin(),v.end(),val)-v.begin())
#define line cout<<endl;
#define sortv(v) sort(v.begin(),v.end())
#define lcm(a,b) (a*b/gcd(a,b))
#define all(v) ((v).begin(),(v).end())
#define v_at_in(n) *p.find_by_order(ll n)
//loops
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define f0 for(ll i=0;i<n;i++)
#define f1 for(ll i=1;i<=n;i++)
#define fr for(ll i=n-1;i>=0;i--)
//input of array
#define inarray ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
// starter pack
#define test ll T;cin>>T;while(T--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//maximum and minimum
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(a,max3(b,c,d))
#define min4(a,b,c,d) min(a,min3(b,c,d))
//some values
#define PI 3.14159265
const ll MOD=1000000000+7;
const ll MOD1 = 998244353;
const ll Val=1000000000;
ll no_of_divisors(ll n){ 
 ll c = 0; 
 for (ll i = 1; i <= sqrt(n); i++) { 
  if (n % i == 0){ 
   if(n/i==i)
    c=c+1;
   else
    c=c+2;
  }
 }
 return c; 
} 

ll pwr(ll x, ll y){
 ll r=1;
 while(y>0){
  if(y&1)
   r=r*x;
  x*=x;
  y>>=1;
 }
 return r;
}
 
ll pwrm(ll x, ll y, ll m){
 x%=m;
 ll r=1;
 while(y>0){
  if(y&1)
   r=r*x%m;
  x=x*x%m;
  y>>=1;
 }
 return r;
} 
int isPrime(ll n) 
{ 
    // Corner cases
    if (n <= 1) 
        return 0; 
    if (n <= 3) 
        return 1; 
  
    if (n % 2 == 0 || n % 3 == 0) 
        return 0; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return 0; 
  
    return 1; 
} 
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
// Shuru karte hai bina kisi backchodi ke_________
int main()
{
#ifdef ENABLE_FILE_IO
freopen("in", "r", stdin);
freopen("out", "w", stdout);
#endif
  fast;
  //string s;cin>>s;
   {
    new_data_set p; 
      int n=5;
      f0{
          int x;
          cin>>x;
          if(x==0)
          {cout<<i+1;
          break;}
      }

      
      //cout<<o;
   }
    return 0;
}
// End of program Logic

Measured memory_bytes: 3632
import sys
import unittest
import random

T = 26


def solve(d, c, s):
    best = [0] * d
    last = [-1]*T

    for i in range(d):
        max_v = -float('inf')
        for j in range(T):
            v = s[i][j] + c[j] * (i - last[j])
            if max_v < v:
                max_v = v
                best[i] = j
        last[best[i]] = i

    score = get_score(d, c, s, best)
    for i in range(1500):
        a = random.randint(0, d-1)
        b = random.randint(0, T-1)
        old = best[a]
        best[a] = b
        t_score = get_score(d, c, s, best)
        if t_score > score:
            score = t_score
        else:
            best[a] = old
    return best


def get_score(d, c, s, t):
    last = [-1]*T
    total = 0
    for i in range(d):
        total += s[i][t[i]]
        last[t[i]] = i
        for j in range(T):
            total -= c[j] * (i - last[j])
    return total


def main():
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for i in range(d)]
    t = solve(d, c, s)
    print(get_score(d, c, s, t), file=sys.stderr)
    for i in range(d):
        print(t[i]+1)


if __name__ == "__main__":
    main()


class Test(unittest.TestCase):
    def test_score(self):
        pass


Measured memory_bytes: 16944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, M;
int a[100010], b[100010];
int cnt[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    cnt[a[i]]++;
    cnt[b[i]]++;
  }
  int yes = 1;
  for (int i = 1; i <= N; i++) {
    yes &= cnt[i] % 2 == 0;
  }
  cout << (yes ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 1408
n, _ = map(int, input().split())
arr = list(map(str, input().split()))

can_use = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
can_use -= set(arr)

price = set(str(n))

while price - can_use:
    n += 1
    price = set(str(n))

print(n)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,l;
string s[105];
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> l;
	for(int i = 1; i <= n; i++)
		cin >> s[i];
	sort(s + 1,s + n + 1);
	for(int i = 1; i <= n; i++)
		cout << s[i];
	return 0;
}

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

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];

  sort(d.begin(), d.end());
  cout << d[n/2] - d[n/2 - 1] << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>

int gcd(int n1,int n2)
{
	int d=1;
	while(d!=0){
		d=n1%n2;
		n1=n2;
		n2=d;
	}
	return n1;
}

int main(void)
{
	int i,n,x,y1,y2,ans;
	scanf("%d%d%d",&n,&x,&y1);
	y1=abs(y1-x);
	if(n==1){
		printf("%d",y1);
		return 0;
	}
	for(i=0;i<n-1;i++){
		scanf("%d",&y2);
		y2=abs(y2-x);
		ans=gcd(y1,y2);
		y1=ans;
	}
	printf("%d",ans);
	return 0;
}
	

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] h = new int[200001];
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            int a = scan.nextInt();
            A[i] = a;
            h[a] += 1;
        }
        int max_first = 0;
        int max_second = 0;

        for (int i = 200000; 0 < i; i--) {
            if (h[i] == 0) {
                continue;
            }
            if (max_first == 0) {
                max_first = i;
                if (h[i] == 1) {
                    continue;
                }
            }
            if (max_second == 0) {
                max_second = i;
                break;
            }
        }
        for (int i = 0; i < N; i++) {
            if (A[i] == max_first) {
                System.out.println(max_second);
            } else {
                System.out.println(max_first);
            }
        }
    }
}


Measured memory_bytes: 103780
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

    typedef long long ll;
    #define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
    #define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

    ll pow(ll a, ll n) { //compute a^n with o(logn)
        ll res = 1;
        while (n > 0) {
            if (n & 1) res = res * a;
            a = a * a;
            n >>= 1;
        }
        return res;
    }

    ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
        ll res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    int main(){
        ll h,w,k;
        ll cnt = 0;
        cin >> h >> w >> k;
        char c[h+1][w+1];
        rep1(i,h){
            rep1(j,w){
                cin >> c[i][j];
            }
        }
    
        // {0, 1, ..., n-1} の部分集合の全探索
        for(int bith = 0; bith < (1<<h); ++bith){
            vector<int> H;
            for (int i = 0; i < h; ++i) {
                if(bith & (1<<i)) H.push_back(i+1);
            }

            for (int bitw = 0; bitw < (1<<w); ++bitw){
                int black = 0;
                vector<int> W;
                for(int i = 0; i < w; ++i) {
                    if (bitw & (1<<i)) W.push_back(i+1);
                }

                for (int i = 0; i < (int)H.size(); ++i) {
                    int hindex = H[i];
                    for (int j = 0; j < (int)W.size(); ++j) {
                        int windex = W[j];
                        if(c[hindex][windex] == '#') black++;
                    }    
                }
                if(black == k) cnt++;
            }
        }
        cout << cnt << endl;
        return 0;
    }

Measured memory_bytes: 3180
#include<bits/stdc++.h>
//#define int long long
#define rep(i, l, r) for(int i = l; i <= r; ++ i)

inline int read() 
{
	char cc = getchar(); int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = -flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - 48; cc = getchar();}
	return cn * flus;
}

const int MAXN = 1e6 + 10, INF = 2147483647;
const int Mod = 998244353, G = 3;

int n, d;
char s[MAXN];

signed main()
{
	n = read();
	int ans(0);
	scanf("%s", s + 1);
	int l = 1, r = n;
  while (l <= r) {
    while (s[l] != 'W' && l <= n) {
      l++;
    }
    while (s[r] != 'R' && r > 0) {
      r--;
    }
    if (l <= r) {
      s[l] = 'R';
      s[r] = 'W';
      ans++;
    }
  }
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3988
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n-1);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<n-1;i++) cin>>c[i];

    int v=0;
    for(int i=0;i<n;i++){
        v+=b[a[i]-1];
        if(i==0) continue;
        if(a[i]==a[i-1]+1) v+=c[a[i-1]-1];
    }

    cout<<v<<endl;

	return 0;
}


Measured memory_bytes: 256
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

a,b,c,d = ip()
print(max(a*c,a*d,b*c,b*d))
    


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<int> x(N);
  REP(i, N) cin >> x[i];
  lint rest = 0;
  lint ans = 1;
  REP(i, N) {
    rest++;
    if(x[i] <= rest*2-2) {
      ans = ans * rest % MOD;
      rest--;
    }
  }
  FOR(i, 1, rest+1) ans = ans * i % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

var grid [][]string

func main() {
	sc.Split(bufio.ScanWords)

	H := nextInt()
	W := nextInt()

	grid = make([][]string, H+2)

	for i := 0; i < H+2; i++ {
		grid[i] = make([]string, W+2)
		for j := 0; j < W+2; j++ {
			grid[i][j] = "@"
		}
	}

	for i := 1; i < H+1; i++ {
		line := nextLine()
		for j, l := range strings.Split(line, "") {
			grid[i][j+1] = l
		}
	}

	// for i := 1; i < H+1; i++ {
	// 	for j := 1; j < W+1; j++ {
	// 		fmt.Print(grid[i][j])
	// 	}
	// 	fmt.Println()
	// }

	for i := 1; i < H+1; i++ {
		for j := 1; j < W+1; j++ {
			count := 0
			if grid[i][j] == "#" {
				continue
			}

			if grid[i-1][j] == "#" {
				count++
			}

			if grid[i+1][j] == "#" {
				count++
			}

			if grid[i+1][j-1] == "#" {
				count++
			}

			if grid[i+1][j+1] == "#" {
				count++
			}

			if grid[i][j-1] == "#" {
				count++
			}

			if grid[i][j+1] == "#" {
				count++
			}

			if grid[i-1][j+1] == "#" {
				count++
			}

			if grid[i-1][j-1] == "#" {
				count++
			}

			grid[i][j] = strconv.Itoa(count)
		}

	}

	for i := 1; i < H+1; i++ {
		for j := 1; j < W+1; j++ {
			fmt.Print(grid[i][j])
		}
		fmt.Println()
	}

}


Measured memory_bytes: 768
a, b = map(int, input().split())

aa = set()
bb = set()

waru = 2
while waru ** 2 <= a:
    if a % waru == 0:
        aa.add(waru)
        a = a // waru
        continue
    waru += 1

aa.add(a)
aa.add(1)

waru = 2
while waru ** 2 <= b:
    if b % waru == 0:
        bb.add(waru)
        b = b // waru
        continue
    waru += 1

bb.add(b)
bb.add(1)


print(len(aa & bb))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,m;cin>>h>>w>>m;
  map<pair<int,int>,int>baku;
  map<int,int>bh;
  map<int,int>bw;
  map<int,int>bhmax;
  map<int,int>bwmax;
  map<int,int>bh_flag;
  map<int,int>bw_flag;
  int tmp1,tmp2;
  for(int i=0;i<m;i++){
    cin>>tmp1>>tmp2;
    baku[{tmp1,tmp2}]=1;
    if(bh.count(tmp1))bh.at(tmp1)++;
    else bh[tmp1]=1;
    if(bw.count(tmp2))bw.at(tmp2)++;
    else bw[tmp2]=1;
  }
  int ansh=0,answ=0;
  for(auto b:baku){
    if(bh_flag.count(b.first.first))continue;
    if(ansh<bh.at(b.first.first)){
      ansh=bh.at(b.first.first);
    }
    bh_flag[b.first.first]=1;
  }
  vector<int>bhh;
  vector<int>bww;
  for(auto b:baku){
    if(bh.at(b.first.first)==ansh){
      bhmax[b.first.first]=1;
    }
  }
  for(auto b:baku){
    if(bw_flag.count(b.first.second))continue;
    if(answ<bw.at(b.first.second)){
      answ=bw.at(b.first.second);
    }
    bw_flag[b.first.second]=1;
  }
  for(auto b:baku){
    if(bw.at(b.first.second)==answ){
      bwmax[b.first.second]=1;
    }
  }
  int flag=-1;
  int count=0;
  for(auto bhi:bhmax){
    for(auto bwi:bwmax){
      count++;
      if(!baku.count({bhi.first,bwi.first})||count>m){flag=0;break;}
    }
  }
  cout<<ansh+answ+flag<<endl;
}

Measured memory_bytes: 106724
#include<bits/stdc++.h>
using namespace std;
int dp[1010][1010];
int main()
{
	int n,m,q,i,x,y,j,k;
	scanf("%d%d%d",&n,&m,&q);
	memset(dp,0,sizeof(dp));
	for(i=1; i<=m; i++)
	{
		scanf("%d%d",&x,&y);
		dp[x][y]++;
	}
	for(j=1; j<n; j++)
		for(i=1; i+j<=n; i++)
		{
			k=i+j;
			dp[i][k]=dp[i][k]+dp[i+1][k]+dp[i][k-1];
			if(j>1)dp[i][k]-=dp[i+1][k-1];
		}
	while(q--)
	{
		scanf("%d%d",&x,&y);
		printf("%d\n",dp[x][y]);
	}



	return 0;
}

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

static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
    public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq) => new HashSet<T>(seq);
}
static class MyMath
{
    static public long GCD(long a, long b) => (a < b) ? GCD(b, a) : ((b == 0) ? a : GCD(b, a % b));
    static public long LCM(long a, long b) => (a > b) ? (a / GCD(a, b) * b) : (b / GCD(a, b) * a);
    static private readonly long _m = 1000000000 + 7;
    static public long Mod(long val) => (val % _m + _m) % _m;
    static private long extGCD(long a, long b, ref long x, ref long y) => (b == 0) ? (a + (x = 1) * 0 + (y = 0) * 0) : (extGCD(b, a % b, ref y, ref x) + (y -= a / b * x) * 0);
    static public long ModInverse(long a, long dummy1 = 0, long dummy2 = 0) => extGCD(a, _m, ref dummy1, ref dummy2) * 0 + Mod(dummy1);    
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        var ND = Console.ReadLine().ToIntArray();
        int N = ND[0];
        int D = ND[1];

        Console.WriteLine((int)Math.Ceiling(N / (double)(2 * D + 1)));
    }
}

Measured memory_bytes: 13268