akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

struct UnionFind {
  vector<int> data;
  int group_count;
  UnionFind(int size) : group_count(size), data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
        group_count -= 1;
        if (data[y] < data[x]) swap(x, y);
        data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
    int N; cin >> N;
    vector<pair<int,int>> points;
    vector<pair<int,int>> vecx; // x座標、頂点の番号
    vector<pair<int,int>> vecy; // y座標、頂点の番号
    REP(i,N){
        int x, y; cin >> x >> y;
        points.push_back(make_pair(x,y));
        vecx.push_back(make_pair(x,i));
        vecy.push_back(make_pair(y,i));
    }
    sort(all(vecx)); sort(all(vecy));
    UnionFind uf(N);
    REP(i,N-1){
        if(vecx[i].first==vecx[i+1].first){
            uf.unionSet(vecx[i].second, vecx[i+1].second);
        }
        if(vecy[i].first==vecy[i+1].first){
            uf.unionSet(vecy[i].second, vecy[i+1].second);
        }
    }
    vector<set<int>> x_count(N);
    vector<set<int>> y_count(N);
    REP(i,N){
        x_count[uf.root(i)].insert(points[i].first);
        y_count[uf.root(i)].insert(points[i].second);
    }
    ll ans = 0;
    REP(i,N){
        if(i!=uf.root(i)) continue;
        ans += (ll)x_count[i].size()*y_count[i].size()-uf.size(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16992
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;
 
//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;
 
//少数点表示
//cout << std::fixed << std::setprecision(14) << 値
 
int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(),l.end());
    int cnt=0;
    rep(i,n-2){
        rep1(j,i+1,n-1){
            rep1(k,j+1,n){
                if(l[i]<l[j] && l[j]<l[k] && l[i]+l[j]>l[k] && l[i]+l[k]>l[j] &&l[j]+l[k]>l[i]){
                cnt++;
                //cout << l[i]<<","<<l[j]<<","<<l[k]<<endl;
                } 
            }
        }
    }
    cout << cnt <<endl;
    
    return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<cstdio>

using namespace std;

int main() {
	int n, q, com, x, y;
	int A[100000];

	cin >> n >> q;

	for (int i = 0; i < n; i++) {
		A[i] = 2147483648 - 1;
	}

	
	for (int i = 0; i < q; i++) {

		int min = n + 1;
		A[min] = 2147483648 - 1;

		cin >> com >> x >> y;

		if (com == 0) {
			A[x] = y;
			//cout << A[x] << endl;
		}
		else {
			if (x == y) {
				cout << A[x] << endl;
			}
			else {
				for (int j = x; j <= y; j++) {
					if (A[j] < A[min]) {
						min = j;
						//cout << min << endl;
					}
				}
				cout << A[min] << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3480
#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>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
	mint p(int n, int k) {
		return fact[n] * ifact[n - k];
	}
}c(1000005);
using namespace std;
int main() {
	int N,M;
	cin >> N >> M;
	mint ans = 0;

	for (int i = 0; i < N + 1; ++i) {
		mint now = c(N, N - i);
		now *= c.p(M, N);
		now *= c.p(M - i, N - i);
		if (1 == (i & 1)) {
			now = -now;
		}
		ans += now;
	}
	
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 18608
#include <iostream>
#include <limits.h>
#include <stdio.h>

using namespace std;

int npow_2(int t, int k) {
  int tmp;
  int i = 0;
  
  while (t < k) {
    i++;
    t *= 2;
  }
  return i;
}
  

int main(void) {
  int n, k;
  int cur, r, i;
  long double sum = 0.0;
  long double b, d;
  
  cin >> n >> k;
  d = 1.0 / n;
  cur = npow_2(1, k);
  if (1 < k) {
    b = 1.0;
    for (i = 0; i < cur; i++) {
      b /= 2;
    }
    sum += b * d;
    for (i = 2; i <= n && i < k; i++) {
      r = npow_2(i, k);
      if (r < cur) {
        b *= 2;
        cur = r;
      }
      sum += b * d;
    }
  }
  
  if (n - k >=0) {
    sum = sum + (n - k + 1) * d;
  }
  
  printf("%.10llf\n", sum);
  
  return 0;
}
  


Measured memory_bytes: 256
program abc121b
  integer n, m, c, i, ans
  integer, allocatable :: a(:), b(:)
  read *, n, m, c
  allocate(a(m), b(m))
  read *, b
  ans = 0
  do i = 1, n
     read *, a
     if (dot_product(a, b) + c > 0) ans = ans + 1
  end do
  print *, ans
end program abc121b


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

using namespace std;

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

  vector<long long> a;

  for (int i = 1; i <= 9; i++) a.push_back(i);
  int i = 0;
  while (a.size() < 100000) {
    long long num = a.at(i);
    long long tmp = a.at(i) % 10;
    i++;
    for (int j = 0; j <= 9; j++) {
      if (abs(tmp - j) <= 1) {
        a.push_back(num * 10 + j);
      }
    }
  }
  cout << a.at(k - 1);
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define mp make_pair

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

void Main()
{
	int a;
  	cin >> a;
	cout << (a+1)/2 << endl;
	return;
}

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

Measured memory_bytes: 256
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
 
s = readChar()
if len(s)==1:
	print(1)
	exit()
b="-1"
ans=0
l = [""]
while len(s)>1:
	if l[-1]!=s[:1]:
		l.append(s[:1])
		s = s[1:]
	else:
		l.append(s[:2])
		s = s[2:]
if s!="":
	l.append(s)
del l[0]

#print(l)
if l[-1]==l[-2]:
	del l[-1]

print(len(l))

Measured memory_bytes: 14768
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
int line(const void*a,const void*b)
{
	return *(int *)a-*(ll *)b;
}
int main()
{
	ll s1[100010];
	ll judgesum[100010];
	ll a,n,sum;
	while(scanf("%lld",&n)!=EOF)
	{
		sum=0;
		for(a=1;a<=n;a++)
			scanf("%lld",&s1[a]);
		qsort(s1+1,n,sizeof(s1[1]),line);
		memset(judgesum,0,sizeof(judgesum));
		judgesum[1]=s1[1];
		for(a=2;a<=n;a++)
			judgesum[a]=judgesum[a-1]+s1[a];
		sum=1;
		for(a=n-1;a>=1;a--)
		{
			if(2*judgesum[a]>=s1[a+1])
				sum++;
            else break;
		}
		printf("%lld\n",sum);
	}
	return 0;
}


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

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

  vector<int> v(n, 0);
  vector<int> ans(0);
  vector<int> res(n);

  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
int count = 0;
  for(int i = n - 1; i >= 0; i--){
    if(i >= n / 2){
      if(v[i] == 1){  res[i] = 1; count++;}
    }
    else{
      int sum = 0;
      
      for(int j = n - 1 - (n % (i + 1)); j > i; j -= i + 1){
        if(res[j] == 1){ sum++; }
        
      }
      if(sum % 2 != v[i]){ res[i] = 1; count++;}
    }
    
  }

cout << count << endl;
int d = 0;
 for(int i = 0; i < n; i++){
   if(res[i] == 1){
     if(d != count - 1){cout << i + 1 << " "; d++;}
     else{cout << i + 1 << endl;}
     }
    }

}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int N, K;

signed main() {
	cin >> N >> K;

	int ans = 0;
	while (1) {
		if (N == 0) break;
		N /= K;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

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

int n, m, a[10];

int main(){
    cin >> n >> m;
    for (int i = 0; i < m; i++) cin >> a[i];
    for (int i = n; ; i++){
        string s;
        stringstream ss;
        ss << i;
        ss >> s;
        bool check = true;
        for (int j = 0; j < s.size(); j++)
            for (int k = 0; k < m; k++)
                if (s[j] - '0' == a[k]) check = false;
        if (check){
            cout << s;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
main(){
  int n, m, d, v, sum;
  
  while(cin>>n>>m, n){

    int ma[100]={};
  
    for(int i=0;i<n;i++){
      cin>>d>>v;
      ma[d-1]=max(ma[d-1], v);
    }
    
    sum=0;
    for(int i=0;i<m;i++) sum+=ma[i];

    cout<<sum<<endl;
  }
  
  return 0;
}

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

#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

ll gcdll(ll a, ll b){
    if(!b) return a;
    return gcdll(b, a%b);
}

int gcd(int a, int b){
    if(!b) return a;
    return  gcd(b, a%b);
}

void seive(int n){
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;

    for(int i=2; i*i<=n; i++){
        if(is_prime[i]){
            for(int j=i*i; j<=n; j+=i){
                is_prime[j] = false;
            }
        }
    }
}

vector<int> constructZFunc(string s){
    int n = s.size();
    vector<int> z(n);
    int l, r;
    l = r = 0;
    z[0] = 0;
    rep(i, 1, n-1){
        z[i] = 0;
        if(i<=r){
            z[i] = min(r-i+1, z[i-l]);  /// initialization, req. for linear time approach.
        }
        while(i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if(i+z[i]-1 > r){
            r = i+z[i]-1;
            l = i;
        }
    }
    return z;
}

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

    int h, a;
    cin>>h>>a;
    cout<<(h/a + (h%a != 0));

    return 0;
}



Measured memory_bytes: 256
N = int(input())
cnt = [0] * (10 ** 4 + 1)
for x in range(1, 3333):
    for y in range(1, 3333):
        for z in range(1, 3333):
            check = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if check > 10000:
                break
            else:
                cnt[check - 1] += 1
for i in range(N):
    print(cnt[i])


Measured memory_bytes: 69124
from collections import deque

n, m = map(int,input().split()) # nは部屋の数、mは通路の数
path = [[] for _ in range(n)] # 隣接リスト

for _ in range(m):
    a, b = map(int,input().split())
    path[a-1].append(b)
    path[b-1].append(a)

ans=[None]*n
ans[0]=0


queue = deque([1])
while queue:
    v = queue.popleft()
    for i in path[v-1]:
        if ans[i-1] is None:
            ans[i-1] = v
            queue.append(i)

if None in ans:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(ans[i])

Measured memory_bytes: 33896
#include<bits/stdc++.h>
#define A puts("Yes"),exit(0)
#define B puts("No"),exit(0)
using namespace std;
const int maxn = 100000 + 10;
const int maxm = 100000 + 10;

int n, m, h[maxn], ecnt, deg[maxn], S1, S2;
struct enode{
	int v, n;
	enode() {}
	enode(int _v, int _n):v(_v), n(_n) {}
}e[maxm << 1];

inline void addedge(int u, int v) { ecnt ++; e[ecnt] = enode(v,h[u]); h[u] = ecnt; }

int vis[maxn];
void dfs(int u, int fa) {
	vis[u] = 1;
	for(int i = h[u];~ i;i = e[i].n) {
		int v = e[i].v;
		if(v == fa) continue;
		if(v == S1) A;
		if(vis[v] || v == S2) continue;
		dfs(v,u);
	}
}

int main() {
	scanf("%d%d", &n, &m); ecnt = 0;
	memset(h,-1,sizeof(h));
	for(int i = 1;i <= m;i ++) {
    int u, v;
		scanf("%d%d", &u, &v);
		addedge(u,v);
		addedge(v,u);
		deg[u] ++; deg[v] ++;
	}
	int cnt4 = 0, flag = 0; S1 = -1, S2 = -1;
	for(int i = 1;i <= n;i ++) {
		if(deg[i] & 1) B;
		if(deg[i] < 4) continue;
		if(deg[i] >= 6) flag = 1;
		if(deg[i] == 4) {
			cnt4 ++;
			if(~ S1) S2 = i;
			else S1 = i;
		}
	}
	if(flag || cnt4 > 2) A;
	if(cnt4 < 2) B;
	dfs(S1,0);
	B;
	return 0;
}


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

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}


int main(){
  ll A, B;
  cin >> A >> B;
  
  cout << lcm(A,B) << endl;
}
  


Measured memory_bytes: 256
n,l,t=map(int,input().split())
xw=[list(map(int,input().split())) for _ in [0]*n]

first_x=xw[0][0]
first_w=xw[0][1]

right=[]
left=[]

for x,w in xw:
    if w==1:
        right.append(x)
    else:
        left.append(x)

if first_w==1:
    left=[(i-first_x)/2 for i in left]
    right.reverse()
    right=[(l+first_x-i)/2 for i in right]
else:
    right=[(l+first_x-i)/2 for i in right]
    right.reverse()
    left=[(i-first_x)/2 for i in left[1:]]+[l/2]
    
ll=len(left)
lr=len(right)

def search(cnt):
    w=first_w
    if ll==0 or lr==0:
        return None
    elif cnt==0:
        return [0,0,0]
    elif w==1:
        right_temp=((cnt//2+cnt%2-1)//ll)*(l/2)+left[(cnt//2+cnt%2-1)%ll]
        left_temp=max((((cnt-2)//2)//lr),0)*(l/2)+right[((cnt-2)//2)%lr]*(cnt!=1)
    else:
        left_temp=((cnt//2+cnt%2-1)//lr)*(l/2)+right[(cnt//2+cnt%2-1)%lr]
        right_temp=max((((cnt-1)//2)//ll),0)*(l/2)+left[((cnt-2)//2)%ll]*(cnt!=1)
    return [left_temp+right_temp,right_temp,left_temp]

def b_search(a,b,p,value):
    med=(a+b)//2
    if a==b:return a
    if a+1==b:
        if value(b)[0]<=p:return b
        else:return a
    elif value(med)[0]<=p:return b_search(med,b,p,value)
    else:return b_search(a,med-1,p,value)

if ll==0 or lr==0:
    last=((first_x+t*int((-first_w+1.5)*2))%l+l)%l
else:
    a=b_search(0,10**9,t,search)
    b=search(a)
    if (a+first_w)%2==1:
        b[1]+=t-b[0]
    else:
        b[2]+=t-b[0]
    last=int(((first_x+b[1]-b[2])%l+l)%l)
    
ans=sorted([((x+t*int((-w+1.5)*2))%l+l)%l for x,w in xw])
    
for i in range(n):
    if last==ans[i]:
        if i==n-1:
            break
        elif ans[i+1]!=last:
            break
        else:
            if (a+first_w)%2==1:
                i+=1
                break
            else:
                break
for j in ans[i:]+ans[:i]:
    print(j)

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    ll h; cin >> h;

    ll ans = 0;
    ll cnt = 1;
    while(0 < h){
        h /= 2;
        ans += cnt;
        cnt *= 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3528
#include<bits/stdc++.h>
#define lli long long double 
using namespace std;

const double INF= 1e9 +5;
typedef std::vector<int> vi;
typedef pair<int,int> ii;

int main() {
    
    int n,d;
    cin>>n>>d;
    d=2*d+1;
    int t=n%d;
    int a=n/d;
    if(t>0)
    {
        cout<<a+1<<endl;
    }
    else
    {
        cout<<a<<endl;
    }
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e3+10;

int main() {
	char c;
	cin>>c;
	if(c >= 'A'&&c <= 'Z') cout<<"A";
	else if(c >= 'a'&&c <= 'z') cout<<"a";
	return 0;
}

Measured memory_bytes: 3620
N, K = map(int,input().split())
d = []
A = []
for i in range(K):
  d.append(input())
  A.append(input().split())
count = ['No'] * N


for i in A:
  for j in range(int(d[A.index(i)])):
    for k in range(1, N + 1):
      if int(i[j]) == k:
        count[k-1] = 'OK'
 
print(N - count.count('OK'))

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

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

    int need_l = 0;
    int p = 0;
    for (int i = 0; i < N; i++) {
        if (S.at(i) == '(') p++;
        else {
            if (p == 0) need_l++;
            else p--;
        }
    }
    int need_r = p;

    string res = "";
    for (int i = 0; i < need_l; i++) res += '(';
    res += S;
    for (int i = 0; i < need_r; ++i) res += ')';
    cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

int main(){
	int n;
	scanf("%d", &n);
	if(n<1200) printf("ABC\n");
	else printf("ARC\n");

	return 0;
}

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

const int N=1e5+10;

int n,a[3][N];
int main(){
  cin>>n;
  for(int j=0;j<3;j++)
    for(int i=1;i<=n;i++){
      cin>>a[j][i];
    }
  for(int j=0;j<3;j++)
    sort(a[j]+1,a[j]+n+1);
  long long ans=0;
  for(int pos=1,i1=0,i2=1;pos<=n;pos++){
    while (i1<n&&a[0][i1+1]<a[1][pos]) i1++;
    while (i2<=n&&a[1][pos]>=a[2][i2]) i2++;
    ans+=1LL*i1*(n-i2+1);
  }
  cout<<ans;
}


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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def bit_count(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

r,d,x = inputIL()

for i in range(10):
  new_x = x*r-d
  x = new_x
  print(x)

Measured memory_bytes: 72964
#include <iostream>
using namespace std;
struct dice{
    int x[6];
    
    void roll(char c){
        int tmp;
        if(c == 'E'){
            tmp = x[0];
            x[0] = x[3];
            x[3] = x[5];
            x[5] = x[2];
            x[2] = tmp;
        }
        if(c == 'N'){
            tmp = x[0];
            x[0] = x[1];
            x[1] = x[5];
            x[5] = x[4];
            x[4] = tmp;
        }
        if(c == 'S'){
            tmp = x[0];
            x[0] = x[4];
            x[4] = x[5];
            x[5] = x[1];
            x[1] = tmp;
        }
        if(c == 'W'){
            tmp = x[0];
            x[0] = x[2];
            x[2] = x[5];
            x[5] = x[3];
            x[3] = tmp;
        }
        if(c == 'R'){
            tmp = x[1];
            x[1] = x[2];
            x[2] = x[4];
            x[4] = x[3];
            x[3] = tmp;
        }
    }
    int top(void){
        return x[0];
    }
    int right(void){
        return x[2];
    }
    int left(void){
        return x[3];
    }
    int front(void){
        return x[1];
    }
};

int main(void){
    dice d1, d2;
    for(int i = 0; i < 6; i++){
        cin >> d1.x[i];
    }
    for(int i = 0; i < 6; i++){
        cin >> d2.x[i];
    }
        
    if(d2.left() == d1.top())   d2.roll('E');
    if(d2.right() == d1.top())  d2.roll('W');
    for(int j = 0; j < 4; j++){
        if(d2.top() != d1.top())
            d2.roll('N');
    }
    for(int j = 0; j < 4; j++){
        if(d2.front() != d1.front())
            d2.roll('R');
    }
    if(d1.top() == d2.top() && d1.right() == d2.right() && d1.front() == d2.front())
        cout << "Yes" << endl;    
    else
        cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int a, b, c; cin >> a >> b >> c;
    cout << max(0, c - (a-b)) << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 123;
int h[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%d", &h[i]);
    int ans = 0;
    for (int i = 0; i < N;) {
        if (!h[i]) {
           i++;
           continue;
        }
        int cur = i, mn = MAXN;
        while (cur < N && h[cur]) {
              mn = min(mn, h[cur]);
              cur++;
        }
        for (int j = i; j < cur; j++) {
            h[j] -= mn;
        }
        ans += mn;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
l(i,0,n)
{
    cin>>a;
    if(i%2==0&&a%2!=0)
    {
        d++;
    }
}cout<<d<<endl;
}


Measured memory_bytes: 3536
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
// #define fill(x, v) memset(x, v, sizeof(x))
#define FER(i,a,b) for(int i=int(a); i< int(b); ++i)
#define IFR(i,a,b) for(int i=int(a); i>=int(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
/*
// #define N 21000000
// #define M 19
// #define mod3 9
#define mod  998244353
#define mod1 1000000007
#define mod2 1000000009
*/
#define mody 998244353
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 3000000000000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<vi> vv;
typedef vector<ii> vii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}
/*
inline ll add(ll a, ll b) { return a+b < mod? a+b : a+b-mod;}
inline ll rem(ll a, ll b) { return a >= b? a - b: a- b + mod;}
inline ll mul(ll a, ll b) { return (long long) a*b%mod;}
inline void Mul(ll &a, ll b) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p){
    ll ret;
    for(ret = 1; p; p>>=1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
    return ret;
}
*/

inline void read(ll &x){cin>>x;}

int main(){
	fastio;
	ll n; read(n);
	vi tnt;
	ll top = sqrt(n) + 1;
	FER(i, 1, top){
		if(n%i == 0){
			tnt.pb(n/i);
			tnt.pb(i);
		}
	}
	for(auto xd: tnt){
		ll a= xd, b = n/xd;
		if(a >= 1 and a <= 9 and b >= 1 and b <= 9){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
const int INF = 1<<20;
const int N = 101;
int cost[N][N];
int tim[N][N];
using namespace std;
int main()
{
	int n, m, a, b, co, ti,r;
	while (1){
		cin >> n >> m;
		if (n == 0 && m == 0)return 0;
		for (int i = 0; i < N; i++){
			for (int i2 = 0; i2 < N; i2++){
				cost[i][i2] = INF;
				tim[i][i2] = INF;
			}
		}
		for (int i = 0; i < n; i++){
			cin >> a >> b >> co >> ti;
			cost[a][b] = co;
			cost[b][a] = co;
			tim[a][b] = ti;
			tim[b][a] = ti;
		}
		for (int k = 0; k < m+1; ++k)
			for (int i = 0; i < m+1; ++i)
				for (int j = 0; j < m+1; ++j)
				{
					cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
					tim[i][j] = min(tim[i][j], tim[i][k] + tim[k][j]);
				}
		cin >> m;
		for (int i = 0; i < m; i++){
			cin >> a >> b >> r;
			if (r == 0){
				cout << cost[a][b] << endl;
			}
			else
				cout << tim[a][b] << endl;
		}
	}
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define BS binary_search
#define WW 100000
#define INF 1000000000000000000

 //1e18
//get<a>(t) gives ath element of tuple named t, numbering starts from 0
//max({__}) can give maximum of any number of elements. Similarly min also.
//don't forget to initialise freq arrays
int32_t main()
{
    IOS;
    int n;cin>>n;
    unordered_map<string,int> umap;
    while(n--){
        string s;
        cin>>s;
        umap[s]++;
    }
    cout<<umap.size();
    return 0;
}

Measured memory_bytes: 17716
#include<cstdio>
int main()
{
	int i,j,h,w;
	char map[501][501];
	scanf("%d%d",&h,&w);
	for(i=0;i<h;++i)
	{
		scanf("%s",map[i]);
	}
	for(i=0;i<h;++i)
	{
		for(j=0;j<w;++j)
		{
			putchar((j!=w-1 && (j==0 || i&1 || map[i][j]=='#') )?'#':'.');
		}
		putchar('\n');
	}
	putchar('\n');
	for(i=0;i<h;++i)
	{
		for(j=0;j<w;++j)
		{
			putchar((j!=0 && (j==w-1 || !(i&1) || map[i][j]=='#') )?'#':'.');
		}
		putchar('\n');
	}
	return 0;
}
/*
5 5
.....
.#.#.
.....
.#.#.
.....
*/
/*
7 13
.............
.###.###.###.
.#.#.#...#...
.###.#...#...
.#.#.#.#.#...
.#.#.###.###.
.............
*/


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long h,w;cin>>h>>w;
    if(h==1 || w==1){cout<<1;return 0;}
    if(h%2==0 || w%2==0)cout<<(h*w)/2;
    else cout<<(h*w)/2+1;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> flowers(N);
  for (int i = 0; i < N; ++i) {
    cin >> flowers[i];
  }
  int ans = 0;
  bool done = false;
  while (!done) {
    int ops = 0;
    bool b = false;
    for (auto &h : flowers) {
      if (h > 0) {
        if (!b) {
          b = true;
          ++ops;
        }
        --h;
      } else {
        b = false;
      }
    }
    ans += ops;
    if (ops == 0) done = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using ll = long long;
using vll = vector<ll>;
#define szof(a) (int)a.size()
#define allof(a) a.begin(), a.end()
#define f first
#define s second

int n;
int g[205][205];
int colour[205];
bool bipartite(int u, int col) {
    colour[u] = col;
    for (int v = 1; v <= n; ++v) {
        if (g[u][v]) {
            if (colour[v] == -1) {
                if (!bipartite(v, col ^ 1)) return false;
            } else if (colour[v] == col) {
                return false;
            }
        }
    }
    return true;
}

const int INF = 1e9;
int dist[205];
int bfs(int src) {
    for (int i = 1; i <= n; ++i) dist[i] = INF;
    dist[src] = 0;
    queue<int> q;
    q.push(src);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int v = 1; v <= n; ++v) {
            if (g[u][v] && dist[v] == INF) {
                dist[v] = 1 + dist[u];
                q.push(v);
            }
        }
    }
    int ans = 0;
    for (int v = 1; v <= n; ++v) ans = max(ans, dist[v]);
    return ans;
}

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            char c;
            scanf(" %c", &c);
            g[i][j] = c - '0';
        }
    }
    memset(colour, -1, sizeof colour);
    if (!bipartite(1, 1)) {
        printf("-1\n");
        return 0;
    }

    int ans = 1;
    for (int u = 1; u <= n; ++u) {
        ans = max(ans, 1 + bfs(u));
    }
    printf("%d\n", ans);
}

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


int main() {

    int n;
    cin >> n;
    char x[105];
    set<char> st;
    for (int i = 0; i < n; ++i) {
        int num; cin >> num;
        if (1<=num&&num<=399) x[i] = 'a';
        else if (400<=num&&num<=799) x[i] = 'b';
        else if (800<=num&&num<=1199) x[i] = 'c';
        else if (1200<=num&&num<=1599) x[i] = 'd';
        else if (1600<=num&&num<=1999) x[i] = 'e';
        else if (2000<=num&&num<=2399) x[i] = 'f';
        else if (2400<=num&&num<=2799) x[i] = 'g';
        else if (2800<=num&&num<=3199) x[i] = 'h';
        else if (3200<=num) x[i] = 'i';
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (x[i] == 'i') ++cnt;
        else st.insert(x[i]);
    }
    if (st.size() == 0) {
        cout << 1 << ' ' << cnt << endl;
        return 0;
    }
    if (cnt == 0) {
        cout << st.size() << ' ' << st.size() << endl;
        return 0;
    } else {
        cout << st.size() << ' ' << st.size() + cnt << endl;
    }
    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
	if (ref < value) ref = value;
}

int main() {
	ll n;
	cin >> n;
	vector<vector<P>> pos(4);
	map<char, int> c;
	c['U'] = 0;
	c['R'] = 1;
	c['D'] = 2;
	c['L'] = 3;
	rep(i, n) {
		ll x, y;
		char ch;
		cin >> x >> y >> ch;
		x *= 10;
		y *= 10;
		pos[c[ch]].push_back({ x,y });
	}
	ll lower = INF;
	{
		map<ll, set<ll>> ys;
		for (auto p : pos[2]) {
			ys[p.first].insert(p.second);
		}
		for (auto p : pos[0]) {
			auto u = ys[p.first].upper_bound(p.second);
			if (u == ys[p.first].end()) continue;
			chmin(lower, abs(*u - p.second) / 2);
		}
	} 
	{
		map<ll, set<ll>> xs;
		for (auto p : pos[3]) {
			xs[p.second].insert(p.first);
		}
		for (auto p : pos[1]) {
			auto u = xs[p.second].upper_bound(p.first);
			if (u == xs[p.second].end()) continue;
			chmin(lower, abs(*u - p.first) / 2);
		}
	}
	{
		map<ll, set<ll>> ys1, ys2;
		for (auto p : pos[1]) {
			//y-x
			ys1[p.first + p.second].insert(p.second);
		}
		for (auto p : pos[3]) {
			//y+x
			ys2[p.second - p.first].insert(p.second);
		}
		for (auto p : pos[0]) {
			auto u = ys1[p.first + p.second].upper_bound(p.second);
			if (u == ys1[p.first + p.second].end()) continue;
			chmin(lower, abs(*u - p.second));
		}
		for (auto p : pos[0]) {
			auto u = ys2[p.second - p.first].upper_bound(p.second);
			if (u == ys2[p.second - p.first].end()) continue;
			chmin(lower, abs(*u - p.second));
		}
	}
	{
		map<ll, set<ll>> ys1, ys2;
		for (auto p : pos[1]) {
			//y+x
			ys1[p.first - p.second].insert(-p.second);
		}
		for (auto p : pos[3]) {
			//y-x
			ys2[p.first + p.second].insert(-p.second);
		}
		for (auto p : pos[2]) {
			auto u = ys1[p.first - p.second].upper_bound(-p.second);
			if (u == ys1[p.first - p.second].end()) continue;
			chmin(lower, abs(*u + p.second));
		}
		for (auto p : pos[2]) {
			auto u = ys2[p.first + p.second].upper_bound(-p.second);
			if (u == ys2[p.first + p.second].end()) continue;
			chmin(lower, abs(*u + p.second));
		}
	}	
	if (lower == INF) {
		cout << "SAFE" << endl;
	}
	else {
		cout << lower << endl;
	}
	return 0;
}


Measured memory_bytes: 52760
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		sc.close();
		int x = 0;
		int max = 0;
		for(int i = 0; i < N; i++) {
			if(S.charAt(i) == 'I') {
				x++;
			}else {
				x--;
			}
			max = Math.max(max, x);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt = 0;
    for(int i = 0; i < n; i++)
    cin >> a[i];
    for(int i = 0; i < n; i++){
           if(a[i] == i + 1 && i != n - 1){
                swap(a[i], a[i + 1]);
                cnt++;
           }
            if(a[i] == i + 1 && i == n - 1)
            {
                swap(a[i], a[i - 1]);
                cnt++;
            } 
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0;i < (int)(n);i++)
int main() {
  const int dx[4]  = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, inf = 10e9;
  int H, W, nh, nw, m = 0;cin >> H >> W;
  P p;
  vector<string> v(H);
  vector<vector<int>> d(H, vector<int>(W));
  queue<P> q;
  rep(i, H) cin >> v[i];
  rep(i, H) rep(j, W) if(v[i][j] == '.') {
    rep(k, H) rep(l, W) d[k][l] = inf;
    q.push(P(i, j));
    d[i][j] = 0;
    while(q.size() != 0) {
      p = q.front();
      q.pop();
      rep(k, 4) {
        nh = p.first + dx[k], nw = p.second + dy[k];
        if(0 <= nh && nh < H && 0 <= nw && nw < W && v[nh][nw] == '.' 
           && d[nh][nw] == inf) {
          q.push(P(nh, nw));
          d[nh][nw] = d[p.first][p.second] + 1;
          if(m < d[nh][nw]) m = d[nh][nw];
        }
      }
    }
  }
  cout << m << endl;
}

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

int main() {
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string s, t;
	cin>>s;
	s+=s[0];
	for (int a=0; a<4; a++){
		if (a==0) t="SS";
		else if (a==1) t="SW";
		else if (a==2) t="WS";
		else t="WW";
		for (int i=2; i<=N+1; i++){
			if (t[i-1]=='S'){
				if (s[i-1]=='o'){
					if (t[i-2]=='S') t+='S';
					else t+='W';
				}
				else{
					if(t[i-2]=='S') t+='W';
					else t+='S';
				}
			}
			else{
				if (s[i-1]=='o'){
					if (t[i-2]=='S') t+='W';
					else t+='S';
				}
				else{
					if(t[i-2]=='S') t+='S';
					else t+='W';
				}				
			}

		}
	    if (t[0] == t[N]&& t[1] == t[N + 1]) {
	            cout << t.substr(0, N);
	            return 0;
	     }
	}
	cout << -1 << endl;
}
	


Measured memory_bytes: 768
inpl = lambda: list(map(int,input().split()))
N, M, K = inpl()
A = inpl()
B = inpl()
k = 0
for i in range(N):
    if k + A[i] <= K:
        k += A[i]
    else:
        break
else:
    i += 1
for j in range(M):
    if k + B[j] <= K:
        k += B[j]
    else:
        break
else:
    j += 1

ans = i + j
for i in range(i-1,-1,-1):
    k -= A[i]
    while j < M and k + B[j] <= K:
        k += B[j]
        j += 1
    if i + j > ans:
        ans = i + j
    if j == M:
        break
print(ans)


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

#define N (ll)(1e5 + 5)

ll n,m;
ll x,y;

vector<ll>adj[N];
ll dis[N] = {0};
bool vis[N];

void DFS(ll v)
{
    vis[v] = true;

    bool flg = false;
    for(auto it:adj[v])
    {
        if(vis[it])
        {
            dis[v] = max(dis[v],dis[it] + 1);
            continue;
        }

        flg = true;
        DFS(it);
        dis[v] = max(dis[v],dis[it]+1);
    }
}

int main()
{
    memset(vis,false,sizeof vis);

    cin>>n>>m;

    for(ll i=0;i<m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
    }

    for(ll i=1;i<=n;i++)
    {
        if(!vis[i])
            DFS(i);
    }

    ll ans = 0;
    for(ll i=1;i<=n;i++)
    {
        ans = max(ans,dis[i]);
    }
    cout<<ans;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_a() {
	ll n, m;
	//ll x, y;
	ll a, b, d;
	//ll c;
	//char c;
	//ll h, w;
	ll k;
	string s, t;
	ll l_ans = 0;
	string s_ans = "NG";
	ll l, r;

	V x(5);
	rep(i, 5) cin >> x[i];
	cin >> k;

	s_ans = "Yay!";
	rep(i, 5) {
		rep(j, 5) {
			if (i<j && x[j] - x[i] > k) {
				s_ans = ":(";
				break;
			}
		}
	}

	cout << s_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}

Measured memory_bytes: 3648
N = int(input())
S = input()
MOD = 10**9+7
TO_INT = {'B': 1, 'W': -1}
BW = S[:]
BW = [TO_INT[s] for s in BW]

if BW[0] == -1 or BW[-1] == -1:
    print(0)
else:
    LR = [1] # {'L': 1, 'R': -1}
    for i in range(1, 2*N):
        if BW[i-1] != BW[i]:
            LR.append(LR[i-1])
        else:
            LR.append(-1*LR[i-1])
    if sum(LR) != 0:
        print(0)
    elif LR[-1] == 1:
        print(0)
    else:
        cnt = 0
        ans = 1
        for n in LR:
            if n == 1:
                cnt+=1
            else:
                ans = ans * cnt % MOD
                cnt -= 1
        import math
        print(ans*math.factorial(N)% MOD)
        
    

Measured memory_bytes: 55948
#include <stdio.h>

int main(void) {                                                                
    int a[4], b[4];                                                             
    int hit, blow, i, j;                                                        
    while (scanf("%d%d%d%d%d%d%d%d", &a[0], &a[1], &a[2], &a[3],                
                 &b[0], &b[1], &b[2], &b[3]) != EOF) {                          
        hit = blow = 0;                                                         
        for (i = 0; i < 4; i++) {                                               
            for (j = 0; j < 4; j++) {                                           
                if (a[i] == b[j]) {                                             
                    if (i == j)                                                 
                        hit++;                                                  
                    else                                                        
                        blow++;                                                 
                }                                                               
            }                                                                   
        }                                                                       
        printf("%d %d\n", hit, blow);                                           
    }                                                                           
    return 0;                                                                   
}

Measured memory_bytes: 596
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a>b){
            System.out.println(a+(a-1));
        }else if(a==b){
            System.out.println(a+(b));
        }else{
            System.out.println(b+(b-1));
        }
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N;
	cin >> N;
	set<string> S;
	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		S.insert(s);
	}
	cout << S.size() << endl;
}



Measured memory_bytes: 19252
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)

int main() {
	in(int, a, b, c);
	YesNo(a <= c && c <= b);
}

Measured memory_bytes: 256