akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<30;
const int mod = 1e9+7;

int main() {
  int N; cin >> N;
  string s[2]; cin >> s[0] >> s[1];
  long long ans = 0LL;
  if(s[0][0] == s[1][0]) ans = 3;
  else ans = 6;
  for(int i = 1; i < N; i++) {
    if(s[0][i-1] == s[0][i]) continue;
    if(s[0][i] == s[1][i]) {
      if(s[0][i-1] == s[1][i-1]) ans *= 2;
      ans %= mod;
      continue;
    }
    if(s[0][i-1] == s[1][i-1]) ans *= 2;
    else{
      ans *= 3;
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
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)*}
    };
}

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)*}
    };

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

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        cs: [usize1; n],
        es: [(usize1, usize1); n - 1]
    }
    let mut t = vec![vec![]; n];
    for &(a, b) in &es {
        t[a].push(b);
        t[b].push(a);
    }
    let mut sub = vec![0; n];
    let mut subc = vec![0; n];
    let mut ans = vec![n * (n - 1) / 2; n];
    dfs(0, 0, &mut 0, &t, &cs, &mut sub, &mut subc, &mut ans);
    for &c in &cs {
        ans[c] += 1;
    }
    for i in 0..n {
        if n > subc[i] {
            ans[i] -= (n - subc[i]) * (n - subc[i] - 1) / 2;
        }
    }
    for &a in &ans {
        println!("{}", a);
    }
}

fn dfs(v: usize, p: usize, s: &mut usize, t: &Vec<Vec<usize>>, cs: &Vec<usize>, sub: &mut Vec<usize>, subc: &mut Vec<usize>, ans: &mut Vec<usize>) -> usize {
    let x = subc[cs[v]];
    sub[v] = 1;
    for &c in &t[v] {
        if c == p {
            continue;
        }
        let pre = *s - subc[cs[v]];
        sub[v] += dfs(c, v, s, t, cs, sub, subc, ans);
        let next = *s - subc[cs[v]];
        if next > pre {
            ans[cs[v]] -= (next - pre) * (next - pre - 1) / 2;
        }
    }
    subc[cs[v]] = x + sub[v];
    *s += 1;
    sub[v]
}


Measured memory_bytes: 47224
#include <iostream>
#include <vector>
#include <queue>

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};
};

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

int main() {
    int n, s, t;
    std::cin >> n >> s >> t;
    --s, --t;

    Graph<> tree(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;
        tree[u].emplace_back(u, v);
        tree[v].emplace_back(v, u);
    }

    std::vector<int> sdist(n, -1);
    sdist[s] = 0;
    std::queue<int> que;
    que.push(s);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto e : tree[v]) {
            if (sdist[e.dst] < 0) {
                sdist[e.dst] = sdist[v] + 1;
                que.push(e.dst);
            }
        }
    }

    std::vector<int> tdist(n, -1);
    tdist[t] = 0;
    que.push(t);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto e : tree[v]) {
            if (tdist[e.dst] < 0) {
                tdist[e.dst] = tdist[v] + 1;
                que.push(e.dst);
            }
        }
    }

    int ans = 0;
    for (int v = 0; v < n; ++v) {
        if (sdist[v] < tdist[v]) {
            ans = std::max(ans, tdist[v] - 1);
        }
    }

    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 7680
H,W = map(int,input().split())
S = [input() for i in range(H)]
A = [["#"]*W for i in range(H)]
if H ==1 and W ==1:
    if S[0] == "#":
        print("#")
        exit()
    else:
        print(0)
        exit()
if H ==1:
    if W ==2:
        if S[0][0]==".":
            A[0][0]=str(S[0].count("#"))
        if S[0][1]==".":
            A[0][1]=str(S[0].count("#"))
 
    else:
        for j in range(W):
            if S[0][j]==".":
                if j ==0:
                    A[0][0]=str(S[0][0:2].count("#"))
                elif j ==W-1:
                    A[0][W-1]=str(S[0][W-2:W].count("#"))
                else:
                    A[0][j]=str(S[0][j-1:j+2].count("#"))
    print("".join(A[0]))
    exit()

if W ==1:
    if H ==2:
        if S[0]==".":
            A[0]=str(S[1].count("#"))
        if S[1]==".":
            A[1]=str(S[0].count("#"))
    else:
        for i in range(H):
            if S[i][0]==".":
                if i ==0:
                    A[0][0]=str(S[1][0].count("#"))
                elif i ==H-1:
                    A[H-1][0]=str(S[H-2][0].count("#")+S[H-1][0].count("#"))
                else:
                    A[i][0]=str(S[i-1][0].count("#")+S[i][0].count("#")+S[i+1][0].count("#"))
    for i in range(H):
        print("".join(A[i]))
    exit()

for i in range(W):
    for j in range(H):
        if S[j][i]==".":
            if i ==0 and j ==0:
                A[j][i] =str(S[0][0:2].count("#")+S[1][0:2].count("#"))
            elif i ==W-1 and j ==0:
                A[j][i] =str(S[0][W-2:W].count("#")+S[1][W-2:W].count("#"))
            elif i ==0 and j ==H-1:
                A[j][i] =str(S[H-2][0:2].count("#")+S[H-1][0:2].count("#"))
            elif i ==W-1 and j ==H-1:
                A[j][i] =str(S[H-2][W-2:W].count("#")+S[H-1][W-2:W].count("#"))
            elif i ==0:
                A[j][i] =str(S[j-1][0:2].count("#")+S[j][0:2].count("#")+S[j+1][0:2].count("#"))
            elif i ==W-1:
                A[j][i] =str(S[j-1][W-2:W].count("#")+S[j][W-2:W].count("#")+S[j+1][W-2:W].count("#"))
            elif j ==0:
                A[j][i] =str(S[0][i-1:i+2].count("#")+S[1][i-1:i+2].count("#"))
            elif j ==H-1:
                A[j][i] =str(S[H-2][i-1:i+2].count("#")+S[H-1][i-1:i+2].count("#"))
            else:
                A[j][i] =str(S[j-1][i-1:i+2].count("#")+S[j][i-1:i+2].count("#")+S[j+1][i-1:i+2].count("#"))
           
                
for i in range(H):
    print("".join(A[i]))

Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#else
template<class...T>void dprint(T&&...t){_print(cerr,t...);}
#endif
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<<(ostream&o,const multiset<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

vp data;

int rt(int x){
    if(data[x].F==-1)return x;
    int r=rt(data[x].F);
    data[x].S+=data[data[x].F].S;
    data[x].F=r;
    return r;
}

int dif_rt(int x){
    rt(x); // cache(?)
    if(data[x].F==-1)return 0;
    return dif_rt(data[x].F)+data[x].S;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(10);
    int n,m;
    cin>>n>>m;
    data.resize(n, P(-1, 0));
    REP(i,m){
        int l,r,d;
        cin>>l>>r>>d;
        l--;r--;
        if(rt(l)==rt(r)){
            if(dif_rt(l)+d!=dif_rt(r)){
                Yes(0);
                return 0;
            }else continue;
        }
        d-=dif_rt(r);
        data[rt(r)]={l, d};
        dprint(data);
        rt(2);
        dprint(data);
    }
    Yes(1);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int ans[200010];
vector<int> G[200010];
int a[200010];
int dp[200010];
int n;
void dfs(int x, int p = -1) {
    auto itr = lower_bound(dp, dp + n, a[x]);
    int tmp = *itr;
    *itr = a[x];
    ans[x] = lower_bound(dp, dp + n, INF) - dp;
    for(auto to: G[x]) {
        if(to == p) continue;
        dfs(to, x);
    }
    *itr = tmp;
}


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    rep(i, 200010) dp[i] = INF;
    dfs(0);
    rep(i, n) {
        cout << ans[i] << endl;
    }


    return 0;
}


Measured memory_bytes: 28312
#include<bits/stdc++.h>
using namespace std;
#define fori(x,y)   for(ll i=x;i<y;i++)
#define forj(x,y)   for(ll j=x;j<y;j++)
#define rfori(a,b)  for(int i=a;i>=b;i--)
#define for_it(a)   for(auto it: a)
#define pb          push_back
#define pf          push_front
#define ff          first
#define ss          second
#define all(x)      x.begin(),x.end()
#define mp          make_pair
#define mod         1000000007
#define mem(a,b)    memset(a,b,sizeof(a))
#define ld          long double
#define endl        "\n"
#define ll          long long
#define llu         unsigned long long 
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vl          vector<ll> ;
#define vi          vector<int> 
#define vc          vector<char> 
#define vs          vector<string> 
#define si          set<int>
#define spii        set<pii>
#define usi         unordered_set<int>
#define uspii       unordered_set<pii>
#define mii         map<int,int>
#define umii        unordered_map<int,int>
#define pqmx        priority_queue<int>
#define pqmn        priority_queue<int,vi,greater<int>>
#define setbits(x)  __builtin_popcountll(x)
#define fast        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int xx[4]={0,0,1,-1};
int yy[4]={-1,1,0,0};

/*-----------------------------------------------------------------------------------------------------------------*/

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("A_IN.txt","r",stdin);
	freopen("A_Out.txt","w",stdout);
	#endif
	fast;
	
	

	int n,c=0;
	cin>>n;
	bool flag=false;
	while(n--)
	{
		int a,b;
		cin>>a>>b;
		if(a==b)
		{
			c++;
			if(c==3)
			{
				flag=true;
				break;
			}

		}
		else
			c=0;
	}
	if(flag)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
 

	return 0;
}

Measured memory_bytes: 3692
main = do
  _ <- getLine
  hs <- map read . words <$> getLine
  print $ length (f hs [])

f :: [Int] -> [Int] -> [Int]
f xs ans
  | length xs == 1 = ans ++ xs
  | maximum (init xs) <= last xs = f (init xs) (ans ++ [last xs])
  | otherwise = f (init xs) ans


Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i;
	cin>>i;
	if(i%100<=12 && i%100!=0 && i/100!=0 && i/100<=12)
	{
		cout<<"AMBIGUOUS"<<endl;
		return 0;
	}
	if(i%100<=12 && i%100!=0)
	{
		cout<<"YYMM"<<endl;
		return 0;
	}
	if(i/100!=0 && i/100<=12)
	{
		cout<<"MMYY"<<endl;
		return 0;
	}
	cout<<"NA"<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N;
    cin >> N;
    //x < y < z となるようなxyzの数*3
    for(ll i = 1; i <= N; i++){
        ll ans = 0;
        for(ll x = 1; x <= 100; x++){
            for(ll y = x; y <= 100; y++){
                for(ll z = y; z <= 100; z++){
                    if(x*x + y*y + z*z + x*y + y*z + z*x == i){
                        if(x == y && y == z){
                            ans++;
                        }else if(x == y || y == z){
                            ans += 3;
                        }else{
                            ans += 6;
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n;
ll a[100005],b[100005],c[100005];
ll ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    for(int i=0;i<n;i++){
        ll B=b[i];
        ans+=((lower_bound(a,a+n,B)-a)*(n-(upper_bound(c,c+n,B)-c)));
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 5876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	int N;
	cin >> N;

	map<int, int> MAP;
	rep(i, N) {
		int A;
		cin >> A;
		MAP[A]++;
	}
	
	vector<pair<int, int>> V;
	for (auto itr : MAP) {
		V.push_back(make_pair(itr.first, itr.second));
	}
	sort(V.begin(), V.end());
	reverse(V.begin(), V.end());

	int hitotu = 0;
	int hutatu = 0;
	for (auto itr : V) {
		if (itr.second >= 2) {
			if (hitotu == 0) {
				hitotu = itr.first;
				if (itr.second >= 4) {
					hutatu = itr.first;
					break;
				}
			}
			else {
				hutatu = itr.first;
				break;
			}
		}
	}

	co(1ll * hitotu * hutatu);

	Would you please return 0;
}

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

using namespace std;
int main()
{
    int n;
    cin>>n;
    string c;
    cin>>c;
    if(n%2==1) cout<<"No"<<endl;
    else{
    char ch1[n/2],ch2[n/2];
    for(int i=0;i<n/2;i++)
    {
        ch1[i]=c[i];
    }
    int j=0;
    for(int i=n/2;i<n;i++)
    {
        ch2[j]=c[i];
        j++;

    }
    int count=0;
    for(int i=0;i<n/2;i++)
    {
       if(ch1[i]==ch2[i])
       {
            count++;
       }

    }
    if(count==n/2)
        cout<<"Yes"<<endl;
   else
        cout<<"No"<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    if(n>=2&&m>=2)
    {
        cout<<n*(n-1)/2+m*(m-1)/2;
    }
    if(n>=2&&m<2)
    {
        cout<<n*(n-1)/2; 
    }
    if(n<2&&m>=2)
    {
        cout<<m*(m-1)/2;
    }
    if(n<2&&m<2)
    {
        cout<<0;
    }

    return 0;
}


Measured memory_bytes: 256
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 12/08/2017 13:13:51
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}
ull lcm(ull a, ull b){
	return a/__gcd(a, b) * b;
}
int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	int n;
	cin>>n;
	ull r = 1;
	ull t;
	for(int i = 0; i < n; i++){
		cin>>t;
		r = lcm(r, t);
//		cout<<r<<endl;
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
y = int(Y/ 1000)
b = False

for i in range(N+ 1):
  for j in range(N+ 1- i):
    k = N- i- j
    if(10* i+ 5* j+ k == y):
      print("{} {} {}".format(i, j, k))
      b = True
      break
  if(b == True):
    break
    
if(b == False):
  print("-1 -1 -1")

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

using namespace std;

#define POS(s, i) (s)[(i) - 1]

bool a_reach[200002] = {};
bool b_reach[200002] = {};


int main() {
  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d;
  cin >> s;

  // すぬけ君とふぬけ君が，追い越さないのであればセーフ．
  // 追い越す必要があれば，3マスほど連続して空いているマスが必要．
  
  // 追い越す必要がない？
  bool no_oikoshi = (c < d);
  
  bool continuous_3space = false;

  if (POS(s, a) == '.') {
    a_reach[a] = true;
  }

  for (int i = a; i <= c; i++) {
    if (i >= 2 && a_reach[i - 2] && POS(s, i) == '.') {
      a_reach[i] = true;
    }
    if (i >= 1 && a_reach[i - 1] && POS(s, i) == '.') {
      a_reach[i] = true;
    }
  }

  if (POS(s, b) == '.') {
    b_reach[b] = true;
  }

  for (int i = b; i <= d; i++) {
    if (i >= 2 && b_reach[i - 2] && POS(s, i) == '.') {
      b_reach[i] = true;
    }
    if (i >= 1 && b_reach[i - 1] && POS(s, i) == '.') {
      b_reach[i] = true;
    }
  }

  // # _ d c
  for (int i = a; i <= c - 2; i++) {
    if (POS(s, i) == '.' && POS(s, i+1) == '.' && POS(s, i+2) == '.') {
      if (a_reach[i] && b_reach[i+1] && a_reach[i+2]) {
        continuous_3space = true;
        break;
      }
    }
  }

  bool pos_ok = (POS(s, a) == '.' && POS(s, b) == '.' && POS(s, c) == '.' && POS(s, d) == '.');

  bool result = (no_oikoshi || continuous_3space) &&
                a_reach[c] && b_reach[d] && pos_ok;

  if (result) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(void)
{
	int n, m;

	while (cin >> n >> m, n || m){
		vector <int> p(n + 1);
		for (int i = 0; i < n; i++){
			scanf("%d", &p[i]);
		}
		p[n] = 0;
		n++;

		vector <int> sum(n * n);
		int cnt = 0;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				sum[cnt] = p[i] + p[j];
				// cout << sum[cnt] << " " << p[i] << " " << p[j] << endl;
				cnt++;
			}
		}

		sort(sum.begin(), sum.end());
		int ret = 0;
		for (int i = 0; i < n * n; i++){
			int diff = m - sum[i];
			if (diff < 0) continue;
			int up = *(upper_bound(sum.begin(), sum.end(), diff)-1);
			ret = max(ret, sum[i] + up);
		}

		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 5440
#include <iostream>
#include <cstdio>
#define N 2002
using namespace std;
const int mod=1000000007;
int n,k,f[N][N],sum[N],i,j;
int main()
{
	cin>>n>>k;
	sum[n+1]=f[0][n+1]=1;
	for(i=n;i>=1;i--) sum[i]=sum[i+1]+f[0][i];
	for(i=1;i<k;i++){
		for(j=1;j<=n-i+1;j++) f[i][j]=sum[j];
		sum[n+1]=f[i][n+1];
		for(j=n;j>=1;j--) sum[j]=(sum[j+1]+f[i][j])%mod;
	}
	int ans=0;
	for(i=2;i<=n+1;i++) ans=(ans+f[k-1][i])%mod;
	for(i=1;i<=n-k-1;i++) ans=ans*2%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 15232
<?php
list($n) = ints();
$a = ints();
$cnt = 0;
for ($i = 0; $i < $n; ++$i) if ($i === $a[$a[$i] - 1] - 1) ++$cnt;
echo intdiv($cnt, 2) . PHP_EOL;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 25120
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;

int main(){
    string S;
    cin>>S;
    if(S=="ABC"){
        cout<<"ARC"<<endl;
    }else
    {
        cout<<"ABC"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3592
N = int(input())
A = list(map(int,input().split()))
p, q, r = 0, 0, 0

for a in A:
    if a % 4 == 0:
        p += 1
    elif a % 4 == 2:
        q = 1
    else:
        r += 1

print("Yes" if q + r <= p + 1 else "No")

Measured memory_bytes: 14252
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
string s;
long long ans,len;
long long f(long long a,long long i)
{
    long long s=0;
    long long cnt=i;
    i=pow(2,i);
    s+=i;
    for(int j=1;j<=len-cnt-1;j++)
    {
        s=s*10+i;
        i*=2;
    }
    return a*s;
}
int main()
{
    cin>>s;
    len=s.length();
    for(long long i=0;i<s.length();i++)
    {
        ans+=f(s[i]-'0',i);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

ll dp[2100][2100];  // dp[i][j] := Sのi文字目までとTのj文字目までを見てペアにしたときの場合の数
ll sdp[2100][2100]; // sdp[i][j]:= : sum = 0 , rep(x,i)rep(y,j)sum+=dp[x][y], sdp[i][j] = sum

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> S(N), T(M);
    rep(i, N) cin >> S[i];
    rep(i, M) cin >> T[i];
    dp[0][0] = 1;
    sdp[1][1] = 1;

    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= M; j++)
        {
            dp[i][j] %= MOD;
            sdp[i][j] %= MOD;
            if (i == 0 && j == 0)
                continue;
            if (i - 1 >= 0 && j - 1 >= 0 && S[i - 1] == T[j - 1])
            {
                dp[i][j] = sdp[i][j]%MOD;
                dp[i][j] %= MOD;
            }
            sdp[i + 1][j + 1] = (sdp[i + 1][j]%MOD + sdp[i][j + 1]%MOD - sdp[i][j]%MOD + dp[i][j]%MOD + MOD) % MOD;
            sdp[i + 1][j + 1]%= MOD;
        }
    }
    cout << sdp[N + 1][M + 1] % MOD << endl;
}


Measured memory_bytes: 67840
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
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 LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};




int main(){
    int n;cin >> n;
    vector<int> a(n),b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    int ans = INF;
    for (int bit = 0; bit < (1<<n); bit++) {
        bool f = true;
        vector<P> v(n);
        for (int i = 0; i < n; i++) {
            if((bit>>i)&1) v[i] = mp(b[i], i);
            else v[i] = mp(a[i], i);
        }
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            P mi = mp(INF,INF);
            int id = 0;
            for (int j = i; j < n; j++) {
                if((abs(i-v[j].sc)%2==((bit>>v[j].sc)&1))&&chmin(mi, v[j])) id = j;
            }
            for (int j = id; j > i; j--) {
                swap(v[j], v[j-1]);
                tmp++;
            }
        }
        for (int i = 0; i < n; i++) {
            if(abs(v[i].sc - i)%2 != ((bit >> v[i].sc)&1)){
                f = false;
            }
        }
        for (int i = 0; i < n-1; i++) {
            if(v[i].fs > v[i+1].fs) f = false;
        }
        /*
        for (int i = 0; i < n; i++) {
            cout << v[i].sc << " ";
        }
        cout << endl;
        for (int i = 0; i < n; i++) {
            cout << v[i].fs << " ";
        }
        cout << endl;
        */
        if(f){
            ans = min(ans, tmp);
        }
    }
    if(ans!=INF) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	long long int n;
	cin >> n;
	long long int a[5];
	rep(i,5){
		cin >> a[i];
	}
	int t=0;
	long long int tmp=min({a[0],a[1],a[2],a[3],a[4]});
	if (n==tmp||n%tmp==0)
		t=1;
	cout <<n/tmp+5-t<<endl;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int n;  cin >> n;
    ll a[n+1],b[n];
    rep(i,n+1)    cin >> a[i];
    rep(i,n)    cin >> b[i];

    ll ans(0);
    rep(i,n){
        if(a[i]<=b[i]){
            ans += a[i];
            b[i] -= a[i];
            a[i] = 0;
        }else{
            ans += b[i];
            a[i] -= b[i];
            b[i] = 0;
        }

        if (a[i+1]<=b[i]){
            ans += a[i + 1];
            b[i] -= a[i];
            a[i+1] = 0;
        }else{
            ans += b[i];
            a[i + 1] -= b[i];
            b[i] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

void solve(long long N, long long K, std::vector<long long> A){
  ll ans = 0;
  for(ll i=0; i<N; i++) {
    ll cnt = 0;
    for(ll j=i; j<N; j++) {
      if(A[j]<A[i]) {
	cnt++;
      }
    }
    ans += (cnt*K)%MOD;
    ans %= MOD;
    //ans = ans % MOD;
  }
  for(ll i=0; i<N; i++) {
    ll cnt = 0;
    for(ll j=0; j<N; j++) {
      if(A[j]<A[i]) {
	cnt++;
      }
    }
    //ans+=(((K-1)*(2*cnt+(K-2)*cnt))/2)%MOD;
    ans += (cnt*((K*(K-1)/2)%MOD))%MOD;
    //ans += ((((K*(K-1))%MOD)*cnt)/2)%MOD;
    ans %= MOD;
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> A(N-1-0+1);
  for(int i = 0 ; i < N-1-0+1 ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, K, std::move(A));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];


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

    string s;
    while(N >0){
        s += to_string(N%K);
        N /= K;
    }
    cout << s.size() << endl;


}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, A[100005];
ll ans = 0;

int main(){
	getint(N);
	for(register int i = 1, B; i <= N; i++){
		getint(A[i]), getint(B);
		A[i] += B, ans -= B;
	}
	sort(A + 1, A + N + 1);
	for(register int i = N; i > 0; i -= 2) ans += A[i];
	return printf("%lld\n", ans), 0;
}

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

int main(void){
    int N;
    cin >> N;
    string S,T;
    cin >> S >> T;
    
    for(int i = 0 ; i < N ; i++){
        cout << S.at(i) << T.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
#define el '\n'
template<class T> bool rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
typedef long long ll; typedef long double ld; typedef double dd; typedef pair<int, int> pii;
const ll INFLL=0x7f7f7f7f7f7f7f7f, MOD=1e9+7; const int INF=0x7f7f7f7f;

//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';

/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vv<int> vis, color; 
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){if(a<0) a=-a; if(b<0) b=-b; while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());


int n; cin>>n;
map<string,int> m;
int ans=0;
while(n--){
	string s; cin>>s;
	sort(all(s));
	ans+=m[s];
	m[s]++;
}
cout<<ans<<el;

return 0;
}


Measured memory_bytes: 11264
s=input()
t=input()
ls=len(s)
alpha="abcdefghijklmnopqrstuvwxyz"
c={}
l={}
for i in alpha:
  c[i]=[]
  l[i]=0
  
for i in range(ls):
  c[s[i]].append(i)
  l[s[i]]+=1

f=True
x,y=0,-1
for i in t:
  if l[i]==0:
    f=False
    break
  left,right=-1,l[i]
  while right-left!=1:
    a=(left+right)//2
    if c[i][a]>y:
      right=a
    else:
      left=a
  if right==l[i]:
    x+=1
    y=c[i][0]
  else:
    y=c[i][right]
if f:
  print(x*ls+y+1)
else:
  print(-1)

Measured memory_bytes: 78696
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main() {
	int n;
	int max1, max2;
	int x, y;//x:4ドルケーキ個数 y:7ドルケーキ個数
	scanf("%d", &n);
	max1 = n / 4;	//4ドルケーキのMAX個数
	max2 = n / 7;	//7ドルケーキのMAX個数
	for (x = 0; x <= max1; x++) {
		for (y = 0; y <= max2; y++) {
			if ((y * 7 + x * 4) == n) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");

	return 0;
}


Measured memory_bytes: 128
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int r;
    cin >> r;

    cout << r * r << endl;
}

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

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

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

    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    vector<ll> v;
    for(int i = 0; i < n; i++){
        ll sum = 0;
        for(int j = i; j < n; j++){
            sum += a[j];
            v.push_back(sum);
        }
    }
    ll ans = 0;
    for(int i = 50; i >= 0; i--){
        ans += 1LL << i;
        int num = 0;
        for(ll j : v){
            if((ans&j)==ans) num++;
        }
        if(num < k) ans -= 1LL << i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 300000;
const int mod = 1e9 + 7;
const int K = 60;
const int M = 16;
int a[N], pr[N][2], suf[N][2];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for (int i = 1; i + i <= n; i++){
        pr[i][0] = pr[i - 1][0] + a[2 * i - 1];
        pr[i][1] = max(pr[i - 1][1] + a[2 * i], pr[i - 1][0] + a[2 * i]);
    }
    for (int i = 1; i + i <= n; i++){
        suf[i][0] = suf[i - 1][0] + a[n - 2 * i + 2];
        suf[i][1] = max(suf[i - 1][1] + a[n - 2 * i + 1], suf[i - 1][0] + a[n - 2 * i + 1]);
    }
    if (n % 2 == 0){
        cout << max(pr[n / 2][0], pr[n / 2][1]);
        return 0;
    }
    int ans = -2e18;
    for (int i = 1; i <= n; i += 2){
        int l = max(pr[i / 2][0], pr[i / 2][1]);
        int r = max(suf[(n - i) / 2][0], suf[(n - i) / 2][1]);
        ans = max(ans, l + r);
    }
    cout << ans;
}


Measured memory_bytes: 8324
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

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

    ll u500 = X / 500;
    X -= u500 * 500;
    ll u5 = X / 5;
    X -= u5 * 5;

    cout << u500 * 1000 + u5 * 5 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * 
 * WWWWWWWRRRRR 5 WRWW 1
 */

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);
		Solution sol = new Solution();
		sol.solve(in, out);
		out.close();
	}

	private static class Solution {
		private void solve(InputReader in, PrintWriter out) {
			int n = in.ni(), ans = 0;
			char[] stones = in.n().toCharArray();
			int l = 0, r = n - 1;
			while (l < r) {
				while (l < n && stones[l] == 'R')
					++l;
				while (r >= 0 && stones[r] == 'W')
					--r;
				if (l < r) {
					++ans;
					++l;
					--r;
				}
			}
			out.println(ans);
		}
	}

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

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

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

		private int ni() {
			return Integer.parseInt(n());
		}
	}
}

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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define PI      acos(-1.0)
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    int x,a,b,s=0;
    cin>>x;
    cin>>a>>b;
    for(int i=a; i<=b; i++)
    {
        if(i%x==0)
        {
            s=1;
            break;
        }
    }
    if(s==1)
        cout<<"OK"<<nl;
    else cout<<"NG"<<nl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string r;
  cin >> r;
  int p = 700;
  if(r[0] == 'o' ){
    p = p + 100;};
  
    if(r[1] == 'o' ){
      p = p + 100;};
  
      if(r[2] == 'o' ){
        p = p + 100;};
  
  cout << p << endl;
}

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

using namespace std;

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

    set<string> st;

    for(int i=0; i < n; i++){
        string s;
        cin >> s;
        st.insert(s);
    }

    cout << st.size() << endl;

    return 0;
}

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

int main(){
	int n;
	string *s;
	string ans="";
	cin>>n;
	s= new string[n];
	
	for(int i=0; i<n; i++)	cin>> s[i];

	int alp[n][26];
	for(int i=0; i<n; i++)
		for(int j=0; j<26; j++)
			alp[i][j]=0;
	
	for(int i=0; i<n; i++){
		for(int j=0; j<s[i].size(); j++){
			int tmp= s[i].at(j)-'a';
			alp[i][tmp]++;
		}
	}
	
	for(int i=0; i<26; i++){
		int times=32767;
		for(int j=0; j<n; j++){
			times= min(times, alp[j][i]);
		}

		for(int j=0; j<times; j++){
			ans+= 'a'+i;	
			
		}
				
	}

	cout<< ans<<endl;

	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <iostream>
//#include <iomanip>
//#include <vector>
//#include <cmath>
//#include <algorithm>
using namespace std;


#define F first
#define PB push_back
#define MP make_pair

typedef unsigned long long ll;

ll p = pow(10, 9) + 7;





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

    int a, b;
    cin >> a >> b;
    int count = 1;
    int ans = 0;
    while(count < b)
    {
        count = count - 1 + a;
        ans++;
    }
    cout << ans << endl;


}


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

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Self {
        Self { reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let n: i64 = sc.get();

    let ans = match n % 10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        3 => "bon",
        _ => unreachable!(),
    };

    println!("{}", ans);
}


Measured memory_bytes: 2080
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    ll A, B;
    cin >> A >> B;
    if ((A + B) % 2 == 0)
    {
        cout << (A + B) / 2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }

    return;
}

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


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array

strToInt s = (read :: String -> Int)


main = do

   n <- readLn :: IO Int
   
   let xn =  [1..n]
   print (maxs 1 xn)


count :: Int -> Int
count x = if (x `mod` 2) == 0
        then 1 + (count (x `div` 2))
        else 0
        
maxs :: Int -> [Int] -> Int
maxs x [] = x
maxs x (y:ys) = if (count x) < (count y)
                then maxs y ys
                else maxs x ys

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

int main() {
    long long N, M;
    cin >> N >> M;
    vector<pair<long long, long long>> AB(N);
    for (long long i = 0; i < N; i++) {
        cin >> AB[i].first >> AB[i].second;
    }

    sort(AB.begin(), AB.end());
    long long ans = 0;
    for (long long i = 0; i < N; i++) {
        long long buyNum = M - AB[i].second >= 0 ? AB[i].second : M;
        ans += buyNum * AB[i].first;
        M -= AB[i].second;
        if (M < 0) {
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h1 = sc.nextInt()
    val m1 = sc.nextInt()
    val h2 = sc.nextInt()
    val m2 = sc.nextInt()
    val k = sc.nextInt()
    println(problema(h1, m1, h2, m2, k))
}

fun problema(h1: Int, m1: Int, h2: Int, m2: Int, k: Int): Int {
    val m1 = m1 + h1 * 60
    val m2 = m2 + h2 * 60
    return m2 - m1 - k
}

Measured memory_bytes: 36348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;
//const ll INF=1LL<<60;

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

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

int N;
set<string> SE;

void solve(int now,string S){
    if(now==N+1){
        vector<int> wh(10,INF),ti;
        for(int i=0;i<N;i++){
            if(wh[S[i]-'a']==INF){
                ti.push_back(i);
                wh[S[i]-'a']=ti.size()-1;
            }
        }
        
        string T;
        
        for(int i=0;i<N;i++){
            T+=char('a'+wh[S[i]-'a']);
        }
        
        SE.insert(T);
        return ;
    }
    for(int i=1;i<=now;i++){
      if(now>=2&&i==now&&S[now-2]!='a'+now-2) return;
        S+=char('a'+i-1);
        solve(now+1,S);
        S=S.substr(0,int(S.size())-1);
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    
    solve(1,"");
    
    for(auto S:SE) cout<<S<<"\n";
    
}


Measured memory_bytes: 14208