akhauriyash/Code-Regression huggingface dataset:
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32
    }
    if (a == b && a != c) ||
       (a == c && a != b) ||
       (b == c && a != b) {
        println!("Yes");
    } else {
        println!("No");
    }
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    string s,t;
    cin>>s>>t;
    ll n=s.length();ll l=t.length();ll i,j;
    ll k=l;
    for(i=0;i<n-l+1;i++){
        ll m=0;
        for(j=0;j<l;j++){
            if(s[i+j]!=t[j])
            m++;
        }
        k=min(m,k);
    }
    cout<<k;
}

Measured memory_bytes: 3632
def D_AtCoder_Express(N, T, V):
    """
    N:時間の区間の総数
    T:各時間区間の秒数
    V:各時間区間において許される最大速度
    """
    from itertools import chain

    # 単位時間を0.5秒としたときの、各時間区間での速度を格納する
    # 0.5秒とする理由は解説参照
    speed = list(chain.from_iterable([v] * (2 * t) for t, v in zip(T, V)))

    # 出発時の速度を0、到着時の速度を0と付け加える
    speed = [min(v1, v2) for v1, v2 in zip([0] + speed, speed + [0])]
    length = len(speed)

    # 制限速度に達しているならその速度を格納し、
    # 達していないなら加速させた速度を格納(加速度は1m/(s・s)と定める)
    speed_previous = 0  # 更新前の速度
    for current in range(1, length):
        speed[current] = speed_previous = min(
            speed[current], speed_previous + 0.5)

    # 同じ処理をリストの逆向きに行う(減速を表す)
    speed_previous = 0
    for current in range(length - 1, 0, -1):
        speed[current] = speed_previous = min(
            speed[current], speed_previous + 0.5)

    # 距離(v-tグラフの面積)は台形法で求める
    # (グラフの形より、これ以上の精度の方法は不要)
    return sum((v1 + v2) * 0.5 / 2 for v1, v2 in zip(speed, speed[1:]))

N = int(input())
T = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]
print(D_AtCoder_Express(N, T, V))

Measured memory_bytes: 4384
#include <stdio.h>
int main() {
    int h,w;
    while (scanf("%d %d", &h, &w) && (h || w)) {
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2616
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    long long x, y;
    cin >> x >> y;

    int ans = 0;
    while(x <= y){
        ++ ans;
        x *= 2;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  int n;
  cin >> n;
  VI num(n);
  rep(i,n) cin >> num.at(i);
  int cnt2=0;
  int cnt4=0;
  rep(i,n){
    if(num.at(i)%4==0)cnt4++;
    else if(num.at(i)%2==0)cnt2++;
  }
  int cnt=n-cnt4-cnt2;
  bool a=false;
  if(cnt==0)a=true;
  else if(cnt2==0 && cnt4+1>=cnt)a=true;
  else if(cnt2!=0 && cnt4>=cnt)a=true;
  if(a) cout<< "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    if (a < b)
    {
        rep(i, b)
        {
            cout << std::to_string(a);
        }
    }
    else
    {
        rep(i, a)
        {
            cout << std::to_string(b);
        }
    }

    return 0;
}

Measured memory_bytes: 3036
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int a,b;
  cin >> a >> b;
  int ans;

  ans = a + a - 1;

  ans = max(ans, a + b);
  ans = max(ans, b + b - 1);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9+7;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  long long int sa = 0;
  long long int sb = 0;
  for(int i=0; i<n; i++){
    cin >> a[i];
    sa += a[i];
  }
  for(int i=0; i<n; i++){
    cin >> b[i];
    sb += b[i];
  }

  long long int x = 0;
  long long int y = 0;
  for(int i=0; i<n; i++){
    if( a[i] < b[i] ){
      y += (b[i]-a[i])/2;
      if((b[i]-a[i])%2 == 1){
        y++;
      }
    }else if( a[i] > b[i] ) x += a[i]-b[i];
  }
  long long int d = sb - sa;
  if( d < x || d < y){
    cout << "No" << endl;
  }else cout << "Yes" << endl;


  return 0;
}




//


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

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

  long long tot = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) tot += i;
  }

  cout << tot << endl;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int length = s.length();
		int[] ans = new int[100000];

		int Rs = 0;
		int Ls = 0;
		int changeid = -1;
		Boolean flag = true;

		for(int i = 0 ; i < length-1 ; i++){
			if(flag){
				if(s.charAt(i) == 'R'){
					Rs++;
				}else{
					Ls++;
					changeid = i-1;
					flag = false;
				}
			}else{
				if(s.charAt(i) == 'R'){

					if(((Rs+Ls)&1) == 0){
						ans[changeid] = (Rs+Ls)/2;
						ans[changeid+1] = (Rs+Ls)/2;
					}else{
						if((Rs&1) == 0){
							ans[changeid] = (Rs+Ls-1)/2;
							ans[changeid+1] = (Rs+Ls+1)/2;
						}else{
							ans[changeid] = (Rs+Ls+1)/2;
							ans[changeid+1] = (Rs+Ls-1)/2;
						}
					}

					Rs = 0;
					Ls = 0;
					flag = true;
					changeid = i;
					Rs++;
				}else{
					Ls++;
				}
			}
		}

		{
			Ls++;
			if(flag){
				changeid = length-2;
			}else{

			}
			if(((Rs+Ls)&1) == 0){
				ans[changeid] = (Rs+Ls)/2;
				ans[changeid+1] = (Rs+Ls)/2;
			}else{
				if((Rs&1) == 0){
					ans[changeid] = (Rs+Ls-1)/2;
					ans[changeid+1] = (Rs+Ls+1)/2;
				}else{
					ans[changeid] = (Rs+Ls+1)/2;
					ans[changeid+1] = (Rs+Ls-1)/2;
				}
			}
		}
		StringBuilder val = new StringBuilder();
		for(int i = 0 ; i < length-1 ; i++){
			val.append(""+ans[i]+" ");
		}
		val.append(""+ans[length-1]);
		System.out.println(new String(val));
	}

}

Measured memory_bytes: 43240
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<stack>
#include<list>
using namespace std;


int main() {
	stack<int> s[1000];
	int n,q,t,x;
	int query;
	cin >> n>>q;
	for (int i = 0; i < q; i++)
	{
		cin >> query>>t;
		switch (query)
		{
		case 0:
			cin >> x;
			s[t].push(x);
			break;
		case 1:
			if (s[t].size() == 0)
			{
			}
			else
			{
				cout << s[t].top() << endl;
			}
			break;
		case 2:
			if (s[t].size() != 0)
			{
				s[t].pop();
			}

			break;
		}
	}
	

	return 0;
}


Measured memory_bytes: 4316
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
int main(){
    int N;
    cin >> N;
    int MAX = -1;
    int sum = 0;
    for(int i=0;i<N;++i){
        int l;
        cin >> l;
        sum += l;
        MAX = max(MAX,l);
    }

    if(sum > 2*MAX ) cout << "Yes" << endl;
    else cout << "No" << endl;   
}

Measured memory_bytes: 256
def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

def factorize(n):
    result = []
    dev = 2
    while dev ** 2 <= n:
        if n % dev == 0:
            n //= dev
            result.append(dev)
        else:
            dev += 1
    if n > 1:
        result.append(n)
    return result

A, B = [int(x) for x in input().split()]
lst = factorize(gcd(A, B))
print(len(set(lst)) + 1)

Measured memory_bytes: 3064
implicit none
integer n,i,j,k
integer :: sum=0
integer,allocatable,dimension(:)::v,c

read(5,*)n
allocate(v(n),c(n))
read(5,*) (v(i),i=1,n)
read(5,*) (c(j),j=1,n)

do k=1,n
if((v(k)-c(k)).gt.0) then
sum=sum+v(k)-c(k)
endif
enddo

write(6,*)sum


deallocate(v,c)
end

Measured memory_bytes: 256
S = input()
T = input()

dp = [[0] * (len(T) + 1) for i in range(len(S) + 1)]

for i in range(len(S)):
  for j in range(len(T)):
    if S[i] == T[j]:
      dp[i + 1][j + 1] = dp[i][j] + 1
    else:
      dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])
      
s = len(S)
t = len(T)
ans = ""
while s > 0 and t > 0:
  if dp[s][t] == dp[s - 1][t]:
    s -= 1
  elif dp[s][t] == dp[s][t - 1]:
    t -= 1
  else:
    ans += S[s - 1]
    s -= 1
    t -= 1
    
print(ans[::-1])

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

ll const MAX = 3e+5;
ll const D = 64;
ll const MOD = (ll)1e+9 + 7;
P table[MAX+1][D];

void solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    for (ll i = N-1; i >= 0; i--) {
        ll t = A[i];
        ll j = 0;
        while (j < D) {
            ll a = t & 1;
            ll zero = table[i+1][j].first;
            ll one = table[i+1][j].second;
            if (a) one++;
            else zero++;
            table[i][j] = {zero, one};
            j++;
            t /= 2;
        }
    }


    ll ans = 0;
    rep(i, N) {
        rep(j, D) {
            if ((A[i]>>j) & 1ll) {
                ans += (((1ll << j) % MOD) * (ll)table[i][j].first) % MOD;
                ans %= MOD;
            } else {
                ans += (((1ll << j) % MOD) * (ll)table[i][j].second) % MOD;
                ans %= MOD;
            }
        }
    }

    cout << ans << endl;

    return;
}


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


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

int main() {
  long n,k,ans=0;
  cin >> n >> k;
  vector<long> v(n);
  vector<long> a(min(k,n));
  vector<long> b(min(k,n));
  for(long i=0;i<n;i++) cin >> v[i];
  a[0]=v[0];
  b[0]=v[n-1];
  
  for(long i=1;i<min(k,n);i++) a[i]=a[i-1]+v[i];
  for(long i=1;i<min(k,n);i++) b[i]=b[i-1]+v[n-i-1];

  for(long i=0;i<=min(k,n);i++) {
    for(long j=0;j<=i;j++) {
      long aaa=0;
      if(j!=0)aaa+=a[j-1];
      if(j!=i)aaa+=b[i-j-1];
      vector<long> c;
      for(long ii=0;ii<j;ii++) if(v[ii]<0) c.push_back(v[ii]);
      for(long ii=0;ii<i-j;ii++) if(v[n-ii-1]<0) c.push_back(v[n-ii-1]);
      if(c.size()>0) {
        sort(c.begin(),c.end());
        for(long ii=0;ii<k-i&&ii<c.size();ii++) aaa+=0-c[ii];
      }
      ans=max(aaa,ans);
    }
  }
  cout << ans << endl;
}

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

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	string S;
	
	cin >> S;
	
	int ans = 0;
	
	rep(i, S.length() / 2)
		if(S[i] != S[S.length() - i - 1])
			ans++;
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
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)*} };}
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        A: [i64; N],
    }
    let mut ans = -1;
    let mut p = 0;
    for i in 0..N{
        if A[p]==2{
            ans = i as i64 +1;
            break;
        }else {
            p = A[p] as usize -1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
// 2部グラフの最大マッチング
// Verified: ARC092 C 2D Plane 2N Points
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
#define REP(i, n) for (int i=0;(i)<(n);(i)++)

// LIBRARY
struct BipartiteMatching {
    vector<vector<int>> G;
    vector<int> match;
    vector<bool> used;
    BipartiteMatching(int n) {
        G.resize(n);
        used.assign(n, 0);
        match.assign(n, -1);
    }
    void add_edge(int u, int v) {
        G[u].push_back(v);
        G[v].push_back(u);
    }
    bool dfs(int v) {
        used[v] = 1;
        REP(i, G[v].size()) {
            int u = G[v][i], w = match[u];
            if (w == -1 or (not used[w] and dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
    int solve() {
        int res = 0;
        REP(i, G.size()) {
            used.assign(G.size(), 0);
            if (match[i] == -1 and dfs(i)) res++;
        }
        return res;
    }
};

// TEST
int main() {
    using P = pair<int, int>;
    int N; cin>>N;
    vector<P> red;
    vector<P> blue;
    REP(i, N) {
        int a, b; cin>>a>>b;
        red.push_back(P(a, b));
    }    
    REP(i, N) {
        int c, d; cin>>c>>d;
        blue.push_back(P(c, d));
    }
    BipartiteMatching bm(2*N);
    REP(r, N) {
        REP(b, N) {
            if (red[r].first < blue[b].first and red[r].second < blue[b].second) {
                bm.add_edge(r, b+N);
            }
        }
    }
    cout << bm.solve() << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    char str[(n + 1)];
    scanf("%s",str);
    int count = 0;
    for(int i = 1;i<n;i++){
        if(str[i] != str[(i - 1)]){
            count++;
        }
    }
    printf("%d",(count + 1));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

struct A_Info {
    int index;
    long val;

    A_Info(int input_index, long input_val) {
        index = input_index;
        val = input_val;
    }
    bool operator<(const A_Info &another) const
    {
        return val < another.val;
    };
};

int main() {
    int N, M; cin >> N >> M;
    vector<A_Info> A;
    vector<long> B;
    long a_tmp, b_tmp;
    for (int i = 0; i < N; i++) {
        cin >> a_tmp >> b_tmp;
        A.push_back(A_Info(i, a_tmp));
        B.push_back(b_tmp);
    }
    sort(A.begin(), A.end());
    int m = 0, index;
    long sum = 0;
    for (int i = 0; m < M; i++) {
        index = A[i].index;
        if (m + B[index] > M) {
            sum += A[i].val * (M - m);
            m = M;
        }
        else {
            sum += A[i].val * B[index];
            m += B[index];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3568
import sys
def input(): return sys.stdin.readline().rstrip()
def prime_fact_factorial(n):
    global e
    e=[0]*(n+1)
    for i in range(2,n+1):
        cur=i
        for j in range(2,i+1):
            while cur%j==0:
                e[j]+=1
                cur//=j
def num(m):
    return len([x for x in e if x>=m-1])
def main():
    n=int(input())
    prime_fact_factorial(n)
    print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)
        +num(5)*(num(5)-1)*(num(3)-2)//2)

if __name__=='__main__':
    main()

Measured memory_bytes: 38384
// とある人物のコード

#include <stdio.h>

int main(void)
{
	int N;
	int K;
	int cnt = 0;
	int ret = 1;


	scanf("%d",&N);
	scanf("%d",&K);
	for(cnt = 0;cnt<N;cnt++)
	{
		if(ret>K)
		{
			ret += K;
		}else
		{
			ret += ret;
		}
	}

	printf("%d",ret);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	char c;
	scanf("%d %c %d",&a,&c,&b);
	if(c=='+')
	printf("%d\n",a+b);
	else
	printf("%d\n",a-b);
	return 0;
}

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

int N;
string s;
char ans[100001];

void sim() {
	for(int i = 1; i <= N; i++) {
		if (s[i] == 'o') {
			if (ans[i] == 'S') {
				if (ans[i - 1] == 'S') ans[i + 1] = 'S';
				else ans[i + 1] = 'W';
			} else {
				// W
				if (ans[i - 1] == 'S') ans[i + 1] = 'W';
				else ans[i + 1] = 'S';
			}
		} else {
			// x
			if (ans[i] == 'S') {
				if (ans[i - 1] == 'S') ans[i + 1] = 'W';
				else ans[i + 1] = 'S';
			} else {
				// W
				if (ans[i - 1] == 'S') ans[i + 1] = 'S';
				else ans[i + 1] = 'W';
			}
		}

	}
}

bool s_check() {
	if (s[0] == 'o') {
		if (ans[N-1] == ans[1] && ans[0] == ans[N]) {
			for(int i = 0; i < N; i++) cout << ans[i];
			cout << endl;
			return true;
		}
	} else {
		if (ans[N-1] != ans[1] && ans[0] == ans[N]) {
			for(int i = 0; i < N; i++) cout << ans[i];
			cout << endl;
			return true;
		}
	}
	return false;
}

bool w_check () {
	if (s[0] == 'o') {
		if (ans[N-1] != ans[1] && ans[0] == ans[N]) {
			for(int i = 0; i < N; i++) cout << ans[i];
			cout << endl;
			return true;
		}
	} else {
		if (ans[N-1] == ans[1] && ans[0] == ans[N]) {
			for(int i = 0; i < N; i++) cout << ans[i];
			cout << endl;
			return true;
		}
	}

	return false;
}

int main () {
	cin >> N >> s;
	
	// Sheep loop
	ans[0] = 'S';
	ans[1] = 'S';
	sim();
	if (s_check()) return 0;

	ans[0] = 'S';
	ans[1] = 'W';
	sim();
	if (s_check()) return 0;

	// Wolf loop
	ans[0] = 'W';
	ans[1] = 'S';
	sim();
	if (w_check()) return 0;

	ans[0] = 'W';
	ans[1] = 'W';
	sim();
	if (w_check()) return 0;
	
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{

    int n;
    int hx,hy,dx,dy;
    int[] x,y;
    double[][] distY;
    double[] distM;
    int[] collect;
    boolean can;

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    n = sc.nextInt();
	    hx = sc.nextInt();
	    hy = sc.nextInt();
	    dx = sc.nextInt();
	    dy = sc.nextInt();
	    if(n==0 && hx==0 && hy==0 && dx==0 && dy==0) break;
	    x = new int[n];
	    y = new int[n];
	    for(int i=0; i<n; i++){
		x[i] = sc.nextInt();
		y[i] = sc.nextInt();
	    }
	    
	    distY = new double[n+1][n+1];
	    distM = new double[n];
	    for(int i=0; i<n; i++){
		double dist = Math.sqrt((hx-x[i])*(hx-x[i])+(hy-y[i])*(hy-y[i]));
		distY[0][i+1] = dist;
		distY[i+1][0] = dist;
		dist = Math.sqrt((dx-x[i])*(dx-x[i])+(dy-y[i])*(dy-y[i]));
		distM[i] = dist;
	    }
	    for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
		    double dist = Math.sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		    distY[i+1][j+1] = dist;
		    distY[j+1][i+1] = dist;
		}
	    }

	    collect = new int[n];
	    can = false;
	    dfs(0,0,0);
	    
	    if(can){
		System.out.println("YES");
	    }else{
		System.out.println("NO");
	    }
	}
    }

    void dfs(int point, int cnt, double d){
	if(can) return;
	if(cnt==n){
	    can = true;
	    return;
	}

	for(int i=0; i<n; i++){
	    if(collect[i]==0){
		if(d+distY[point][i+1]>=distM[i]){
		    return;
		}
	    }
	}

	for(int i=0; i<n; i++){
	    if(collect[i]==0){
		double newD = d+distY[point][i+1];
		collect[i] = 1;
		dfs(i+1, cnt+1, newD);
		collect[i] = 0;
	    }
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 12000
#include <iostream>
#define MAX 1000001

using namespace std;

bool prime[MAX];

void hurui(void){

  fill(prime, prime + MAX, true);
  prime[0] = prime[1] = false;

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

}

int main(void){

  hurui();
  int a,b,n;
  while( cin >> a >> b >> n , a + b + n ){

    int cnt = 0;
    for( int i = a ; i < MAX ; i += b ){
      if( prime[i] ) cnt++;
      if( cnt == n ){
	cout << i << endl;
	break;
      }
    }

  }
  return 0;
}

Measured memory_bytes: 2136
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main() {
    int n, l;
    scanf("%d %d", &n, &l);
    vector<string> s(n);
    REP(i,n){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    for(auto ss : s){
        cout << ss;
    }
    cout << endl;
}


Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  cin >> n;
  vector<int> dp(n + 1);
  dp[0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 3; j <= i; ++j) {
      dp[i] = (dp[i] + dp[i - j]) % MOD;
    }
  }
  cout << dp[n] << '\n';
  return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
struct q{
  int f, a, x, y, idx;
};

int main() {
  int N;
  vector< q > Query[2];
  cin >> N;
  for(int i = 0; i < N; i++){
    int f, a, t, x, y;
    cin >> f >> a >> t >> x >> y;
    Query[t].push_back((q){f, a, x, y, i});
  }
  int A[2] = {-1,-1}, B[2] = {-1, -1};
  for(int k = 0; k < 2; k++){ 
    for(int i = 1; i < Query[k].size(); i++) {
      q& prev = Query[k][i - 1], now = Query[k][i];
      if(prev.a == now.a) continue;
      if(prev.idx + 1 != now.idx) continue;
      int dist = pow(abs(prev.x - now.x), 2) + pow(abs(prev.y - now.y), 2);
      if(A[k] < dist) {
        A[k] = dist;
        B[k] = now.f - prev.f;
      } else if(A[k] == dist && B[k] > now.f - prev.f) {
        B[k] = now.f - prev.f;
      }
    }
  }
  cout << fixed << setprecision(10);
  for(int k = 0; k < 2; k++) {
    if(A[k] == -1) {
      cout << -1 << " " << -1 << endl;
    } else {
      cout << sqrt(A[k]) << " " << (double)B[k] / 60 << endl;
    }
  }

}

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

int main(void){
	int n, k;
	cin >> n >> k;
	if(k>(n-1)*(n-2)/2){
		cout << -1 << endl;
		return 0;
	}
	vector<int> a(10000), b(10000);
	int m = n-1 + (n-1)*(n-2)/2 - k;
	cout << m << endl;
	int cnt = 0;
	for(int i = 2; i <= n; ++i){
		cout << 1 << " " << i << endl;
		cnt++;
		if(cnt == m) return 0;
	}
	for(int i = 2; i <= n; ++i){
		for(int j = i+1; j <= n; ++j){
			cout << i <<  " " << j << endl;
			cnt++;
			if(cnt == m) return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 384
using System;
class main{
    static void Main(string[] args){
        int n = int.Parse(Console.ReadLine());
        int tpoint = 0;
        int hpoint = 0;
        for (int i = 0; i < n; i++)
        {
            string[] data = Console.ReadLine().Split(' ');
            if (data[0] == data[1])
            {
                tpoint++; hpoint++;
                continue;
            }
            char[] t = data[0].ToCharArray();
            char[] h = data[1].ToCharArray();
            int tlength = t.Length, hlength = h.Length;
            int charcount = tlength > hlength ? hlength:tlength;
            bool winner = tlength > hlength ? true : false;

            for (int j = 0 ; j < charcount; j++)
            {
                if (t[j] > h[j])
                {
                    winner = true;
                    break;
                }
                else if (t[j] < h[j])
                {
                    winner = false;
                    break;
                }
            }

            if(winner)
            {
                tpoint += 3;
            }else{
                hpoint += 3;
            }
        }
        Console.WriteLine("{0} {1}", tpoint, hpoint);
    }
}

Measured memory_bytes: 5720
#include <iostream>

using namespace std;

int main() {
  int D;
  cin >> D;
  cout << "Christmas ";
  for (int i = 0; i < (25 - D); ++i) {
    cout << "Eve";
    if (i < (25 - D) - 1) {
    	cout << " ";
    }
  }
  cout << endl;
}

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

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	ll ans = 0;
	rep(i, s.size()) {
		if (s[i] == 'W') {
			cnt++;
			ans += i - cnt + 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
using ll=long long;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
using ll = long long;
using namespace std;

vector<int> sieve_of_eratosthenes(int n) { // enumerate primes in [2,n] with O(n log log n)
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i*i <= n; ++i)
        if (is_prime[i])
            for (int k = i+i; k <= n; k += i)
                is_prime[k] = false;
    vector<int> primes;
    for (int i = 2; i <= n; ++i)
        if (is_prime[i])
            primes.push_back(i);
    return primes;
}
map<ll,int> prime_factrorize(ll n, vector<int> const & primes) {
    map<ll,int> result;
    for (int p : primes) {
        if (n < p ) break;
        while (n % p == 0) {
            result[p] += 1;
            n /= p;
        }
    }
    if (n != 1) result[n] += 1;
    return result;
}

const int mod = 1e9+7;
int main() {
    int n; cin >> n;
    vector<int> primes = sieve_of_eratosthenes(sqrt(n) + 3);
    map<ll,int> factors;
    repeat_from (i,1,n+1) {
        for (auto it : prime_factrorize(i, primes)) {
            int p, cnt; tie(p, cnt) = it;
            factors[p] += cnt;
        }
    }
    ll ans = 1;
    for (auto it : factors) {
        int cnt = it.second;
        ans = ans * (1 + cnt) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,a,b;
    cin >> n >> a >> b;
    if(n>a*b||n<a+b-1){
        print(-1);
        return;
    }
    ll cur=n;
    rp(i,a) princ(cur-a+i+1);
    cur-=a;
    if(cur==0) {
        cout << endl;
        return;
    }
    rp(i,(n-a)%(b-1)){
        ll p=(n-a)/(b-1)+1;
        rp(j,p) princ(cur-p+j+1);
        cur-=p;
    }
    while(cur>0){
        ll p=(n-a)/(b-1);
        rp(j,p) princ(cur-p+j+1);
        cur-=p;
    }
    cout << endl;
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int n;
int ans=0;
char d[3] = {'7', '5', '3'};

void count(string str){
	if(str.size()>0){
      if(stoll(str) > n) return;
    }

	bool is = true;
	for(int i=0; i<3; i++){
		if(str.find(d[i]) < 0 || str.find(d[i]) >= str.size()){
			is = false;
		}
	}
	if(is) ans++;

	for(int i=0; i<3; i++){
		count(str+d[i]);
	}
}

int main() {
	cin >> n;
	count("");
	cout << ans << endl;
}

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

int main() 
{
	vector<int> abc(3);
	for (auto& t : abc) {
		cin >> t;
	}

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

	int ret = 0;
	int diff12 =  abc[2] - abc[1];
	int diff23 = abc[1] - abc[0];
	if (diff23 % 2 == 0) {
		ret = diff12 + (diff23 / 2);
	}
	else {
		ret = diff12 + 1 + ((diff23+1) / 2);
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets.strip.to_i
v = gets.strip.split(" ").map(&:to_i)
c = gets.strip.split(" ").map(&:to_i)

ans = 0
n.times do |i|
  t = v[i] - c[i]
  if t > 0
    ans += t
  end
end

puts ans


Measured memory_bytes: 3836
#include <stdio.h>
#include <ctype.h>
#include <memory.h>
int main(void){
    int n,i,o,min,max,t;
    char line[1025],line1[52];
    scanf("%d",&n);
    for(i=0;memset(line,0,sizeof(line)),min=t=25,max=26,i<n;i++){
        scanf("%s",line);
        line1[min]=line[0];
        for(o=3;line[o];o++)
            if(isalpha(line[o])){
                if(line[o-1] == '>'){
                    line1[++t]=line[o];
                    if(max==t)
                        max++;
                }
                else{
                    if(min==t)
                        min--;
                    line1[--t]=line[o];
                }
            }
        line1[max]=0;
        printf("%s\n",line1+min);
    }
    return 0;
}

Measured memory_bytes: 584
N = int(input())
F = []
P = []
for i in range(N):
    temp = [int(i) for i in input().split()]
    tt = 0b0
    for j in range(len(temp)):
        tt += 2 ** j * temp[j]
    F.append(tt)
    
for i in range(N):
    temp = [int(i) for i in input().split()]
    P.append(temp)

def bene(bit):
    res = 0
    for i in range(N):
        a = bit & F[i]
        cc = 0
        for j in str(bin(a)):
            if j == "1":
                cc += 1
        res += P[i][cc]
    return res

benes = [bene(i) for i in range(1,1024)]
benes.sort()
print(benes[-1])

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

using namespace std;

const int N=3e5+5;

int co[N],ans[N];
int n;

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		co[x]++;
	}
	sort(co+1,co+n+1);
	int l=1,curs=0;
	for(int i=1;i<=n;i++)
	{
		while(l<=n&&co[l]<i) curs+=co[l++];
		ans[i]=(curs+(n-l+1)*i)/i;
	}
	ans[0]=(1<<30);
	l=n;
	for(int i=1;i<=n;i++)
	{
		while(ans[l]<i) l--;
		printf("%d\n",l);
	}
}

Measured memory_bytes: 6148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	private static BufferedReader br;
	
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		int c = Integer.parseInt(line[2]);
		
		if((a != b || a !=c || b!=c) && (a == b || a ==c || b==c)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  vector<ll>com(100001);
  com.at(0)=0;com.at(1)=0;
  for(long i=2;i<=100000;i++){
    com.at(i)=i*(i-1)/2;
  }
  
  int N;cin>>N;
  vector<string>s(N);
  for(int i=0;i<N;i++){
    cin>>s.at(i);
    sort(s.at(i).begin(),s.at(i).end());
    //cout<<s.at(i)<<endl;
  }
  
  sort(s.begin(),s.end());
  
  ll res=0;
  int count=0;
 
  for(int i=1;i<N;i++){
    if(s.at(i)==s.at(i-1)){
      count++;
    }
    else{
      res+=com.at(count+1);
      count=0;
    }
  }
  res+=com.at(count+1);
  
  cout<<res;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int N; cin >> N;
    VI a(N); REP(i,N){cin >> a[i]; a[i]--;}
    int ans = 0;
    REP(i,N){
        if(a[i] < i) continue;
        if(i == a[a[i]]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

char mp[8][9];

int A[4][2] = {{0, 0}, {0, 1}, {1, 0}, {1, 1}};
int B[4][2] = {{0, 0}, {1, 0}, {2, 0}, {3, 0}};
int C[4][2] = {{0, 0}, {0, 1}, {0, 2}, {0, 3}};
int D[4][2] = {{0, 1}, {1, 0}, {1, 1}, {2, 0}};
int E[4][2] = {{0, 0}, {0, 1}, {1, 1}, {1, 2}};
int F[4][2] = {{0, 0}, {1, 0}, {1, 1}, {2, 1}};
int G[4][2] = {{1, 0}, {1, 1}, {0, 1}, {0, 2}};

int main()
{
	int nyan = 0;
	while (1) {
		int i = 0;
		while (1) {
			int res = scanf("%s", mp[i++]);
			if (res == EOF) return 0;
			if (i == 8) break;
		}

		int cnt;

		for (int i = 0; i < 8; ++i) for (int j = 0; j < 8; ++j) {
			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + A[k][0], nx = j + A[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("A");
				continue;
			}

			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + B[k][0], nx = j + B[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("B");
				continue;
			}

			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + C[k][0], nx = j + C[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("C");
				continue;
			}

			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + D[k][0], nx = j + D[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("D");
				continue;
			}

			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + E[k][0], nx = j + E[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("E");
				continue;
			}

			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + F[k][0], nx = j + F[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("F");
				continue;
			}

			cnt = 0;
			for (int k = 0; k < 4; ++k) {
				int ny = i + G[k][0], nx = j + G[k][1];
				if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8 || mp[ny][nx] == '0') break;
				cnt++;
			}
			if (cnt == 4) {
				puts("G");
				continue;
			}
		}
	}
}

Measured memory_bytes: 1108
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a; cin >> n;
	int test[100001] = { 0 };
	for (int h = 0; h < n; h++) {
		cin >> a;
		test[h] = a;
	}
	for (int h = n - 1; h > 0; h--) {
		if (test[h - 1] > test[h]) {
			if (test[h - 1] - test[h] == 1) {
				test[h - 1]--;
			}
			else {
				cout << "No" << endl; 
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	cin >> n;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	int n=s.size();
	int m=SZ(t);
	vector<vector<int>> lcs(n+1,vector<int>(m+1,0));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1]==t[j-1]){
				lcs[i][j]=1+lcs[i-1][j-1];
			}
			else{
				lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
			}
		}
	}
	int len=lcs[n][m];
	vector<char> ans(len);
	int c=0;
	int p=n-1,q=m-1;
	while(c!=len){
		if(s[p]==t[q]){
			ans[c++]=s[p];
			p--;
			q--;
		}
		else{
			if(lcs[p][q+1]>=lcs[p+1][q]){
				p--;
			}
			else{
				q--;
			}
		}
	}
	for(int i=len-1;i>=0;i--)cout<<ans[i];
	cout<<endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 150000

vector<int> G[MAX_N];

double dp[MAX_N];
double ans[MAX_N];

double dfs(int v, int pre) {
    vector<double> t;
    for (auto to : G[v]) {
        if (to == pre) continue;
        t.emplace_back(dfs(to, v));
    }
    if (t.size() == 0) return dp[v] = 0;
    double res = 0;
    rep(i, t.size()) {
        res += t[i];
    }
    return dp[v] = res / t.size() + 1;
}

void ddfs(int v, int pre) {
    for (auto to : G[v]) {
        ans[v] += dp[to] + 1;
    }
    ans[v] /= G[v].size();
    for (auto to : G[v]) {
        if (to == pre) continue;
        double t = dp[v];
        if (G[v].size() > 1)
            dp[v] = (ans[v] * G[v].size() - (dp[to] + 1)) / (G[v].size() - 1);
        else
            dp[v] = 0;
        ddfs(to, v);
        dp[v] = t;
    }
}

signed main() {
    int n;
    cin >> n;
    int u, v;
    rep(i, n - 1) {
        cin >> u >> v;
        u--;
        v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    dfs(0, -1);
    ddfs(0, -1);
    rep(v, n) {
        printf("%.10lf\n", ans[v]);
    }
    return 0;
}

Measured memory_bytes: 20864
#include<bits/stdc++.h> 
using namespace std; 
  
int check(string str) 
{ 
    
    int n = str.length(); 
    int digitSum = 0; 
    for (int i=0; i<n; i++) 
        digitSum += (str[i]-'0'); 
  
     
    return (digitSum % 9 == 0); 
} 
  

int main() 
{ 
    string str;
  cin>>str;
    check(str)?  cout << "Yes" : cout << "No "; 
    return 0; 
} 

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 200010
 
#define PI   3.14159265358979323846264338327950
 
#define PB push_back 
#define F first
#define S second
 
#define ll 	long long int
 
#define mod  1000000007
 
 
 
int main()
{
	FAST;
	string s;
	cin >> s;
	ll x = 0;
	 ll ans = INT_MAX;
	 bool fl = false;
	for(ll i = 0; i < s.size(); i ++){
		if(s[i] == 'R'){
			x ++;
			fl = true;
		}
		else{
			if(x > 0){
				ans = min(x, ans);
			x = 0;
			}
			
		}
	}
	if(x > 0){
		ans = min(x, ans);
	}
	if(!fl){
		ans = 0;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

void solve()
{
	int rect = 0;
	int diamond = 0;
	int a, b, c;
	while(~scanf("%d,%d,%d", &a, &b, &c))
	{
		if(a * a + b * b == c * c)
		{
			++rect;
		}
		else if(a == b)
		{
			++diamond;
		}
	}
	cout << rect << endl;
	cout << diamond << endl;
}

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

Measured memory_bytes: 0