akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

double res,l;

int main() {
	int n,k,i,t;
	cin>>n>>k;
	
	for(i=1;i<=n;i++){
		t = i;
		l = 1.0/n;
		while(t<k){
			t *= 2;
			l /= 2;;
		}
	  res += l;
	}
	
	cout<<fixed<<setprecision(12)<<res;
 	return 0;
}


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

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

   bool flag = false;
    for (int i=1; i<=9; i++) {
        for (int j=1; j<=9; j++) {
            if (i*j==N) flag = true;
        }
    }

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

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<unistd.h>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

struct Buffer{
    int idx;
    char buf[1025];
    Buffer(){ init(); }
    void init(){ idx = 0; cin.read(buf, 1024); }
    void check(){ if(idx == 1024){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

int cs[10][10];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    Buffer buf;
    int h = buf.next(), w = buf.next();
    // vector<vector<short>> cs(10, vector<short>(10));
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cs[i][j] = buf.next();
        }
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                cs[j][k] = min((int)cs[j][k], cs[j][i] + cs[i][k]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int a = buf.next();
            prints(a);
            if(a != -1){
                ans += cs[a][1];
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,m,V,E,d[3];
vvp g;
vvi G,c;
vi a;
vp b;

bool dfs(int v){
	V++;
	bool A=0,B=0,flag=0;
	for(auto p:g[v]){
		int u=p.first,t=p.second;
		if(a[u]==inf){
			a[u]=a[v]+t+1;
			flag|=dfs(u);
			G[v].push_back(u);
		}
		else{
			if(t) b.push_back({u,v});
			else b.push_back({v,u});
		}
		if(t) A=1,E++;
		else B=1;
	}
	d[a[v]%3]++;
	if(A&&B) flag=1;
	return flag;
}

ll f(int x){
	a[x]=V=E=0;
	b.clear();
	fill(d,d+3,0);
	if(!dfs(x)) return E;
	bool B=0;
	for(auto p:b){
		int u=p.first,v=p.second;
		if((a[u]-a[v]+300001)%3>0) B=1;
	}
	if(B) return V*V;
	return d[0]*d[1]+d[1]*d[2]+d[2]*d[0];
}

int main(){
	cin>>n>>m;
	a=vi(n,inf);
	g=vvp(n);
	G=vvi(n);
	c=vvi(n,vi(3));
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back({v,0});
		g[v].push_back({u,1});
	}
	ll res=0;
	for(int i=0;i<n;i++) if(a[i]==inf) res+=f(i);
	cout<<res<<endl;
}

Measured memory_bytes: 31864
fn f(b: usize, n: usize) -> usize {
    if n < b {
        n
    } else {
        f(b, n / b) + n % b
    }
}

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n: usize = sc.read();
    let s: usize = sc.read();

    for b in 2.. {
        if f(b, n) == s {
            println!("{}", b);
            return;
        }
        if b * b > n {
            break;
        }
    }

    // x*b+y=n
    // x+y=s
    // x*(b-1)=n-s
    // x<b x<=(b-1)
    // y<b
    if n > s {
        let sq = ((n - s) as f64).sqrt() as usize + 1;
        for x in (1..sq).rev() {
            if (n - s) % x != 0 {
                continue;
            }
            let b = (n - s) / x + 1;
            if n < x * b {
                continue;
            }

            let y = n - x * b;
            if x >= b || y >= b {
                continue;
            }
            assert_eq!(f(b, n), s, "b={} x={} n-s={}", b, x, n - s);
            println!("{}", b);
            return;
        }
    }
    if n == s {
        println!("{}", n + 1);
        return;
    }
    println!("-1");
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    cin>>n;double a[n];for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    double ans=a[0];
    for(int i=1;i<n;i++){
        ans=(ans+a[i])*0.5;
    }
    cout<<ans<<endl;
    }

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

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  
  vector<int> B(M);
  for (int i = 0; i < M; i++){
    cin >> B.at(i);
  }
  
  int ans = 0;
  for (int j = 0; j < N; j++){
    int test = 0;
    for (int i = 0; i < M; i++){
      int A;
      cin >> A;
    
      test += A * B.at(i);
    }
    test += C;
    
    if (test > 0){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3644
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()+'*'*K
h=['']*N
f,n='',''
ans=0
for i in range(N):
    if K<=i:f=h[i-K]
    n=T[i+K]
    if T[i]=='r':
        if f=='p':h[i]=n
        else:ans+=P;h[i]='p'
    if T[i]=='p':
        if f=='s':h[i]=n
        else:ans+=S;h[i]='s'
    if T[i]=='s':
        if f=='r':h[i]=n
        else:ans+=R;h[i]='r'
print(ans)

Measured memory_bytes: 10084
#include<cstdio>
#include<vector>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<vector<int> > e(n);
	for(int t=0;t<m;t++){
		int a,b; scanf("%d%d",&a,&b); a--,b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	int r6=0; vector<int> r4;
	rep(i,0,n-1){
		if(e[i].size()%2!=0){ puts("No"); return 0; }
		if(e[i].size()>=6) r6++;
			else if(e[i].size()==4) r4.push_back(i);
	}
	if(r6>0 || r4.size()>=3) puts("Yes");
	else if(r4.size()<2) puts("No");
		else{
			bool F=0;
			rep(x,0,3){
				int i=e[r4[0]][x],p=r4[0];
				while(e[i].size()==2){ int temp=e[i][0]+e[i][1]-p; p=i; i=temp; }
				if(i==r4[0]) F=1;
			}
			puts(F?"Yes":"No");
		}
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
	string s, ans;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			if (!ans.empty()) {
				ans.pop_back();
			}
		}
		else {
			ans += s[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  long long int sum=0;
  for(int i=0;i<k;i++)sum+=a[i];
  cout<<sum<<endl;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int cnt = 0;
		int sum = 0;
		for (int i = 8 ; i >= 0 ; i--) {
			sum += n / (int)Math.pow(10, i) - cnt * 10;
			cnt = n / (int)Math.pow(10, i);
		}
		System.out.println(n % sum == 0 ? "Yes" : "No");
	}
}


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

int main() {
  int a,b;
  cin >> a >> b;
  int ans=0;
  for(;a<=b;a++){
    if((a/10000==a%10)&&((a/1000)%10==(a/10)%10))ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long mult_mod(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

// ree always check bounds
// int vs long long
// bitset cheese <3

vector<int> adj[100005];
int parent[100005];
long long cur[100005], ans[100005];

void helper(int node){
    for(int i : adj[node]){
        if(cur[i] != 0){
            ans[node] += cur[i];
            if(parent[i] != node && parent[i] != 0)
                ++ans[node];
            continue;
        }
        ++cur[node];
        parent[i] = node;
        helper(i);
    }
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for(int a, b, i = 1; i < n; ++i){
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    helper(1);

    long long prod = 1;

    for(int i = 1; i <= n; ++i)
        prod = prod * max(0LL, k - ans[i]) % MOD;

    cout << prod;

    return 0;
}


Measured memory_bytes: 9856
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#ifdef LOCAL
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#else
#define D(x)
#define R(X, l)
#endif
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
inline int _max(int cnt, ...);
inline int _min(int cnt, ...);
signed main(void)
{
	#ifdef LOCAL
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = next<int>(), ans = 0;
	hrp(i, 1, n) hrp(j, 1, n) hrp(k, 1, n) ans += __gcd(__gcd(i, j), k);
	cout<<ans<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}
inline int _max(int cnt, ...)
{
	int mx = -1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mx = max(mx, va_arg(l, int));
	va_end(l);
	return mx;
}
inline int _min(int cnt, ...)
{
	int mn = 1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mn = min(mn, va_arg(l, int));
	va_end(l);
	return mn;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

const int MAX = 510000;
const int MOD = 998244353;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	ll n,m,k;
	cin>>n;
	cin>>m;
	cin>>k;
	COMinit();
	vector<ll> power(n,1);
	FOR(i,1,n){
		power[i]=power[i-1]*(m-1);
		power[i]%=MOD;
	}
	ll ans=0;
	REP(i,k+1){
		ll tmp=m;
		tmp*=power[n-1-i];
		tmp%=MOD;
		//cout<<"/"<<tmp;
		tmp*=COM(n-1,i);
		tmp%=MOD;
		//cout<<" /"<<tmp<<endl;
		ans+=tmp;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

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

int main() {
	int n;
	scanf("%d", &n);
	vector<int> v;
	int cnt[n];
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		v.push_back(a);
		cnt[i] = 0;
	}
	sort(v.begin(), v.end());
	
	int index = 0;
	for (int i = 0; i < n - 1; i++) {
		if (v[i] == v[i + 1]) {
			cnt[index]++;
		} else {
			cnt[index]++;
			index++;
		}
	}
	cnt[index]++;
	sort(cnt, cnt + index + 1);
	
	int even = 0;
	for (int i = 0; i <= index; i++) {
		if (cnt[i] % 2 == 0) {
			even++;
		}
	}
	
	if (even % 2 == 0) {
		cout << (index + 1) << endl;
	} else {
		cout << index << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1148
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int k = stdIn.nextInt();

        if(n % k == 0)
          System.out.println("0");
        else
          System.out.println("1");
    }
}

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

int main(){
    int n, m; cin >> n >> m;
    int h[n];
    for (int i=0; i<n; i++){
        cin >> h[i];
    }
    set <int> losers;
    for (int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        if (h[a-1]==h[b-1]){
            losers.insert(a);
            losers.insert(b);
        } else if (h[a-1]>h[b-1]){
            losers.insert(b);
        } else {
            losers.insert(a);
        }
        //cout << "LOSER IS " << loser << endl;
    } 
    
    cout << n-losers.size() << endl;
    
    return 0;
}

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

int main(void) {

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k <= a) {
        cout << k << endl;
        return 0;
    }
    else if (k <= a + b) {
        cout << a << endl;
        return 0;
    }
    else {
        ll c2 = k - (a + b);
        cout << a - c2 << endl;
        return 0;
    }

}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = -LINF;
  chmax(ans,a*c);
  chmax(ans,a*d);
  chmax(ans,b*c);
  chmax(ans,b*d);
  cout << ans << endl;
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <math.h>
//Atcoder Begginer 142
int main(void)
{
    long long int A, B;
    int i, j, k;
    i = scanf("%lld", &A);
    j = scanf("%lld", &B);
    if(i < 1 || j < 1){
        printf("scanf Error\n");
    }
    if(A > B){
        long long temp = B;
        B = A;
        A = temp;
    }
    // A < B
    int maxA = sqrt(A);
    int maxB = sqrt(B);
    int primeA[22] = {0}, primeB[22] = {0}, countA = 0, countB = 0;
    for(i = 2; i < maxA || i < maxB; i++){
        while(A % i == 0){
            A /= i;
            if(primeA[countA] != i && primeA[0] != 0){
                countA++;
            }
            primeA[countA] = i;
        }
        while(B % i == 0){
            B /= i;
            if(primeB[countB] != i && primeB[0] != 0){
                countB++;
            }
            primeB[countB] = i;
        }
    }
    if(A != 1)
        primeA[primeA[0] == 0 ? 0 : countA + 1] = A;
    if(B != 1)
        primeB[primeB[0] == 0 ? 0 : countB + 1] = B;
    int result = 1;
    for(i = 0, j = 0; primeA[i] != 0 && primeB[j] != 0;){
        if(primeA[i] == primeB[j])
        {
            result++;
            i++; j++;
        }
        else if(primeA[i] > primeB[j]){
            j++;
        }
        else{
            i++;
        }
    }
    printf("%d\n", result);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  if (a+b >= 10) cout << "error";
  else cout << a+b;
    return 0;
}

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

int main(){
  long long a, b, c, d;
  cin>>a>>b>>c>>d;
  long long e=max(a*c,a*d);
  long long f=max(b*c,b*d);
  long long g=max(e,f);
  cout<<g<<endl;
}

Measured memory_bytes: 3660
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    A, B, C, D, E, F = map(int, input().split())
    W = set()
    for a in range(F // (100 * A) + 1):
        for b in range(F // (100 * B) + 1):
            if 0 < 100 * A * a + 100 * B * b <= F:
                W.add(100 * A * a + 100 * B * b)
    W = sorted(list(W))
    kouho = []
    for w in W:
        max_S = (w // 100) * E
        tmp = 0
        for c in range(0, max_S + 1, C):
            for d in range(0, max_S + 1 - c, D):
                s = c + d
                if s + w <= F:
                    tmp = max(tmp, s)
        kouho.append([w + tmp, tmp])

    ma = 0
    res = [W[0], 0]
    for total, sugar in kouho:
        noudo = (sugar * 100) / total
        if ma < noudo:
            ma = noudo
            res = [total, sugar]

    print(*res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 41452
# coding: utf-8
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces


def getCost(selects, a):
    cost = 0
    pre = a[0]#見える高さ
    for i in range(1,len(a)):
        if i in selects:
            costi = max(0, pre-a[i]+1)
            cost += costi
            if costi > 0:
                pre = pre+1
        pre = max(pre,a[i])
    return cost


def main():
    n,k = na()
    a = na()
    ans = float('inf')
    for i in range(pow(2,n)):
        selects = []
        for j in range(n):
            if ((i>>j) & 1):
                selects += [j]
        if len(selects) != k:
            continue
        ans = min(ans, getCost(selects,a))
    print(ans)
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 43484
a, b = map(int, raw_input().split())
slices = [0 for x in range(16)]
i = 0
while a != 0 and b != 0 and i < 15:
    slices[i] = 0
    slices[i + 1] = 1
    a -= 1
    b -=1
    i += 2

while a > 0 and i < 15:
    slices[i] = 0
    a -= 1
    i += 2
 
while b > 0 and i < 15:
    slices[i] = 1
    b -= 1
    i += 2

print "Yay!" if a == 0 and b == 0 else ":("

Measured memory_bytes: 2568
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
ab = []
ans = 0
for i in range(n):
    _a,_b = map(int,input().split())
    ab.append([_a,_b])
sab = sorted(ab)
for i in range(n):
    num = sab[i][1]
    if num <= m:
        m -= num
        ans += sab[i][0]*sab[i][1]
    else:
        ans += sab[i][0]*m
        m = 0
print(ans)

Measured memory_bytes: 20832
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cmath>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	string st;
	cin >> st;
	ll maxx = 0, cur = 0;
	for(ll i=0; st[i]; i++){
		if(st[i] == 'A' or st[i] == 'G' or st[i] == 'C' or st[i] == 'T')
			cur ++;
		else{
			maxx = max(maxx, cur);
			cur = 0;
		}
	}
	maxx = max(maxx, cur);
	cout << maxx;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
	int A, B, C, a, b, c, count = 0, key = 0;;

	cin >> A >> B >> C;

	while (A % 2 != 1 && B % 2 != 1 && C % 2 != 1) {
		
		if (key != A) {
			key = A;
		}
		else {
			cout << "-1";
			goto End;
		}

		a = A;
		b = B;
		c = C;
		
		A = (b + c) / 2;
		B = (c + a) / 2;
		C = (a + b) / 2;
		count++;
	}

	cout << count;

	End:

	return 0;
}


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

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 20007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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


ll t,i,x,j,y,z,k,n;
cin>>n;
ll p[n+1],a[n+1],b[n+1];
rep(i,1,n+1,1){
	cin>>x;
	p[x]=i;
}

rep(i,1,n+1,1){
	a[i]=i*hell;
	cout<<a[i]<<" ";
}
ce("")

rep(i,1,n+1,1){
	b[i]=(n-i)*hell+p[i];
	cout<<b[i]<<" ";
}

}


Measured memory_bytes: 1152
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;
typedef long double ld;

using namespace std;

/*
//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}
*/
//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}


vector<pair<long long, long long> > factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

void solve(){

	ll n;
	cin>>n;

	const auto &res =factorize(n);
	ll ans=0;
	for(auto p :res){
		ll i=0;
		while(p.second>=0){
			i++;
			p.second-=i;
		}
		ans+=(i-1);
	}

	cout<<ans<<endl;
}


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


Measured memory_bytes: 3632
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define trace(x) cerr << #x << " = " << x << endl
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define sl(a)   scanf("%lld",&a)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define pi acos(-1)
#define en '\n'
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;

template <class T> T power(T a,T b){a%=MOD;if(!a) return 0;T p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
template <class T> void print(vector<T> &v){for(T u:v){cout<<u<<" ";}cout<<endl;}
template <class T> T gcd(T a, T b){return (b!=0?gcd<T>(b,a%b):a);}
template <class T> T lcm(T a, T b){return (a/gcd<T>(a,b)*b);}

int main()
{
    speed();
    ll a,i,x;
    string s;
    cin>>s;
    a=  s.size();
    if(s[a-1]=='s')
        cout<<s<<"es"<<endl;
    else
        cout<<s<<"s"<<endl;




return 0;
}


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

struct node{
    int num;
    struct node *next,*prev;
};

typedef struct node * NodePointer;
NodePointer head;

void init();/*番兵ノード作成*/
NodePointer listSearch(int);/*一致するデータがあるか検索*/
void printList();/*連結リストに含まれるデータの出力*/
void deleteNode(NodePointer);/*ノードを削除*/
void deleteKey(int);/*与えられた値をリスト削除*/
void deleteFirst();/*リストの最初にある値を削除*/
void deleteLast();/*リストの最後にある値を削除*/
void insert(int);/*データを挿入*/
       
int main(){
    int n,key;
    char order[20];
    char ins[] = "insert";
    char del[] = "delete";
    char delF[] = "deleteFirst";
    char delL[] = "deleteLast";

    init();
    scanf("%d",&n);

    for(int i=0; i<n; i++){
        scanf("%s",order);
        if(strcmp(del,order) == 0 || strcmp(ins,order) == 0)scanf("%d",&key);

        if(strcmp(ins,order) == 0){
            insert(key);
        }
        else if(strcmp(del,order) == 0){
            deleteKey(key);
        }
        else if(strcmp(delF,order) == 0){
            deleteFirst();
        }
        else if(strcmp(delL,order) == 0){
            deleteLast();
        }
    }

    printList();

    return 0;
}


void init(){
    head = (NodePointer)malloc(sizeof(struct node));
    head->next = head;
    head->prev = head;
}

NodePointer listSearch(int key){
    NodePointer check;
    for(check = head->next; check != head; check = check->next){
        if(check->num == key) return check;
    }

    return NULL;
}

void printList(){
    NodePointer now = head->next;
    int dif=0;
    while(1){
        if(now == head) break;
        if(dif != 0) printf(" ");
        printf("%d",now->num);
        now = now->next;
        dif = 1; 
    }

    printf("\n");
}

void deleteNode(NodePointer key){
    if(key == head ) return;
    key->prev->next = key->next;
    key->next->prev = key->prev;
    free(key);
}

void deleteKey(int key){
    NodePointer v;
    v = listSearch(key);
    if(v == NULL) return;
    deleteNode(v);
}

void deleteFirst(){
    deleteNode(head->next);
}

void deleteLast(){
    deleteNode(head->prev);
}

void insert(int key){
    NodePointer x;
    x = (NodePointer )malloc(sizeof(struct node));
    x->num = key;

    x->next = head->next;
    head->next->prev = x;
    head->next = x;
    x->prev = head;
}



Measured memory_bytes: 32936
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n, W;
  cin >> n >> W;
  vector <ll> w(n + 1);
  vector <ll> v(n + 1);
  REP1(i, n) {
	cin >> w[i] >> v[i];
  }
  int V = n * 1000;
  vector <vector <ll> > dp(n + 1, vector <ll>(V + 1, 1e15));
  REP(i, n + 1) {
	dp[i][0] = 0;
  }
  REP1(i, n) {
	REP1(j, V) {
	  dp[i][j] = dp[i - 1][j];
	  if (j - v[i] >= 0) {
		  dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
		}
	}
  }
  int ans = 0;
  REP1(i, V) {
	if (dp[n][i] <= W) {
		ans = i;
	  }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 80256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main
{
    public static void main(String[] args)
    {
        List<Integer> allNum = new ArrayList<>();
        List<Integer> counts = new ArrayList<>();
        List<Integer> modeFound = new ArrayList<>();
        final int MAX = 100;
        int curNum = 0, maxRep = 0;
        boolean flag = false;
        
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()) {
            allNum.add(scan.nextInt());
            curNum ++;
            if (curNum >= MAX) {
                break;
            }
        }
        
        for (int i=0; i<allNum.size(); i++) {
            flag = false;
            for (int j=0; j<counts.size(); j+=2) {
                if (allNum.get(i) == counts.get(j)) {
                    counts.set(j+1,counts.get(j+1)+1);
                    flag = true;
                }
            }
            if (!flag) {
                counts.add(allNum.get(i));
                counts.add(1);
            }
        }
        
        for (int i=0; i<counts.size(); i+=2) {
            if (counts.get(i+1) > maxRep)
                maxRep = counts.get(i+1);
        }
        
        for (int i=0; i<counts.size(); i+=2) {
            if (counts.get(i+1) == maxRep) {
                flag = false;
                for (int j=0; j<modeFound.size(); j++) {
                    if (modeFound.get(j) > counts.get(i)) {
                        modeFound.add(j,counts.get(i));
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                    modeFound.add(counts.get(i));
            }
        }
        
        for (int i=0; i<modeFound.size(); i++) {
            System.out.println(modeFound.get(i) + "");
        }
    }
}

Measured memory_bytes: 26412
#include <iostream>

using namespace std;

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

    int max_num = 1;
    int max_count = 0;
    for (int i = 1; i <= N; i++){
        int counter = 0;
        int num = i;
        while (true){
            if (num % 2 == 1) break;
            num /= 2;
            counter++;
        }
        if (counter > max_count){
            max_num = i;
            max_count = counter;
        }
    }
    cout << max_num << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		if(S.equals("Sunny")) {
			System.out.println("Cloudy");
		} else if(S.equals("Cloudy")) {
			System.out.println("Rainy");
		} else {
			System.out.println("Sunny");
		}
		
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;

ll bit[200010];
//ll kai[3010];
ll Cnt[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }



/*ll sum(ll i)
{
	//i += 1;
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	//i += 1;
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/



void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

void makePrimeList(ll x) {
	ll X = x;
	for (ll j = 2; j * j <= x; j++) {
		ll cnt = 0;
		while (X % j == 0) {
			cnt++;
			X /= j;
		}
		if (cnt) {
			Cnt[j] = max(Cnt[j], cnt);
		}
	}
	if (X != 1) Cnt[X] = max(Cnt[X], 1LL);
}

ll N;

void solve() {
	cin >> N;
	rep(i, 9) {
		rep(j, 9) {
			if (N == (i + 1) * (j + 1)) {
				cout << "Yes" << endl;
				return;
			}
		}
	}
	cout << "No" << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

Measured memory_bytes: 256
#include<cstring>
#include <cstdio> 
#include <iostream>
#include <cmath>
using namespace std;
#define pi 3.1415926 
#define N 510
int main()
{
	char a;
	cin>>a;
	if(a>='a'&&a<='z')
	{
		printf("a");
	}
	else if(a<='Z'&&a>='A')
	{
		printf("A");
	}
	return 0;
}



Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
#include <time.h>

int main(void){
    long N;
    std::cin >> N;
    std::vector<long> A;
    bool dp[1000000+1]={};
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        A.push_back(temp);
    }
    std::sort(A.begin(),A.end());

    for(long i=0; i<N; i++){
        for(long j=2*A[i]; j<=A[N-1]; j+=A[i]){
            dp[j]=1;
        }
    }

    long count=0;
    for(long i=0; i<N; i++){ 
        if(dp[A[i]]==0){
            count++;
        }
    }

    bool flag=0;
    long run=1;
    for(long i=1; i<N; i++){
        if(A[i]==A[i-1]){
            flag=1;
            run++;
        }
        if(flag && A[i]!=A[i-1]){
            if(dp[A[i-1]]==0){
                count-=run;
            }
            flag=0;
            run=1;
        }
        if(run>1 && i==N-1){
            if(dp[A[N-1]]==0){
                count-=run;
            }
        }
    }

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

Measured memory_bytes: 6344
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
int main() {
	int h, w;
	long long n;
	while (cin >> h >> w >> n, h){
		vector<string> vs;
		vector<vector<vector<int>>> vvvi(h,vector<vector<int>>(w,vector<int>(4,-1)));
		int x, y, d;
		REP(i, h){
			string s;
			cin >> s;
			vs.push_back(s);
			REP(j, w){
				if (s[j] == 'N' || s[j] == 'E' || s[j] == 'W' || s[j] == 'S'){
					x = j;
					y = i;
					if (s[j] == 'W')d=0;
					if (s[j] == 'S')d = 1;
					if (s[j] == 'E')d = 2;
					if (s[j] == 'N')d = 3;
				}
			}
		}
		vvvi[y][x][d]=0;

		for(long long i=0;i<n;i++){
			while (x + dx[d] < 0 || x + dx[d] >= w || y + dy[d] < 0 || y + dy[d] >= h || vs[y + dy[d]][x + dx[d]] == '#'){
			d+=3;
			d%=4;
			}
			x += dx[d];
			y += dy[d];
			if (vvvi[y][x][d]==-1)
			vvvi[y][x][d] = i + 1;
			else
				n=i+1+((n - i - 1) % (i+1-vvvi[y][x][d]));
		}
		char c;
		if (d == 0)c = 'W';
		if (d == 1)c = 'S';
		if (d == 2)c = 'E';
		if (d == 3)c = 'N';
		cout << (y + 1) << " " << (x + 1) << " "<<c<<endl;
	}
}

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

int main() {
	int N;
	cin >> N;
	pair<long long, long long> ab[N];
	for(int i=0; i<N; i++){
		cin>>ab[i].first>>ab[i].second;
	}
	
	sort(ab,ab+N);
	
	cout<<ab[N-1].first+ab[N-1].second<<endl;
	return 0;
}

Measured memory_bytes: 1792
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
for i in range(n):
    if A[i]<=B[i]:
        ans+=A[i]
        B[i]-=A[i]
        A[i]=0
        if A[i+1]<=B[i]:
            ans+=A[i+1]
            B[i]-=A[i+1]
            A[i+1]=0
        else:
            ans+=B[i]
            A[i+1]-=B[i]
            B[i]=0
    else:
        ans+=B[i]
        A[i]-=B[i]
        B[i]=0
print(ans)

Measured memory_bytes: 18476
#include <iostream>     // std::cout
#include <algorithm>    // std::make_heap, std::pop_heap, std::push_heap, std::sort_heap
#include <vector>       // std::vector
#include <climits> 
//#include <stdio.h>

using namespace std;

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int N, x, k;
  cin >> N >> k;
  
  vector<int> jumpHeights;
  vector<int> jumpCost(N, 0);
  
  for(int i = 0; i < N; i++) {
	  cin >> x;
	  jumpHeights.push_back(x);
  }

  
  
  for(int i = 1; i<N;i++) {
	  int minCost = INT_MAX;
	  for(int j = 1; j <= k; j++) {
		if(i - j >= 0) {
			minCost = min(minCost, abs(jumpHeights[i] - jumpHeights[i -j]) + jumpCost[i-j]);
		}
		jumpCost[i] = minCost;
			
	  }
  }
  cout << jumpCost[N - 1] << "\n";
  

  return 0;
}





Measured memory_bytes: 1276
#include <iostream>
#include <string>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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


	string to;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == ',') {
			s[i] = ' ';
		}
	}

	cout << s << endl;

}

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

using namespace std;


int main(){
    vector<int> v;
    int a;
    for(int i=0;i<3;++i){
        cin >> a;
        v.emplace_back(a);
    }
    sort(v.begin(), v.end());
    for(auto i=0;i<v.size();++i){
        if (i!=0)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int count = 0;
    while (A >= B)
    {
        B *= 2;
        count++;
    }
    while (B >= C)
    {
        C *= 2;
        count++;
    }
    if (count <= K)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ll;
typedef pair<ll, ll> P;

int main(){
	int n,a,b,c,d;
	cin >> n >> a >> b >> c >> d;
	string s;
	cin >> s;
	int rock = 0;
	int possible = 1;
	int res;
	if(c<d){
		for(int i=b;i<d;i++){
			if(s[i]=='#'){
				if(rock==1){
					possible = 0;
				}
				rock = 1;
			}else{
				rock = 0;
			}
		}
		res = possible;
		possible = 1;
		rock = 0;
		for(int i=a;i<c;i++){
			if(s[i]=='#'){
				if(rock==1){
					possible = 0;
				}
				rock = 1;
			}else{
				rock = 0;
			}
		}
		res *= possible;
	}else{
		int none = 0;
		int beyond = 0;
		for(int i=b-2;i<d+1;i++){
			if(s[i]=='#'){
				none = 0;
				if(rock==1){
					possible = 0;
				}
				rock = 1;
			}else if(s[i]=='.'){
				none++;
				if(none==3) beyond =1;
				rock = 0;
			}
		}
		res = possible;
		possible = 1;
		rock = 0;
		for(int i=a;i<c;i++){
			if(s[i]=='#'){
				if(rock==1){
					possible = 0;
				}
				rock = 1;
			}else{
				rock = 0;
			}
		}
		res *= possible;
		res *= beyond;
	}
	if(res){
		cout << "Yes" << endl;
	}else{
		cout << "No"<< endl;
	}
}

Measured memory_bytes: 640
// atcoder/abc079/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  lli dp[100];
  dp[0] = 2;
  dp[1] = 1;
  for (int i = 2; i < 100; ++i) {
    dp[i] = dp[i - 1] + dp[i - 2];
  }

  int n;
  while (cin >> n) cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 384
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  var inputNum = Number(input[0]);
  var tmpAll = [];
  for(var i=1; i <= inputNum; i++){
    var tmp = input[i].split(" ");
    tmpAll.push(tmp);
  }
  var array = tmpAll;

  // ソート
  array.sort(function(a, b){
    return a[1]- b[1];
  });

  var result = 'Yes';
  var sumA = 0;

  for(var j=0; j < inputNum; j++){
    sumA = sumA + Number(array[j][0]);
    if(sumA > Number(array[j][1])){
      result = 'No';
      break;
    }
  }
  console.log(result);
 }
 //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    ll X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    vector<P> a(A+B+C);
    rep(i, A){
        cin >> a.at(i).first;
        a.at(i).second = 1;
    }
    rep(i, B){
        cin >> a.at(i+A).first;
        a.at(i+A).second = 2;
    }
    rep(i, C){
        cin >> a.at(i+A+B).first;
        a.at(i+A+B).second = 3;
    }

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

    ll cnt1 = 0ll;
    ll cnt2 = 0ll;
    ll cnt3 = 0ll;
    ll ans = 0ll;
    int i = 0;
    while((X+Y-cnt1-cnt2)>cnt3){
        if(a.at(i).second == 1 && cnt1 < X){
            ans += a.at(i).first;
            cnt1++;
        }
        if(a.at(i).second == 2 && cnt2 < Y){
            ans += a.at(i).first;
            cnt2++;
        }
        if(a.at(i).second == 3){
            ans += a.at(i).first;
            cnt3++;
        }
        i++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#define N 32768
long a[N],b[N],c[N]={},n,k,i=N;
int main(){
for(std::cin>>n>>k;--i;a[i]=i<n?i:n)b[i]=n/i;while(--k){for(;++i<N;)c[i]=c[i-1]+b[i];for(*a=c[n/--i];--i;a[i]=c[i])*a=b[i]=(*a+a[i]*(n/i-n/(i+1)))%0x3B9ACA07;}std::cout<<*a;}

Measured memory_bytes: 1024