akhauriyash/Code-Regression huggingface dataset:
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
ll power(ll x, ll y); 

const ll MOD = 1000000007;

ll f[3000006];

ll tot(pair<ll, ll> a, pair<ll, ll> b){
    if(a.ff > b.ff) swap(a, b);
    if(a.ss > b.ss) return 0;
    ll num = f[b.ff + b.ss - a.ff - a.ss];
    ll den = (f[b.ff - a.ff] * f[b.ss - a.ss]) % MOD;
    return (num * power(den, MOD - 2)) % MOD;
}

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    f[0] = f[1] = 1;
    repp(i, 2, 3000000) f[i] = (f[i - 1] * i) % MOD;
    ll h, w, n;
    cin >> h >> w >> n;
    pair<ll, ll> st = {1, 1}, en = {h, w};
    vector<pair<ll, ll> > v(n);
    for(auto &i : v) cin >> i.ff >> i.ss;
    sort(all(v));

    ll dp[n + 5] = {0};
    rep(i, 0, n){
        dp[i] = tot(st, v[i]);
        rep(j, 0, i){
            dp[i] -= (tot(v[j], v[i]) * dp[j]) % MOD;
            dp[i] += MOD;
            dp[i] %= MOD;
        }
    }

    ll res = tot(st, en);
    rep(i, 0, n){
        res -= (tot(v[i], en) * dp[i]) % MOD;
        res += MOD;
        res %= MOD;
    }

    cout << res;
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

// ll A = 107, B = 107, C = 1361, D = 1361, E = 10000019;


Measured memory_bytes: 23808
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
ll a1[100005],b1[100005],c1[100005];
bool cmp(ll a,ll b){
	return a>b;
}
int main()
{
	int x,y,a,b,c;
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	rep(i,1,a)scl(a1[i]);
	rep(i,1,b)scl(b1[i]);
	rep(i,1,c)scl(c1[i]);
	sort(a1+1,a1+a+1,cmp);
	sort(b1+1,b1+b+1,cmp);
	sort(c1+1,c1+c+1,cmp);
	c1[c+1]=0;
	int bega=1,begb=1,begc=1;
	ll cout=0;
	while(x+y>=begc){
		if(x>0&&y>0){
			if(c1[begc]>a1[bega]&&c1[begc]>b1[begb]){
				cout+=c1[begc++];
			}else if(a1[bega]>=b1[begb]){
				cout+=a1[bega++];x--;
			}else {
				cout+=b1[begb++];y--;
			}
		}else if(x>0){
			if(c1[begc]>a1[bega]){
				cout+=c1[begc++];
			}else {
				cout+=a1[bega++];x--;
			}
		}else {
			if(c1[begc]>b1[begb]){
				cout+=c1[begc++];
			}else {
				cout+=b1[begb++];y--;
			}
		} 
	}pf("%lld\n",cout);
}

Measured memory_bytes: 2560
from collections import deque

S = input()
T = input()
N = len(S)

ans = False
QS = deque(list(S))

for _ in range(N):
    QS.appendleft(QS.pop())
    A = ''.join(QS)
    if A == T:
        ans = True
        break

print('Yes' if ans else 'No')

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    List<Character> list1 = new ArrayList<>();

    int n = sc.nextInt();
    String s = sc.next();
    int count = 0;

    for(int i = 0; i < n; i++){
        list1.add(s.charAt(i));
    }
    
    for(int i = 0; i < n-2; i++){
        if(list1.get(i).equals('A') && list1.get(i+1).equals('B') && list1.get(i+2).equals('C')){
            count++;
        }else{
        }
    }
    //System.out.println(list1.get(1));
    System.out.println(count);
    }
}

Measured memory_bytes: 22612
N = int(input())
A,B,C = 0,0,0
for TA in range(1,3501):
    for TB in range(1,3501):
        Numer = TA*TB*N
        Denom = 4*TA*TB-(TA+TB)*N
        if Denom>0 and Numer>0 and Numer%Denom==0:
            A = TA
            B = TB
            C = Numer//Denom
print('{} {} {}'.format(A,B,C))

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

#define ll long long

int main()
{
  ll n,a,b;
  cin>>n>>a>>b;
  if(abs(a-b)%2==0)cout<<abs(a-b)/2<<endl;
  else
  {
    cout<<min(n-b,a-1)+1+(b-a-1)/2<<endl;
  }
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
        t: String,
    }
    let mut s = s;
    let t = t;

    if s == t {
        println!("Yes");
        return;
    }

    for _ in 0..s.len() {
        let mut end = s.pop().unwrap().to_string();
        end.push_str(&s);
        s = end;
        if s == t {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


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

int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	string s;
	cin >> n >> s;
	for(int i=0;i<s.size();i++){
		int ch=s[i]-'A';
		ch=(ch+n)%26;
		s[i]='A'+ch;
	}
	cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  string s;cin>>s;
  bool can = true;
  fr(i, s.size()){
    if(i%2){
      if(s[i]=='R') can = false;
    }else{
      if(s[i]=='L') can = false;
    }
  }

  cout << (can? "Yes":"No")<< endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;

const int maxn = 100009;
const int MOD = 1e9+7;
int x[maxn], y[maxn];
int n, m;
LL a, b;

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

int main(){
	n = read(); m = read();
	for (int i=1; i<=n; i++) x[i] = read();
	for (int j=1; j<=m; j++) y[j] = read();
	sort(x+1, x+n+1); sort(y+1, y+m+1);
	for (int i=1; i<=n-1; i++)
		a = (a + 1LL*(x[i+1]-x[i])*i%MOD*(n-i)) % MOD;
	for (int j=1; j<=m-1; j++)
		b = (b + 1LL*(y[j+1]-y[j])*j%MOD*(m-j)) % MOD;
	printf("%lld\n", a*b%MOD);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define SG getchar()
using namespace std;
int n,m,k;
static inline int read(){int s(0),f(1);char c(SG);while(('0'>c)||(c>'9')){f=((!(c-'-'))?(-1):(1)),c=SG;}while(('0'<=c)&&(c<='9')){s=((s<<3)+(s<<1)+c-48),c=SG;}return (s*f);}
signed main(){n=read(),m=read(),k=read();int t,ans(0);for(register int i(0);i^n;i++){t=read(),ans+=((t<m)||(t>=k));}return printf("%d",ans),putchar(10),0;}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		int m = kb.nextInt();
		for (int i = 0; i < m; i++) {
			int j = kb.nextInt();
			n -= j;
		}
		if (n >= 0) {
			System.out.println(n);
		} else {
			System.out.println(-1);
		}
		kb.close();
	}

}


Measured memory_bytes: 46088
#include <stdio.h>

int main(int argc, char *argv[])
{
	char a[8000000];
	long long i,sum=0;
	scanf("%s",a);
	for(i=0;a[i];i++)
		sum+=(a[i]-48);
	if(!(sum%9))
		printf("Yes\n");
	else
		printf("No\n");
	
}

Measured memory_bytes: 1796
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
mp = []
syn = [str(i) for i in range(4)]
temp = []
for k in range(N - 1):
    for i in syn:
        for j in range(4):
            temp.append(i + str(j))
    syn.clear()
    syn.extend(temp)
    temp.clear()

syn_list = [i for i in syn if '1' in i and '2' in i and '3' in i]

for i in syn_list:
    A_l = 0
    B_l = 0
    C_l = 0
    for j in range(N):
        if i[j] == '1':
            A_l += l[j]
        elif i[j] == '2':
            B_l += l[j]
        elif i[j] == '3':
            C_l += l[j]
        else:
            continue
    mp.append(abs(A_l - A) + abs(B_l - B) + abs(C_l - C) + (i.count('1') + i.count('2') + i.count('3') - 3) * 10)
print(min(mp))

Measured memory_bytes: 9880
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<string> s(N);
    for(int i = 0; i < N; i++){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }
    long long ans = 0;
    map<string,long long> mp;
    for(int i = 0; i < N; i++){
        if(mp.count(s[i])){
            ans += mp[s[i]];
            mp[s[i]]++;
        }
        else mp[s[i]] = 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define MAX 55
long long n;
long long a[MAX];
typedef pair<long long,long long> pii;
vector<pii> ans;
// void prlong longA();
void solveP();
void solveN();
 
int main()
{
    cin>>n;
    long long maxn = -10000001;
    long long minn =  10000001;
    long long maxloc = 0;
    long long minloc = 0;
 
    for(long long i=1;i<=n;++i)    
    {
        cin>>a[i];
        // maxn = max(maxn, a[i]);
        // minn = min(minn, a[i]);
        if(a[i] > maxn)
        {
            maxn = a[i];
            maxloc = i;
        }
        if(a[i] < minn)
        {
            minn = a[i];
            minloc = i;
        }
    }
 
 
    if(maxn<=0)
    {
        cout<<n-1<<endl;
        solveN();
        return 0;
    }
    else if(minn>=0)
    {
        cout<<n-1<<endl;        
        solveP();
        return 0;
    }
    else
    {
        cout<<2*n-1<<endl;        
        if(maxn + minn >=0)
        {
            for(long long i=1;i<=n;++i)
            {
                // if(i == maxloc)
                //     continue;
                cout<<maxloc<<" "<<i<<endl;
                // ans.push_back(pii(maxloc,i));
                // a[i] += a[maxloc];
            }
            solveP();
            return 0;
        }
        else
        {
            for(long long i=1;i<=n;++i)
            {
                // if(i == minloc)
                //     continue;
                cout<<minloc<<" "<<i<<endl;                
                // ans.push_back(pii(minloc, i));
                // a[i] += a[minloc];
            }
            solveN();
            return 0;
        }
    }
 
    return 0;
}
 
 
void solveP()
{
    for(long long i=2;i<=n;++i)
    {
        // a[i] += a[i-1]; 
        cout<<i-1<<" "<<i<<endl;
    }
    // prlong longA();
}
 
void solveN()
{
    for(long long i=n-1;i>=1;--i)
    {
        // a[i] += a[i+1];
        cout<<i+1<<" "<<i<<endl;        
    }
    // prlong longA();
}
 
// void prlong longA()
// {
//     for(long long i=1;i<=n;++i)
//         cout<<a[i]<<" ";
//     cout<<endl;
// }

Measured memory_bytes: 256
import java.util.Scanner;

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 > A - B)
            if(A + B > A * B)
                System.out.println(A + B);
            else
                System.out.println(A * B);
        else if(A - B > A * B)
                System.out.println(A - B);
        else
            System.out.println(A * B);
    }
}

Measured memory_bytes: 24020
#include<stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  int A[3];
  A[2]=(int)n/100;
  A[1]=((int)n/10)%10;
  A[0]=n%10;
  int i;
  for(i=0;i<3;i++){
    if(A[i]==1){
      A[i]=9;
    }else{
      A[i]=1;
    }
  }
  printf("%d", A[2]*100+A[1]*10+A[0]);
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int l;
    cin >> l;
    double x = (double)l / 3;
    cout << fixed << setprecision(12) << x * x * x << endl;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int a,b,c,d,f=0;
	cin>>a>>b>>c>>d;
	while(1)
	{
		if(f==0)
		{
			c-=b;
			if(c<=0)	
			{
				puts("Yes");
				return 0;
			}
		}
		if(f==1)
		{
			a-=d;
			if(a<=0)
			{
				puts("No");
				return 0;
			}
		}
		f^=1;
	}
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int X,A;
    cin >>X>>A;

    cout << ((X<A) ? 0 : 10) <<endl;
    return (0);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a;
	cin >> a;
	if (a % 7 == 0){
		cout << "thu" << endl;
	}
	if (a % 7 == 1){
		cout << "fri" << endl;
	}
	if (a % 7 == 2){
		cout << "sat" << endl;
	}
	if (a % 7 == 3){
		cout << "sun" << endl;
	}
	if (a % 7 == 4){
		cout << "mon" << endl;
	}
	if (a % 7 == 5){
		cout << "tue" << endl;
	}
	if (a % 7 == 6){
		cout << "wed" << endl;
	}
	return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

#define N 1100

struct Node {
    int l, r;
    bool operator < (const Node &u) const {
        return l < u.l;
    }
};

Node a[N];

int main() {
    int n;
    while (scanf("%d", &n) != EOF) {
        for (int i = 0; i < n; ++i) {
            scanf("%d%d", &a[i].l, &a[i].r);
        }
        sort(a, a + n);
        int res = 0;
        int e = 0;
        for (int i = 0; i < n; ++i) {
            if (e >= a[i].l) {
                res += a[i].r - e;
            } else {
                res += a[i].r - a[i].l + 1;
            }
            e = a[i].r;
        }
        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
n, m = map(int,input().split())
questions = [0 for i in range(n)]
clear = [0 for i in range(n)]
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'WA':
        if clear[p-1] == 0:
            questions[p-1] += 1
    else:
        clear[p-1] = 1
questions = np.array(questions)
print(sum(clear), questions[np.where(np.array(clear) == 1)[0]].sum())


Measured memory_bytes: 21796
#include <stdio.h>
#define MAX 100001
#define NIL -1 /*use to show there no any input*/

typedef struct{
  int parent,left,right;
}Record;
int dep[MAX];

void depth(int, int, Record*);
int main(){
  int i,j,num,id,childnum,child,prechild,root;
  Record data[MAX];
  scanf("%d",&num);
  for(i=0;i<num;i++){
    data[i].parent=NIL;
    data[i].left=NIL;
    data[i].right=NIL;
  }
  
  for(i=0;i<num;i++){
    scanf("%d%d",&id,&childnum);
    for(j=0;j<childnum;j++){
      scanf("%d",&child);
      if(j==0) data[id].left=child;
      else data[prechild].right=child;
      prechild=child;
      data[child].parent=id;
    }
  }
  for(i=0;i<num;i++){
    if(data[i].parent==NIL){
      root=i;
      break;
    }
  }
  depth(root,0,data);

  for(i=0;i<num;i++){
    printf("node %d: parent = %d, ",i,data[i].parent);
    printf("depth = %d, ",dep[i]);
    if(i==root) printf("root, ");
    else if(data[i].left==NIL) printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    child=data[i].left;
    for(j=0;child!=NIL;j++){
      if(j>0) printf(", ");
      printf("%d",child);
      child=data[child].right;
    }
    printf("]\n");
  }
  return 0;
}	

void depth(int x, int y, Record *data){
  dep[x]=y;
  if(data[x].right!=NIL) depth(data[x].right,y,data);
  if(data[x].left!=NIL) depth(data[x].left,y+1,data);
}



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

int main(){
       int w, h, x, y, r;
       cin>>w>>h>>x>>y>>r;

       if((x-r<0 || w<x+r) || (y-r<0 || h<y+r)){
	      cout<<"No\n";
       }else{
	      cout<<"Yes\n";
	      }

	      return 0;
}

Measured memory_bytes: 3088
import math
N=int(input())

def is_integer(number):
    return number == int(number)

A=1
answer=11
while A <= math.sqrt(N):
    if is_integer(N/A):
        n_a=1
        while A>=pow(10, n_a):
            n_a+=1
        B=int(N/A)
        n_b=1
        while B>=pow(10, n_b):
            n_b+=1
        if max(n_a, n_b)<answer:
            answer = max(n_a, n_b)
    else:
        pass
    A+=1
print(answer)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

#include<cstring>
struct edge { int to, cap, rev; };
vector<edge> G[100000];
bool used[100000];
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap, (int)G[to].size() });
	G[to].push_back(edge{ from, 0, (int)G[from].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < (int)G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, mod);
		if (f == 0)return flow;
		flow += f;
	}
}

int n, m;
int a[500];
int main() {
	cin >> n >> m;
	string u; cin >> u;
	int s = n, t = n+1;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (u[i] == 'L') {
			add_edge(i, t, a[i]);
		}
		else {
			add_edge(s, i, a[i]);
		}
	}
	rep(i, m) {
		int x, y, b; cin >> x >> y >> b; x--; y--;
		if (x < y) {
			add_edge(x, y, b);
		}
		else {
			add_edge(y, x, b);
		}
	}
	int f = max_flow(s,t);
	cout << f << endl;
	//stop
	return 0;
}



Measured memory_bytes: 5688
//__builtin_popcount()//计算二进制位有多少个1
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
LL a[maxn];
int n;
int main()
{
    LL res=1;
    cin>>n;
    int f=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]==0){
            f=1;
        }
    }
    if(f){
        printf("0\n");
    }
    else{
        /*vector<LL> v;v.clear();
        for(int i=1;i<=n;i++){
            LL pre=a[i];
            for(LL j=2;j*j<=a[i];j++){
                if(pre%j==0){
                  while(pre%j==0){
                    pre/=j;
                    v.push_back(j);
                  }
                }
            }
            if(pre>1){
                v.push_back(pre);
            }
        }
        sort(v.begin(),v.end());
        LL res=1;
        int p=0;
        int len=v.size();
        for(int i=0;i<len;i++){
            res*=v[i];
            if(res>=1e18)
        }
        */
        LL res=1LL;
        LL ko=1e18;
        int p=0;
        for(int i=1;i<=n;i++){
            if(ko/res<a[i]){
                p=1;break;
            }
            res*=a[i];
        }
        if(p){
          printf("-1\n");
        }
        else{
            printf("%lld\n",res);
        }
    }
    return 0;
}


Measured memory_bytes: 4544
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s.size()!=6){
    cout<<"No\n";
  }
  else{
    if(s[2]==s[3]&&s[4]==s[5]){
      cout<<"Yes\n";
    }
    else{
      cout<<"No\n";
    }
  }
  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 K = sc.nextInt();
    
    int count = 0;
    for(int i = 0; i < N ; ++i){
      int high = sc.nextInt();
      if(high >= K){
        count++;
      }
    }
    
    System.out.println(count);
 
  }
  
}

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

int X[100010];
int sec[100010];

int main() {
  int N, M;
  cin >> N >> M;
  int sum = 0;
  for (int i = 0; i < M; i++) cin >> X[i];
  sort(X, X + M);
  sum = X[M - 1] - X[0];
  for (int i = 0; i < M - 1; i++) {
    sec[i] = X[i + 1] - X[i];
  }
  sort(sec, sec + M - 1, greater<int>());
  int max = 0;
  if (N < M) {
    for (int i = 0; i < N - 1; i++) max += sec[i];
    cout << sum - max << endl;
  } else {
    cout << 0 << endl;
  }
}


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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a, b;
  cin >> a >> b;

  // 解答
  if (a > 0) {
    cout << "Positive" << endl;
  } else if (a <= 0 && b >= 0) {
    cout << "Zero" << endl;
  } else {
    int diff = abs(b - a);
    cout << (diff & 1 ? "Positive" : "Negative") << endl;
  }

  return 0;
}


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

using namespace std;

int main() {
	/* ----- 変数宣言 ----- */
	int n, d, x, i;

	cin >> n >> d >> x;

	int ans = x;
	vector<int> a(n);

	/* ----- 入力 ----- */
	for (i = 0; i<n; i++) {
		cin >> a[i];
	}

	/* ----- 計算 ----- */
	for (i = 0; i < n; i++) {
		ans += (d - 1) / a[i] + 1;
	}

	/* ----- 出力 ----- */
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char** argv){
    int N, L;
    cin >> N >> L;

    int ans = 0;
    if (L > 0){
        for (int i=1; i<N; i++) ans += L+i;
    }
    else if (L+N-1 < 0){
        for (int i=0; i<N-1; i++) ans += L+i;
    }
    else {
        for (int i=0; i<N; i++) ans += L+i;
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
#define MOD 1000000007ll

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

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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int x = 0, ans = 0;
	REP(i, s.size()) {
		chmax(ans, x += s[i] == 'I' ? 1 : -1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			double[] A = new double [2];
			double[] B = new double [2];
			double[] C = new double [2];
			double[] D = new double [2];
			
			A[0] = sc.nextDouble();  A[1] = sc.nextDouble();
			B[0] = sc.nextDouble();  B[1] = sc.nextDouble();
			C[0] = sc.nextDouble();  C[1] = sc.nextDouble();
			D[0] = sc.nextDouble();  D[1] = sc.nextDouble();
			
			double[] AB = {B[0]-A[0], B[1]-A[1]};
			double[] CD = {D[0]-C[0], D[1]-C[1]};
			double inner_product = AB[0]*CD[0] + AB[1]*CD[1]; 
			
			System.out.println(inner_product==0. ? "YES" : "NO");
		}
		
		sc.close();
	}
	
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

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

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

  string s;
  cin >> s;

  string s_out;
  for (int i = 0; i < s.size(); ++i) {
    if (s.at(i) == 'B') {
      if (s_out.empty()) {
        continue;
      }
      else {
        s_out.pop_back();
      }
    }
    else {
      s_out.push_back(s.at(i));
    }
  }

  cout << s_out << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	char s[5][7]={
		"afkpuz",
		"bglqv.",
		"chmrw?",
		"dinsx!",
		"ejoty ",
	};
	char t[201],o[101];;
	int l,f,x,y;
	while(~scanf("%s",t)){
		f=0;
		l=strlen(t);
		if(l%2==1){
			puts("NA");
			continue;
		}
		for(int i=0;i<l;i+=2){
			y=t[i+1]-'1';
			x=t[i]-'1';
			if(y<0 || y>4 || x<0 || x>5)f=1;
			if(f)break;
			o[i/2]=s[y][x];
		}
		o[l/2]=0;
		puts(f?"NA":o);
	}

	return 0;
}

Measured memory_bytes: 1116
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

void in(){} template<typename Head,typename... Tail> void in(Head&& head,Tail&&... tail){cin>>head;in(forward<Tail>(tail)...);}

void flagfunc3(bool flag){cout<<(flag?"Yes\n":"No\n");}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  ll d,t,s;
  in(d,t,s);
  flagfunc3(t*s>=d);
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		int a = x * y;
		int b = x * 2 + y * 2;
		String c = a + " " + b;

		System.out.println(c);
	}
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    ll n, ans = 1e15;
    cin >> n;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ans = min(ans, i + n / i - 2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
 
int main(){
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    int m = 0; 
    cin >> A[0];
    for(int i = 1; i < N ; i++){
        cin >> A[i];
        m = max(m, A[i]- A[i-1]);
    }

    m = max(m, (K - A[N-1]) + A[0]);
    cout << K - m << endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S,T; cin >> S >> T;
    int N = S.size();
    int M = T.size();

    vector<vector<int>> G(26);
    rep(i,N) {
        int k = S[i] - 'a';
        G[k].emplace_back(i);
        G[k].emplace_back(N+i);
    }
    rep(i,26) sort(all(G[i]));
    ll ans = 0;
    int cur = -1;
    rep(i,M) {
        int k = T[i] - 'a';
        if (G[k].empty()) {
            cout << -1 << ln;
            return 0;
        }
        int p = *upper_bound(all(G[k]),cur);
        ans += p - cur;
        cur = p;
        if (cur >= N) cur -= N; 
    }

    cout << ans << ln;
}


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

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

using namespace std;

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

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

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

//#define MULTIPLE_TEST_CASE
map<int, int> dp;
map<ii, int> pot2;

void precalc(string s, int digits, int n) {
  for (int m = max(digits - 1, 1LL); m <= digits + 1; m++) {
    int ans = 0;
    pot2[ii(0, m)] = 1;
    for (int i = 1; i <= n; i++) {
      pot2[ii(i, m)] = (pot2[ii(i - 1, m)] * 2) % m;
    }
    for (int i = 0; i < n; i++) {
      if (s[i] == '1') ans = (ans + pot2[ii(i, m)]) % m;
    }
    dp[m] = ans;
  }
}

int firstSolve(string s, int digits, int i, int n) {
  if (s[i] == '0') {
    return mod(dp[digits + 1] + pot2[ii(i, digits + 1)], digits + 1);
  } else {
    if (digits - 1 == 0) return -1;
    return mod(dp[digits - 1] - pot2[ii(i, digits - 1)], digits - 1);
  }
}

int cntBits(int n) {
  int ans = 0;
  for (int i = 0; i < 25; i++) {
    if (n & (1 << i)) ans++;
  }
  return ans;
}

void solution() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  int digits = 0;
  for (char c : s)
    if (c == '1') digits++;

  precalc(s, digits, n);

  for (int i = n - 1; i >= 0; i--) {
    // change s[i]

    int ans = 0;
    int cur = firstSolve(s, digits, i, n);
    ans++;
    if (cur == -1) {
      cur = 0;
      ans--;
    }

    while (cur > 0) {
      cur %= cntBits(cur);
      ans++;
    }

    cout << ans << endl;
  }
}

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


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

int main()
{
    double d,x,s;
    int n;
    cin>>n>>d>>x;
    double n2=n+n;
    for(int i=n;i>=1;i--) 
    {
        s+=d+(n2-1)/2*x;
        double dd=d+(2*d+5*x)/n2;
        double xx=x+4*x/n2;
        x=xx,d=dd,n2-=2;
    }
    cout<<fixed<<setprecision(10)<<s;
    return 0;
}

Measured memory_bytes: 384
object Main {
  def main(args: Array[String]): Unit = {
    io.Source.stdin.getLines foreach (n => println(pi(n.toInt)))
  }
  val primes: IndexedSeq[Int] = prime_sieve(90000)
  val pi_cache: collection.mutable.Map[Int, Int] = collection.mutable.Map.empty
  val phi_cache: collection.mutable.Map[(Int, Int), Int] = collection.mutable.Map.empty

  def prime_sieve(x: Int): IndexedSeq[Int] = {
    val n = x - x % 6 + 6
    val correction = if (x % 6 > 1) 1 else 2
    val sieve = Array.fill(n/3)(true)
    for (i <- 1 to (Math.sqrt(n) / 3).toInt if sieve(i)) {
      val k = (3 * i + 1) | 1
      for (j <- (k * k) / 3 until sieve.length by 2*k) sieve(j) = false
      for (j <- (k*(k-2*(i&1)+4))/3 until sieve.length by 2*k) sieve(j) = false
    }
    2 +: 3 +: (for (i <- 1 until n / 3 - correction if sieve(i)) yield (3*i+1)|1)
  }
  def bisect(n: Int): Int = {
    def loop(left: Int, right: Int): Int = {
      val mid = (left + right) / 2
      if (primes(mid) <= n && n < primes(mid+1)) mid+1
      else if (n < primes(mid)) loop(left, mid)
      else loop(mid+1, right)
    }
    if (n < primes.head) 0
    else if (n >= primes.last) primes.length
    else loop(0, primes.length)
  }
  def pi(x: Int): Int =
    pi_cache.getOrElseUpdate(x,
      if (x <= primes.last) bisect(x)
      else {
        val a = pi(Math.sqrt(Math.sqrt(x)).toInt)
        val b = pi(Math.sqrt(x).toInt)
        val c = pi(Math.cbrt(x).toInt)
        var result = phi(x, a) + ((b + a - 2) * (b - a + 1)) / 2
        for (i <- a + 1 to b) {
          val w = x / primes(i - 1)
          val b_i = pi(Math.sqrt(w).toInt)
          result -= pi(w)
          if (i <= c)
            for (j <- i to b_i)
              result = result - pi(w / primes(j - 1)) + j - 1
        }
        result
      }
    )
  def phi(x: Int, a:Int): Int =
    phi_cache.getOrElseUpdate(
      (x,a),
      {
        if (a == 1) (x + 1) / 2
        else phi(x, a - 1) - phi(x / primes(a - 1), a - 1)
      }
    )
}

Measured memory_bytes: 45500
input = gets.chomp.split("\s")
h, w = input[0].to_i, input[1].to_i

until (h == 0) && (w == 0)
	for i in 1..h
		if (i == 1) || (i == h)
			output = ['#'] * w
			puts output.join
		else
			output = ["#"] + ['.'] * (w - 2) + ["#"]
			puts output.join
		end
	end
	
puts ""
input = gets.chomp.split("\s")
h, w = input[0].to_i, input[1].to_i
end

Measured memory_bytes: 6936
#include <iostream>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool b[26]= {false};
  int l = s.size();
  for (int i=0; i<l; i++){ 
   b[(s[i]-'a')]=true;
  } 
  for (int i=0; i<26; i++) {
    if (!b[i])  {
      cout << char (i + 'a') <<endl;
      return 0;
    }
  }
  cout << "None" <<endl;
}

Measured memory_bytes: 3708
#include <iostream>

using namespace std;

int main() {
	int m; cin >> m;
	
	for (int prob = 0; prob < m; prob++) {
		
		int depo; cin >> depo;
		int year; cin >> year;
		
		int n; cin >> n;
		
		int ans = 0;
		
		for (int method = 0; method < n; method++) {
			int hukuri;
			double nennri;
			int tesuu;
			cin >> hukuri >> nennri >> tesuu;
			
			int cur = depo;
			
			if (hukuri==1) {
				int A = cur;
				for (int y = 0; y<year; y++) {
					int B = (int)(A * nennri);
					A = A + B - tesuu;
				}
				cur = A;
			} else {
				int A = cur;
				int BSUM = 0;
				for (int y=0; y<year; y++) {
					int B = (int)(A*nennri);
					A = A - tesuu;
					BSUM += B;
				}
				cur = A + BSUM;
			}
			
			ans = max(ans, cur);
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1232
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long mod = (long)Math.pow(10,9)+7;
        int n = sc.nextInt();
        long nl = (long)n;
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[sc.nextInt()]++;
        }
        if(n == 1 && a[0] == 1){
            System.out.println(1);
        }else if(n % 2 == 0){
            for(int i = 1; i < n; i+=2){
                if(a[i] != 2){
                    System.out.println(0);
                    return;
                }
            }
            System.out.println(rep2(2L,n/2L,mod));
        }else{
            for(int i = 0; i < n; i+=2){
                if((i == 0 && a[i] != 1) || (i != 0 && a[i] != 2)){
                    System.out.println(0);
                    return;
                }
            }
            System.out.println(rep2(2L,(n-1)/2L,mod));
        }
    }
    
    private static long rep2(long b, long n, long mod){
        if(n == 0) return 1;
        if(n == 1) return b;
        long bn = rep2(b,n/2,mod)%mod;
        if(n % 2 == 0){
            return (long)(bn%mod*bn%mod)%mod;
        }else{
            return (long)(bn%mod*bn%mod)%mod*b%mod;
        }
    }
}


Measured memory_bytes: 48104
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

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

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

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

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  string s; cin>>s; int x=7; rep(i,3) x+=TF(s[i]=='o'); COUT(x*100);
}













Measured memory_bytes: 256
D = gets.to_i
C,*S = (0..D).map{gets.split.map &:to_i}
1 < (I=(0..25).select{C[_1]==0}).size and S.each {|s;z|
  I.each {|i| if i!=(z||=i); s[z]<s[i] ? (s[z]=0; z=i) : (s[i]=0) end }
}
L,M,N = [-1]*27,5,4
def calc(d,n)
  s,x = S[d],0
  t = (0..25).map {s[_1] > 0 ? C[_1]*(d-L[_1])+s[_1] : 0}
  i = (0..25).max_by(M){t[_1]}.max_by {|i|
    next t[i]  if n == 0 || d+1 >= D || t[i]==0
    l,L[i] = L[i],d
    c = calc(d+1,n-1) >> 5
    L[i] = l
    x < c ? x=c : c
  }
  ((t[i]+x) << 5) + i
end
D.times { p 1 + i=calc(_1,N)&31; L[i]=_1 }

Measured memory_bytes: 15236
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

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

    int left = 0, right = 0;
    int ans = 0;
    while(right < n){
        while(right < n){
            auto pos = s.find(s.substr(left, (right+1-left)), right+1);
            if(pos != s.npos){
                right++;
            }
            else
                break;
        }
        ans = max(ans, right - left);
        left++;
    }
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {
  int N, Q; std::cin >> N >> Q;
  std::string S; std::cin >> S;
  
  std::vector<int> T(N+1);
  for(int i=1; i<N; i++) {
    if ( S.substr(i-1,2) == "AC" ) T[i] = T[i-1]+1;
    else T[i] = T[i-1];
  }

  for(int i=0; i<Q; i++){
    int l, r; std::cin >> l >> r;
    std::cout << T[r-1] - T[l-1] << std::endl;
  }

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int a[MAXN], b[MAXN], c[MAXN], sl[MAXN];
double slope[MAXN];
pair<double, int> si[MAXN];
int bit[MAXN];
int n;
pair<double, int> current[MAXN];
void upd(int pos, int val){
    while(pos <= n){
        bit[pos] += val;
        pos += pos & -pos;
    }
}
int get(int pos){
    int ret = 0;
    while(pos){
        ret += bit[pos];
        pos -= pos & -pos;
    }
    return ret;
}
int main(){
    scanf("%d", &n);
    long long pairs = 1ll * n * (n - 1) / 2;
    long long goal = (pairs + 1) / 2;
    for(int i = 1; i <= n; i++){
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
        slope[i] = -1.0* a[i] / b[i];
        si[i] = {slope[i], i};
    }
    sort(si + 1, si + n + 1);
    for(int i = 1; i <= n; i++) sl[si[i].second] = i;
    double ansx, ansy;
    double lo = -1000000000.0;
    double hi = 1000000000.0;
    for(int iterations = 0; iterations < 200; iterations++){
        for(int i = 1; i <= n; i++) bit[i] = 0;
        double md = (lo + hi) / 2.0;
        for(int i = 1; i <= n; i++){
            current[i] = {(c[i] - md * a[i]) / b[i], sl[i]};
        }
        sort(current + 1, current + n + 1);
        long long cnt = 0;
        for(int i = 1; i <= n; i++){
            //printf("%d ", current[i].second);
            upd(current[i].second, 1);
            cnt += get(current[i].second - 1);
        }
        //printf("%6f %d\n", md, cnt);
        if(cnt < goal) lo = md;
        else hi = md;
    }
    ansx = (lo + hi) / 2.0;
    for(int i = 1; i <= n; i++){
        swap(a[i], b[i]);
        slope[i] = -1.0* a[i] / b[i];
        si[i] = {slope[i], i};
    }
    sort(si + 1, si + n + 1);
    for(int i = 1; i <= n; i++) sl[si[i].second] = i;
    lo = -1000000000.0;
    hi = 1000000000.0;
    for(int iterations = 0; iterations < 200; iterations++){
        for(int i = 1; i <= n; i++) bit[i] = 0;
        double md = (lo + hi) / 2.0;
        for(int i = 1; i <= n; i++){
            current[i] = {(c[i] - md * a[i]) / b[i], sl[i]};
        }
        sort(current + 1, current + n + 1);
        long long cnt = 0;
        for(int i = 1; i <= n; i++){
            //printf("%d ", current[i].second);
            upd(current[i].second, 1);
            cnt += get(current[i].second - 1);
        }
        //printf("%6f %d\n", md, cnt);
        if(cnt < goal) lo = md;
        else hi = md;
    }
    ansy = (lo + hi) / 2;
    printf("%.9f %.9f\n", ansx, ansy);
    return 0;
}


Measured memory_bytes: 3968
//
//  main.cpp
//  Atcoder1
//
//  Created by Hamske on 2020/09/17.
//  Copyright © 2020 Author. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

//#define pb push_back
//#define mp make_pair
//
//#define F first
//#define S second

typedef long long ll;

#define rept(_i,iv,n,type) for(type _i=(type)(iv);_i<(type)(n);++_i)
//#define repi(_i,iv,n) rept(_i,iv,n,int)
//#define repl(_i,iv,n) rept(_i,iv,n,ll)

#define rept0(_i,n,type) rept(_i,0,n,type)
#define repi0(_i,n) rept(_i,0,n,int)
#define repl0(_i,n) rept(_i,0,n,ll)

//#define repst(_i,iv,n,type) for(type _i=iv;_i<=(type)(n);++_i)
//#define repsi1(_i,n) repst(_i,1,n,int)

#define REPT(_i,iv,_l,n,type) for(type _i=(type)(iv),_l=(type)(n);_i<_l;++_i)
//#define REPI(_i,iv,_l,n) REPT(_i,iv,_l,n,int)
//#define REPL(_i,iv,_l,n) REPT(_i,iv,_l,n,ll)
//
#define REPT0(_i,_l,n,type) REPT(_i,0,_l,n,type)
#define REPI0(_i,_l,n) REPT(_i,0,_l,n,int)
#define REPL0(_i,_l,n) REPT(_i,0,_l,n,ll)


//#define rrept(_i,x,e,type) for(type _i=((type)(x)-1);_i>=e;--_i)
//
//#define rrept0(_i,x,type) rrept(_i,x,0,type)
//
//#define RREPT(_i,x,_e,e,type) for(type _i=((type)(x)-1),_e=(type)(e);_i>=_e;--_i)
//
//#define RREPT0(_i,x,_e,type) RREPT(_i,x,_e,0,type)
//
//#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//#define all(x) (x).begin(),(x).end()
#define REPV(v,_itr,_end) for(auto _itr=(v).begin(),_end=(v).end();_itr!=_end;++_itr)
#define REPVC(v,_itr,_end) for(auto _itr=(v).cbegin(),_end=(v).cend();_itr!=_end;++_itr)

#define td typedef
//#define tds(stl,type,name) typedef stl<type > name;
#define tdv(type,name) typedef vector<type > name;


//typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb > vvb;
typedef vector<int> vi;
typedef vector<vi > vvi;
typedef vector<ll> vll;
//typedef vector<vll > vvll;

#define mod99 998244353

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    bool flg=true;
    repi0(i, N){
        int a;
        cin>>a;
        if(flg&&a%2==0){
            if(!(a%3==0||a%5==0)){
                flg=false;
            }
        }
    }
    cout<<(flg?"APPROVED":"DENIED")<<endl;
    return 0;
}


Measured memory_bytes: 3096