akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int dfs(long long prefix, long long n, bool t, bool f, bool s){
  if(prefix>n){
    return 0;
  }
  int res;
  if(t && f && s){
    res = 1;
  }else{
    res = 0;
  }
  res += dfs(10*prefix+3,n,true,f,s);
  res += dfs(10*prefix+5,n,t,true,s);
  res += dfs(10*prefix+7,n,t,f,true);
  return res;
}

int main(){
  
  long long n;
  cin>>n;
  int ans;
  ans = dfs(0,n,false,false,false);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

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

const int MAXN = 200005;

int n, m, f[MAXN], siz[MAXN];
vector <int> adj[MAXN];
bool a[MAXN];
char s[MAXN];
LL ans = 1;

inline void Dfs(int x, int p)
{
	siz[x] = a[x];
	for (auto y : adj[x])
		if (y ^ p)
			Dfs(y, x), siz[x] += siz[y], f[x] = max(f[x], f[y] + 1);
}

inline void Dfs(int x, int p, int d)
{
	vector <pii> vec;
	vec.pb(mp(0, a[x]));
	int mx1 = d, mx2 = 0, cur = 0;
	for (auto y : adj[x])
		if (y ^ p)
		{
			if (f[y] + 1 > mx2)
				mx2 = f[y] + 1;
			if (mx1 < mx2)
				swap(mx1, mx2);
			vec.pb(mp(f[y] + 1, siz[y]));
		}
	vec.pb(mp(d, m - siz[x]));
	sort(vec.begin(), vec.end());
	for (auto y : adj[x])
		if (y ^ p)
			if (f[y] + 1 == mx1)
				Dfs(y, x, mx2 + 1);
			else
				Dfs(y, x, mx1 + 1);
	for (int i = 0; i < vec.size() - 1; i ++)
		if (cur += vec[i].yy)
		{
			if (i == vec.size() - 2)
			{
				if (vec[i + 1].xx > vec[i].xx)
					ans ++;
				if (vec[i + 1].xx > vec[i].xx + 1)
					ans ++;
			}
			else
				ans += vec[i + 1].xx - vec[i].xx;
		}
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1, x, y; i < n; i ++)
		x = Read(), y = Read(), adj[x].pb(y), adj[y].pb(x);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i ++)
		m += a[i] = s[i] - '0';
	Dfs(1, 0);
	Dfs(1, 0, 0);
	return printf("%lld\n", ans), 0;
}


Measured memory_bytes: 45312
import collections

n = int(input())
v = list(map(int, input().split()))

e = v[::2]
o = v[1::2]

ce = collections.Counter(e)
co = collections.Counter(o)

if ce.most_common(1)[0][0] != co.most_common(1)[0][0]:
  print(n - ce.most_common(1)[0][1] - co.most_common(1)[0][1])
else:
  if len(ce) ==1 and len(co) ==1:
    print(n//2)
  elif len(ce) ==1:
    print(n//2 - co.most_common(2)[1][1])
  elif len(co) ==1:
    print(n//2 - ce.most_common(2)[1][1])
  else:
    a = ce.most_common(2)[0][1] + co.most_common(2)[1][1]
    b = ce.most_common(2)[1][1] + co.most_common(2)[0][1]
    print(min([n-a, n-b]))
  

Measured memory_bytes: 19040
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
int D,head[N],tot,dep[N],mx[N];
struct E{int u,v;E(int _u=0,int _v=0):u(_u),v(_v){}}e[N];
struct Edge{int v,next;Edge(int _v=0,int _n=0):v(_v),next(_n){}}edge[N];
inline void add(int x,int y){edge[++tot]=Edge(y,head[x]);head[x]=tot;}
void dfs(int x,int la,int son=0)
{	for(rint i=head[x];i;i=edge[i].next)
	if(to!=la) dep[to]=dep[x]+1,dfs(to,x),son++;
	mx[dep[x]]=max(mx[dep[x]],son); D=max(D,dep[x]);
}
pll solve1(int x)
{	ll ans=1; memset(mx,0,sizeof(mx));
	dep[x]=D=1; dfs(x,0);
	for(rint i=1;i<D;i++) ans*=mx[i];
	return mp(D,ans);
}
pll solve2(int x)
{	ll ans=2; memset(mx,0,sizeof(mx));
	dep[e[x].u]=D=1; dfs(e[x].u,e[x].v); dep[e[x].v]=1; dfs(e[x].v,e[x].u);
	for(rint i=1;i<D;i++) ans*=mx[i];
	return mp(D,ans);
}
int main()
{	int n,x,y; cin>>n; pll ans=mp(1e18,1e18); 
	for(rint i=1;i<n;i++) scanf("%d%d",&x,&y),e[i]=E(x,y),add(x,y),add(y,x);
	for(rint i=1;i<=n;i++) ans=min(ans,solve1(i));
	for(rint i=1;i<n;i++) ans=min(ans,solve2(i));
	printf("%lld %lld",ans.first,ans.second);
	return 0;
}


Measured memory_bytes: 22912
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}

#pragma endregion
int main(void) {

	int A, B, C, X;
	int a, b, c, j = 0, i = 0,cnt, tmp;
	
	i_cin4(A, B, C, X);
	a = _min(A, X / 500);
	b = _min(B, X /100);

	cnt = 0;
	while (1) {	
		while (1) {
			tmp = X - 500 * i - 100 * j;
			if (tmp < 0) break;
			cnt+=(!tmp || (tmp / 50 <= C)) ? 1 : 0;
			if (j == b) break; 
			j++;
		}
		if (i == a) break;
		i++; 
		b = _min(B, X / 100 * i);
		j = 0;
	}
	i_cout(cnt);	
	return 0;
}



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

int main(){
  int N, W;
  cin >> N >> W;
  vector<long long> dp(W+1,0);
  for(int i = 0; i < N; ++i){
    int w, v;
    cin >> w >> v;
    vector<long long> dp_ = dp;
    for(int j = 0; j <= W-w; ++j){
      dp_[j+w] = max(dp_[j+w],dp[j]+v);
    }
    dp = dp_;
    for(int j = 0; j < W; ++j)
      dp[j+1] = max(dp[j+1],dp[j]);
  }
  cout << dp[W] << endl;
}


Measured memory_bytes: 1804
x, n = map(int, input().split())
if n > 0:
    p = list(map(int, input().split()))
    sorted_p = sorted(p)

    min_num = sorted_p[0]
    max_num = sorted_p[-1]

    candidate_list = []
    no_flag = 0
    candidate_num = -1
    distance = 10000

    for cnt in range(0, 102):
        no_flag = 0
        for nums in range(n):
            if cnt == sorted_p[nums]:
                no_flag = 1

        if no_flag == 0:
            candidate_list.append(cnt)

    for cnt in range(len(candidate_list)):
        if abs(x - candidate_list[cnt]) < distance:
            candidate_num = candidate_list[cnt]
            distance = abs(x - candidate_num)

    print(candidate_num)

else:
    print(x)


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

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

    std::string s, t;
    std::cin >> s >> t;

    int ns = s.size();
    int nt = t.size();

    int max = 0;
    for (int i = 0; i + nt - 1 < ns; i++) {
        int cnt = 0;

        for (int j = 0; j < nt; j++) {
            cnt += (s[i + j] == t[j]);
        }

        max = std::max(max, cnt);
    }

    std::cout << nt - max;

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int x; cin >> x;
    Out(1 - x);

    return 0;
}


Measured memory_bytes: 3608
import java.io.PrintWriter;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		int n=in.nextInt();
		BTNode[] tree=new BTNode[n];
		for(int i=0;i<n;i++)tree[i]=new BTNode();
		
		for(int i=0;i<n;i++) {
			int id=Integer.parseInt(in.next()),
					l=Integer.parseInt(in.next()),
					r=Integer.parseInt(in.next());
			
			if(l!=-1) {
				tree[id].lc=l;
				tree[l].p=id;
			}
			if(r!=-1) {
				tree[id].rc=r;
				tree[r].p=id;
			}
		}
		in.close();
		
		//print
		PrintWriter out=new PrintWriter(System.out);
		for(int i=0;i<n;i++) {
			out.print("node "+i+": ");
			out.print("parent = "+tree[i].p+", ");
			out.print("sibling = "+sibling(tree,i)+", ");
			out.print("degree = "+degree(tree,i)+", ");
			out.print("depth = "+depth(tree,i)+", ");
			out.print("height = "+height(tree,i,0)+", ");
			out.println(nodeType(tree,i));
			out.flush();
		}
		
	}
	
	static int sibling(BTNode[] tree,int p) {
		if(tree[p].p==-1)return -1;
		
		if(tree[tree[p].p].lc==p)return tree[tree[p].p].rc;
		else return tree[tree[p].p].lc;
	}
	
	static int degree(BTNode[] tree,int pos) {
		int cnt=0;
		
		if(tree[pos].lc!=-1)cnt++;
		if(tree[pos].rc!=-1)cnt++;
		
		return cnt;
	}
	
	static int depth(BTNode[] tree,int p) {
		int cnt=0,pos=p;

		while(tree[pos].p!=-1) {
			pos=tree[pos].p;
			cnt++;
		}

		return cnt;
	}
	
	static int height(BTNode[] tree,int pos,int h) {
		if(tree[pos].lc==-1 && tree[pos].rc==-1)return h;
		
		int l=0,r=0;
		if(tree[pos].lc!=-1)l=height(tree,tree[pos].lc,h+1);
		if(tree[pos].rc!=-1)r=height(tree,tree[pos].rc,h+1);
		
		if(l>r)return l;
		else return r;
	}
	
	static String nodeType(BTNode[] tree,int p) {
		if(tree[p].p==-1)return "root";
		else if(tree[p].lc==-1 && tree[p].rc==-1)return "leaf";
		else return "internal node";
	}

}

class BTNode{
	int p=-1,lc=-1,rc=-1;
}




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

int main(){
    string s,s2;
    cin >> s;
    int ans=0,ka=0;
    rep(i,3){
        s2=s[i];
        if(s2=="R"){
            ++ka;
        }
        else{
            ans=max(ans,ka);
            ka=0;
        }
    }

    ans=max(ans,ka);
    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 3628
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  puts(a + b + c >= 22 ? "bust" : "win");
}

Measured memory_bytes: 256
inp=input().split(" ")
N=int(inp[0])
K=int(inp[1])
dislike=input().split(" ")
like=[]
for i in range(0,10):
    if str(i) not in dislike:
        like.append(str(i))
def search_min(n,like):
    n=str(n)
    if len(n)==1:
        for i in like:
            if i>=n:
                return i
    else:
        if n[0] in like:
            if n[1]<=like[-1]:
                try:
                    return n[0]+search_min(n[1:],like)
                except TypeError:
                    return None
            else:
                j=like.index(n[0])
                if j+1<len(like):
                    return like[j+1]+like[0]*(len(n)-1)
        else:
            for i in like:
                if i>n[0]:
                    return i+like[0]*(len(n)-1)
if search_min(N,like)==None:
    n=len(str(N))
    k="1"+"0"*n
    print(search_min(k,like))
else:
    print(search_min(N,like))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

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

	vector<int> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}

	int ans = 1;
	for (int i = 1; i < N; i++)
	{
		bool flag = true;
		for (int k = 0; k < i; k++)
		{
			if (H[i] < H[k])
			{
				flag = false;
				break;
			}
		}

		if (flag)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
U = 2*10**6+2
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD

def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z %= MOD
    z *= fact_inv[n-k]
    z %= MOD
    return z
  
ans = 0
r1, c1, r2, c2 = map(int, input().split())
for i in range(c1, c2+1):
  ans += comb(i+r2+1, i+1) - comb(i+r1, i+1)
  ans %= MOD
print(ans)

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int t_1 = 0, t_2 = 0, t_3 = 0;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    if (p <= a) {
      t_1++;
    } else if (p <= b) {
      t_2++;
    } else {
      t_3++;
    }
  }
  int ans = 0;
  if (t_1 && t_2 && t_3) {
    ans = min({t_1, t_2, t_3});
  } else {
    ans = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int c[55][30] = {0};
int re[30], ans = 0;

void in()
{
	scanf("%d",&n);
	int sum = 0;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		for(int j=0;j<s.size();j++)
		{
			c[i][ s[j] - 'a' + 1] ++;
		}
	}
}

void work()
{
	memset(re, 10, sizeof(re));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=26;j++)
		{
			if(re[j] > c[i][j])
				re[j] = c[i][j];
		}
	}
	for(int i=1;i<=26;i++)
		if(re[i] == 0)
			ans++;
}

int main()
{
	in();
	work();
	if(ans >= 26)
		printf("");
	else
	{
		for(int i=1;i<=26;i++)
		{
			for(int j=1;j<=re[i];j++)
				cout<<char(i + 'a' - 1);
		}
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<set<int>> v(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        v[a-1].insert(b-1);
        v[b-1].insert(a-1);
    }
    for (int i = 1; i < n-1; ++i) {
        if(v[0].count(i) && v[i].count(n-1)){
            cout << "POSSIBLE\n";
            return 0;
        }
    }
    cout << "IMPOSSIBLE\n";
    return 0;
}


Measured memory_bytes: 28416
#include <iostream>

using namespace std;

int main()
{
    int a,b,x,y,z ;
    cin>>a>>b ;
    x=a+b ;
    y=a-b ;
    z=a*b ;
    if ((x>z)&&(x>y))
    {
         cout << x << endl;
    }
    else
    {
        if(z>y)
        {
             cout << z << endl;
        }
        else
        {
             cout << y << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
        public static void main(String[] args){
            Scanner sc =new Scanner(System.in);
            int n = sc.nextInt();
            int[] h = new int[n];
            for(int i=0;i<n;i++){
                h[i] = sc.nextInt();
            }
            int max = h[0];
            int sum = 1;
            for(int j=1;j<n;j++){
                if(h[j]>=max){
                    sum++;
                    max=h[j];
                }
            }
            System.out.println(sum);
            for(double k = 0;k<10000000;k=k+0.5){
                sum=sum*2;
                double a = 10.2f;
                double b = 10.589f;
                double c = a*b;
                sum=sum/2;
            }
        }

        }

Measured memory_bytes: 21716
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static boolean ok(int x, int y, int z, int n){
		if(x < 0 || x >= n || y < 0 || y >= n || z < 0 || z >= n){
			return false;
		}
		
		return true;
	}
	
	public static boolean check_dir(int x, int y, int z, int color, int n, int m, int dx, int dy, int dz, int board[][][]){
		if(!ok(x, y, z, n) || board[z][y][x] != color){
			return false;
		}
		
		for(int i = 0; i < m - 1; i++){
			x += dx;
			y += dy;
			z += dz;
			
			if(!ok(x, y, z, n) || board[z][y][x] != color){
				return false;
			}
		}
		
		return true;
	}
	
	public static boolean check(int color, int n, int m, int[][][] board){
		for(int z = 0; z < n; z++){
			for(int y = 0; y < n; y++){
				for(int x = 0; x < n; x++){
					if(board[z][y][x] != color){
						continue;
					}
					
					for(int dz = -1; dz <= 1; dz++){
						for(int dy = -1; dy <= 1; dy++){
							for(int dx = -1; dx <= 1; dx++){
								if(dx == 0 && dy == 0 && dz == 0){
									continue;
								}
								
								if(check_dir(x, y, z, color, n, m, dx, dy, dz, board)){
									return true;
								}
							}
						}
					}
				}
			}
		}
		
		return false;
	}
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);

		while (true) {
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			final int p = sc.nextInt();
			
			if(n == 0 && m == 0 && p == 0){
				break;
			}
			 
			int[][][] board = new int[n][n][n];
			int win_color = 0;
			int count = 1;
			
			for(int i = 0; i < p; i++){
				final int x = sc.nextInt() - 1;
				final int y = sc.nextInt() - 1;
				
				if(win_color != 0){
					continue;
				}
				
				final int color = i % 2 == 0 ? 1 : -1;
				
				boolean flag = false;
				for(int z = n - 1; z >= 0; z--){
					if(board[z][y][x] != 0){
						board[z+1][y][x] = color;
						flag = true;
						break;
					}
				}
				if(!flag){
					board[0][y][x] = color;
				}
				
				if(check(color, n, m, board)){
					win_color = color;
				}else{
					count++;
				}
			}
			
			if(win_color == 0){
				System.out.println("Draw");
			}else{
				System.out.println((win_color == 1 ? "Black" : "White") + " " + count);
			}
		}
	}

}

Measured memory_bytes: 62208
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
  
using namespace std;
  
int main(){
    int a, b;
    cin >> a >> b;
    if(a==1){
        a+=13;
    }
    if(b==1){
        b+=13;
    }
    if(a>b){
        cout << "Alice" << endl;
    }
    else if(b>a){
        cout << "Bob" << endl;
    }
    else{
        cout << "Draw" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <string>
#include <set>

using namespace std;

int a[10];
string vs[10];
bool selected[10];
set<int> res;

void comb(int num){
  if(num==5){
    // ツづつソツづァツづーツ湘」ツづ可つキツづゥツつゥ
    for(int s = 0; s < (1<<5); s++){
      int mask=0;
      for(int i = 0; i < 5; i++){
	if((s>>i)&1){
	  for(int j = 0; j < 5; j++){
	    if(vs[a[i]][j]=='1')
	      mask|=(1<<(j*5+i));
	  }
	}
	else{
	  // ツ逆ツ古シツつォ
	  for(int j = 0; j < 5; j++){
	    if(vs[a[i]][4-j]=='1')
	      mask|=(1<<(j*5+i));
	  }
	}
      }
      vector<int> left;
      for(int i = 0; i < 10; i++){
	if(!selected[i])
	  left.push_back(i);
      }
      bool no[10];
      memset(no,0,sizeof(no));
      bool bad=false;
      // ツづ個つアツづィツづ個要ツ素ツづーツマツッツチツつキツづゥツ渉氾板づ可置ツつ「ツづつ「ツつュ
      for(int i = 0; i < 5; i++){
	bool ok=false;
	for(int j = 0; j < left.size(); j++){
	  if(no[j])continue;
	  bool isMatch=true;
	  // matchツつキツづゥツつゥツ陳イツづ猟づゥ
	  // ツ債カツつゥツづァ
	  for(int k = 0; k < 5; k++){
	    if(!((vs[left[j]][k]-'0')^((mask>>(i*5+k))&1))){
	      // no
	      isMatch=false;
	      break;
	    }
	  }
	  if(!isMatch){
	    isMatch=true;
	    for(int k = 0; k < 5; k++){
	      if(!((vs[left[j]][4-k]-'0')^((mask>>(i*5+k))&1))){
		// no
		isMatch=false;
		break;
	      }
	    }
	    if(isMatch){
	      no[j]=true;
	      ok=true;
	      break;
	    }
	  }
	  else{
	    no[j]=true;
	    ok=true;
	    break;
	  }
	}
	// ツづ敖づつつゥツづァツづ按つ「
	if(!ok){
	  bad=true;
	  break;
	}
      }
      if(!bad){
	res.insert(mask);
      }
    }
  }
  else{
    for(int i = 0; i < 10; i++){
      if(selected[i])continue;
      a[num]=i;
      selected[i]=true;
      comb(num+1);
      selected[i]=false;
    }
  }
}

int main(){

  memset(selected,0,sizeof(selected));
  while(cin>>vs[0]&&vs[0]!="END"){
    for(int i = 1; i < 10; i++)
      cin>>vs[i];
    comb(0);
    cout<<res.size()/8<<endl;
    res.clear();
  }
  
  
  return 0;
}

Measured memory_bytes: 928
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 998244353; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
void solve() {
	int N, M; cin >> N >> M;
	vector<int>A(N);
	REP(i, N) {
		cin >> A[i];
		A[i] /= 2;
	}
	int G = A[0];
	REP(i, N) {
		G = lcm(G, A[i]);
		if (G > M) {
			print(0); return;
		}
	}
	REP(i, N) {
		if ((G / A[i]) % 2 == 0) {
			print(0); return;
		}
	}
	//DEBUG(G);
	if (G > M) {
		print(0); return;
	}
	int mx = (M - G) / (2 * G);
	print(max((ll)0, mx + 1));
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 1024
# coding:utf-8

import sys

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


N, W = LI()
L = [LI() for _ in range(N)]

# dp[w]: 容量wのナップザックの価値の総和の最大値
dp = [0] * (W + 1)
for weight, value in L:
    for w in range(W + 1)[::-1]:
        if w - weight < 0:
            continue
        dp[w] = max(dp[w], dp[w - weight] + value)

print(dp[W])


Measured memory_bytes: 42092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main(int argc, char *argv[]){
        long D, T, S;
        scanf("%ld %ld %ld", &D, &T, &S);
        if(T * S >= D){
                printf("Yes\n");

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

Measured memory_bytes: 1664
#include <iostream>
#include <cstring>
#include <cstdio>
#include <unordered_set>
#include <algorithm>

using namespace std;
const int N = 105;
int main()
{
	int x, n;
	scanf("%d%d", &x, &n);
	if (n == 0)
	{
		printf("%d\n", x);
	}
	else
	{
		int q;
		unordered_set<int> v;
		for (int i = 1; i <= n; ++i)
		{
			scanf("%d", &q);
			v.insert(q);
		}

		int last = 2000;
		int pos = 100;
		for (int i = -1; i <= 101; ++i)
		{
			if (v.find(i) == v.end())
			{
				if (abs(i - x) < last)
				{
					pos = i;
					last = abs(i - x);
				}
			}
		}
		printf("%d\n", pos);
	}

	



	return 0;
}

Measured memory_bytes: 3792
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(string, s, t);

    sort(all(s));
    sort(all(t), greater<>());

    cout << ((s < t) ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;


public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskT solver = new TaskT();
        solver.solve(1, in, out);
        out.close();
    }
    
    

    static class TaskT {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            /*
        	int K = in.nextInt();
            int prev = 7;
            int steps = 0, rem = 0;
            while (steps < 1e7) {
                ++steps;
                rem += prev;
                if (rem % K == 0) break;
                prev = (prev * 10) % K;
                rem %= K;
            }
        	
        	System.out.println((steps < 1e7) ? steps : -1); 
        	*/
        	
        	int N = in.nextInt();
        	String str = in.next();
        	int i = 0;
        	int j = str.length()-1;
        	int ans = 0;
        	while(i < j){    //RRRiWWWRjWW
        		//find collision point 
        		if(str.charAt(i) == 'R'){  //its safe for R to be on left 
        			i++;
        			continue; 
        		}
        		if(str.charAt(j) == 'W'){  //its safe for W to be on the right 
        			j--;
        			continue;
        		}
        		//now we have a violating condition where we can do a swap and continue 
        		ans ++; //when doing  swap to fix collision increment counter 
        		
        		//dont forget after swap
        		i++;
        		j--;
        	}
        	
        	System.out.println(ans);
        }
        

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        
        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 36740
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>9||b>9){
      System.out.println("-1");
    }else{
      System.out.println(a*b);
    }
  }
}


Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
#include<cmath>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int n,k;
int main()
{
	read(n);
	read(k);
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i<=k)	continue;
		int gg=max((n-n/i*i)-k+1,0);
		if(k==0)
			gg--;
		ans+=(n/i)*(i-k)+gg;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	char a[52] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	
	int n;
	while(cin >> n && n!=0)
	{
		int b[100]={};
		REP(i,n){cin >> b[i];} //カギ
		
		char c[100]={}; //文字
		cin >> c;
		
		
		REP(i,sizeof(c))
		{
			REP(j,52)
			{
				if(c[i]==a[j])
				{
					cout << a[( j - b[(i +n)% n] +52) % 52];
					break;
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int a,b;
	for(int i=0;i<s.size();i++)
	if(s[i]=='A')
	{
		a=i;
		break;	
	}
	for(int i=0;i<s.size();i++)
	if(s[i]=='Z')
	b=i;
	cout<<b-a+1;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		if (a < b) System.out.println("a < b");
		else if (a > b) System.out.println("a > b");
		else if (a == b) System.out.println("a == b");
		else;
	}
}

Measured memory_bytes: 26108
#include <cstdio>
using namespace std;
int main() {
	int a[5],k;
    bool f;
    f = false;
    for (int i=0; i<5; i++) {
        scanf("%d",&a[i]);
    }
	scanf("%d", &k);
    for (int i=0;i<5;i++){
        for (int j=1;j<5-i;j++){
            if (a[i]-a[j]>k || a[j]-a[i]>k){
                f = true;
            }
        }
    }
    if (f) {
        printf(":(\n");
    } else {
        printf("Yay!\n");
    }
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

const int64_t R = 1e9 + 7;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

bool isL[200'000];

int main()
{
    int64_t n;
    string s;
    cin >> n >> s;

    rep(i, 2 * n)
    {
        int flip = i + (s[i] == 'B' ? 1 : 0);
        isL[i] = (flip % 2 == 1);
    }

    int64_t lnum = 0;
    int64_t rnum = 0;
    int64_t cmb = 1;
    rep(i, 2 * n)
    {
        if (isL[i]) {
            lnum++;
        } else {
            cmb = cmb * (lnum - rnum) % R;
            rnum++;
        }
    }

    if (s[0] == 'W' || s[2 * n - 1] == 'W' || lnum != rnum) {
        cout << 0 << endl;
        return 0;
    }

    rep(i, n)
    {
        cmb = cmb * (i + 1) % R;
    }
    cout << cmb << endl;

    return 0;
}

Measured memory_bytes: 772
// ABC077_C
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))

int main() {
    // input
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    REP(i, N) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    
    // calculation
    ll now_B, num_A, num_C, res = 0;
    ll idx_bound_A, idx_bound_C;
    
    for (ll i = 0; i < N; ++i) {
        now_B = B[i];
        num_A = 0;
        num_C = 0;
        
        // 1 段目: now_B 未満の数を求める
        auto iter_A = lower_bound(A.begin(), A.end(), now_B);
        idx_bound_A = distance(A.begin(), iter_A);
        num_A = (iter_A == A.end())? N: (idx_bound_A + 1) - 1;
        
        // 3 段目: now_B より大きい数
        auto iter_C = upper_bound(C.begin(), C.end(), now_B);
        idx_bound_C = distance(C.begin(), iter_C);
        num_C = (iter_C == C.end())? 0: N - idx_bound_C;
        
        res += num_A*num_C;
    }
    
    cout << res << "\n";
    
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(){
    char c[6];
    int i;
    for(i = 0; i < 6; i++){
        scanf(" %c", &c[i]);
    }
    if(c[1] == c[4]){
        if(c[0] == c[5] && c[2] == c[3]){
            printf("YES\n");
        } else{
            printf("NO\n");
        }
    } else{
        printf("NO\n");
    }

    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000

string A;

ll calc(ll length) {
    ll ret = 0;
    REP(i, length) {
        ret += length - 1 - i;
    }
    return ret;
}

map<string, int> pat;
void invest() {
    pat[A]++;

    for(int i = 2; i <= A.length(); ++i) {
        for(int j = 0; j + i <= A.length(); ++j) {
            string cand = "";
            for(int k = 0; k < j; ++k) {
                cand += A[k];
            }
            for(int k = j + i - 1; k >= j; --k) {
                cand += A[k];
            }
            for(int k = j + i; k < A.length(); ++k) {
                cand += A[k];
            }
            cout << cand << "[" << j << ", " << j+i-1 << "] i = " << i;
            if(pat[cand] != 0) {
                printf("has!");
            }
            printf("\n");
            pat[cand]++;
        }
    }
}

map<char, ll> pattern;
int main()
{
    cin >> A;

    ll ans = calc(A.length()) + 1;

    REP(i, A.length()) {
        pattern[A[i]]++;
    }
    auto it = pattern.begin();
    while(it != pattern.end()) {
        //printf("%c %lld\n", it->first, it->second);
        ans -= calc(it->second);
        ++it;
    }
    printf("%lld\n", ans);

    return 0;
}


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

int main(){
  int n,i;
  cin>>n;
  vector<pair<pair<string,int>,int>> a(n);
  for(i=0;i<n;i++){
    string str;
    int l;
    cin>>str>>l;
    a.at(i).first.first=str;
    a.at(i).first.second=-l;
    a.at(i).second=i+1;
  }

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

  for(i=0;i<n;i++){
    cout<<a.at(i).second<<endl;
  }


}


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

typedef  long long ll;
typedef long double ld;
using namespace std;
const int N=1e5+5;

#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define point complex<double>
ll mod=1e9+7;
ll inf=2e18;
double eps=1e-10;
double pi=acos(-1);
double dot(point a, point b)
{
    return (conj(a)*b).real();
}
double cross(point a, point b)
{
    return (conj(a)*b).imag();
}

int arr[N];
int main()
{
 int n;
 cin>>n;
 for(int i=0;i<n+1;i++)
        cin>>arr[i];
 ll ans=0;
 for(int i=0;i<n;i++)
 {
     int x;
     cin>>x;
     ll rem=min(x,arr[i]);
     arr[i]-=rem;
     x-=rem;
     ans+=rem;
     rem=min(arr[i+1],x);
     arr[i+1]-=rem;
     x-=rem;
     ans+=rem;
 }
 cout<<ans;


    return 0;
}


Measured memory_bytes: 3980
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int n;
    cin >> n;
    vector<int> v(n), c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];

    int ans = 0;
    for(int bit = 0; bit < (1<<n); bit++){
        int x = 0, y = 0;
        rep(i, n){
            if(bit>>i & 1){
                x += v[i];
                y += c[i];
            }
        }

        ans = max(ans, x-y);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    print(s[:-8])
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39728
#include <bits/stdc++.h>
using namespace std;
int a[1010],n;
double s=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	s=a[1];
	for(int i=2;i<=n;i++)
		s=(s+a[i])*1.0/2;
	cout<<s;
	return 0;
}
/*
模拟只会猜题意
贪心只能过样例
数学上来先打表
DP一般看规律
组合数学靠运气
计算几何瞎暴力
图论强行套模板
数论只会GCD
递归递推伤不起
搜索茫然TLE
分治做得像枚举
暴力枚举数第一
数据结构干瞪眼
怒刷水题找信心
涨姿势也不容易
考试一来全懵逼
*/

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

struct Train {
    ll time;
    ll start;
    ll between;

    ll next(ll t) {
        if (t <= start) {
            return start + time;
        }
        ll s = t - start;
        ll maega_ittekara_byougo = s % between;
        if (maega_ittekara_byougo == 0) {
            return t + time;
        }
        ll mati = between - maega_ittekara_byougo;
        return t + mati + time;
    }

};

int main() {

    ll n;
    cin >> n;

    vector<Train> trains(n - 1);

    rep(i, n - 1) {
        ll c, s, f;
        cin >> c >> s >> f;
        Train t = {c, s, f};
        trains[i] = t;
    }

    for (ll start_station = 0; start_station < n; start_station++) {
        ll time = 0;
        for (ll current_station = start_station; current_station < n - 1; current_station++) {

            Train t = trains[current_station];
            ll next = t.next(time);
            time = next;
        }
        cout << time << endl;
    }


}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a, b;

    while (cin >> a >> b)
    {
        cout << to_string(a + b).size() << endl;
    }

    return 0;
}



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

int main(){
  int n,m,d[100];
  string s[100];
  while(cin>>n>>m&&n){
    int a=0;
    for(int i=0;i<n;i++)cin>>s[i]>>d[i];
    for(int i=0;i<m;i++){
      string t;
      cin>>t;
      for(int k=0;k<n;k++){
      bool f=1;
	for(int j=0;j<t.size();j++)if(s[k][j]!='*'&&s[k][j]!=t[j])f=0;
	if(f)a+=d[k];    
      }
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
import queue
import copy
import math
from collections import deque

# そのまま入力文字列の入力
n = int(input())

# 空白区切りの数値をリスト化
pn = list(map(int, input().split()))

ans = 0
current_min = n + 1

for i in range(0, n):
    if i == 0:
        current_min = pn[i]
        ans += 1
        continue

    if pn[i] < current_min:
        ans += 1
        current_min = pn[i]
        continue

print(ans)

Measured memory_bytes: 25764