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

using namespace std;

void solve()
{
	int m, n;
	while(cin >> m >> n)
	{
		if(!m && !n)
		{
			break;
		}
		vector<int> Vec(m);
		for(int i = 0; i < m; ++i)
		{
			cin >> Vec[i];
		}
		int sum = 0;
		for(int i = 0; i < n; ++i)
		{
			sum += Vec[i];
		}
		int max = sum;
		for(int i = 1; i < m - n + 1; ++i)
		{
			sum += Vec[i + n - 1] - Vec[i - 1];
			if(sum > max)
			{
				max = sum;
			}
		}
		cout << max << endl;
	}
}

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

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll N, K;
ll dp[100][100][5000];
ll x[100];

int main() {
   cin >> N >> K;
   rep (i, N) {
      cin >> x[i];
   }

   dp[0][0][0] = 1;
   rep (i, N) {
      rep (j, N) {
         rep (k, 5000) {
            if (dp[i][j][k] == 0) continue;
            dp[i+1][j+1][k+x[i]] += dp[i][j][k];
            dp[i+1][j][k] += dp[i][j][k];
         }
      }
   }
   ll sum = 0;
   for (int i = 1; i <= N; i++) sum += dp[N][i][K*i];
   cout << sum << endl;

   return 0;
}

Measured memory_bytes: 151808
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long x = sc.NextLong();

        long answer = 0;
        long now = 100;
        while (true)
        {
            answer++;
            now += now / 100;
            if (now >= x)
            {
                break;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27536
#include<iostream>
#include<math.h>
using namespace std;
int main(void){
	long ans=0;
	long long n=0,i,N,P;
	cin>>N>>P;
	if(N==1){
		cout<<P<<endl;
		return 0;
	}
	for(i=1;n<P&&n>=0;i++){
		n=powl(i,N);
//		cout<<n<<" "<<i<<" "<<P<<" "<<ans<<endl;
		if(P%n==0)ans=i;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#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 IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define mem1(x)  memset(x,1,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
int32_t main(){
    IOS;
    ll l,r,d,i,j,cnt=0;
    cin >> l >>r >> d;
    for(i=l;i<=r;i++){
        if(i%d==0) cnt++;
    }
    cout << cnt <<"\n";
} 

Measured memory_bytes: 3660
n, k = map(int, input().split())
l = list(map(int, input().split()))

use_d = []
for i in range(10):
  if i not in l:
    use_d.append(i)

use_d.sort()

m = str(n)

ds = []

import itertools
for i in itertools.product(use_d, repeat=len(m)):
  d = int("".join(str(x) for x in i))
  ds.append(d)
ds.sort()

import bisect
x = bisect.bisect_left(ds, n)
if x != len(ds):
  ans = ds[x]
else:
  ans = ''
  for i in range(len(m)+1):
    if i == 0:
      if use_d[0] == 0:
        ans += str(use_d[1])
      else:
        ans += str(use_d[0])
    else:
      ans += str(use_d[0])
  ans  = int(ans)
print(ans)  


Measured memory_bytes: 41072
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
const int nax = 2e5 + 5;
int food[nax];
int people[nax];
int n,k; 
bool check(int mid)
{
    int cnt = 0;
    for(int i=0;i<n;i++)
    {
        if(people[i]*food[i] <= mid) continue;
        int res=  people[i]*food[i] - mid;
        int lol = res/food[i] + !(res%food[i] == 0);
        cnt += lol;
    }
    if(cnt <= k) return 1;
    return 0;
}
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>people[i];
    for(int i=0;i<n;i++) cin>>food[i];
    sort(people,people+n,greater<int>());
    sort(food,food+n);
    int st = 0, en =  1e12 + 3;
    int ans;
    while(st <= en)
    {
        int mid = st + (en-st)/2;
        if(check(mid) == 1)
        {
            ans = mid;
            en = mid-1;
        }
        else st = mid+1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, M;
int S, T;
vector<pair<int,pair<ll,ll>>> e[100000];
priority_queue<pair<ll, int>> pq;
ll costS[100000], costT[100000];

signed main(){
    cin >> N >> M >> S >> T;
    S--; T--;
    rep(i, M){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        e[a].pb({ b,{c,d} });
        e[b].pb({ a,{c,d} });
    }
    
    rep(i, N) costS[i] = LLONG_MAX;
    costS[S] = 0;
    pq.push({ 0,S });
    while(!pq.empty()){
        int n = pq.top().second;
        pq.pop();
        rep(i, e[n].size()){
            if(costS[e[n][i].first] > costS[n] + e[n][i].second.first){
                costS[e[n][i].first] = costS[n] + e[n][i].second.first;
                pq.push({ -costS[e[n][i].first] ,e[n][i].first });
            }
        }
    }

    rep(i, N) costT[i] = LLONG_MAX;
    costT[T] = 0;
    pq.push({ 0,T });
    while(!pq.empty()){
        int n = pq.top().second;
        pq.pop();
        rep(i, e[n].size()){
            if(costT[e[n][i].first] > costT[n] + e[n][i].second.second){
                costT[e[n][i].first] = costT[n] + e[n][i].second.second;
                pq.push({ -costT[e[n][i].first] ,e[n][i].first });
            }
        }
    }

    const ll DEF = 1e15L;
    vector<ll> ans;
    ans.pb(DEF-costS[N-1]-costT[N-1]);
    for(int i=N-2; i>=0; i--){
        ans.pb(max(ans.back(), DEF-costS[i]-costT[i]));
    }
    reverse(all(ans));
    rep(i, N) cout << ans[i] << endl;
}

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

const int MAXN = 2002;

struct Sum {
	int s[MAXN][MAXN];

	Sum() {
		memset(s, 0, sizeof(s));
	}

	void Upd(int i, int j, int k) {
		s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + k;
	}

	int Get(int xl, int yl, int xr, int yr) {
		return (s[xr][yr] + s[xl][yl] - s[xr][yl] - s[xl][yr]);
	}
};

Sum s1, s2, s3;
string s[MAXN];

int main() {
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			s1.Upd(i, j, s[i - 1][j - 1] == '1');
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < m; j++) {
			s2.Upd(i, j, (s[i - 1][j] == '1') && (s[i - 1][j - 1] == '1'));
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= m; j++) {
			s3.Upd(i, j, (s[i][j - 1] == '1') && (s[i - 1][j - 1] == '1'));
		}
	}
	for (int i = 0; i < k; i++) {
		int xl, yl, xr, yr;
		cin >> xl >> yl >> xr >> yr;
		int ss1 = s1.Get(xl - 1, yl - 1, xr, yr);
		int ss2 = s2.Get(xl - 1, yl, xr, yr);
		int ss3 = s3.Get(xl, yl - 1, xr, yr);
		cout << s1.Get(xl - 1, yl - 1, xr, yr) - s2.Get(xl - 1, yl - 1, xr, yr - 1) - s3.Get(xl - 1, yl - 1, xr - 1, yr) << "\n";
	}
	return 0;
}

Measured memory_bytes: 53120
#include <stdio.h>
int main() {
	int x[5];
	for (int i = 0; i < 5; i++) {
		scanf("%d", &x[i]);
	}
	for (int i = 0; i < 5; i++) {
		if (x[i] == 0) {
			printf("%d\n", i + 1);
		}
	}
	return 0;
}

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

int main() {
  int n, m, x, r = 0, l = 0;
  cin >> n >> m >> x;
  rep(i, m){
    int tmp;
    cin >> tmp;
    if(tmp < x) ++l;
    else ++r;
  }
  cout << min(r, l) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define ld long double
#define mod 1000000007ll
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define Debug(x) cout << x << "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
//int main() {
//    ll n;
//    cin >> n;
//    ll ct = 0;
//    while(n) {
//        n /= 26;
//        ++ct;
//        if(n < 26)
//            break;
//    }
//    string ans = "";
//    for(int i = 0; i < ct; ++i)
//        ans += 'a';
//    ans += char(n - 1 + 97);
//    cout << ans;
//}
int main() {
    ll n, q, num;
    cin >> n;
    map<ll, ll> np;
    ll sum = 0;
    for(int i = 0; i < n; ++i) {
        cin >> num;
        ++np[num];
        sum += num;
    }
    ll a, b;
    tc {
        cin >> a >> b;
        ll ct = np[a];
        np[b] += ct;
        np[a] = 0;
        ll nw = sum - a*ct + b*ct;
        sum = nw;
        cout << nw << "\n";
    }
}


Measured memory_bytes: 9348
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int N=S.size();
  for(int i=0;i<N;i++){
    if(S.at(i)==','){
      cout<<" ";
    }
    else{
      cout<<S.at(i);
    }
  }
}


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

int main() {
    int d[110];
    int N;

    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> d[i];
    }
    sort(d, d+N);
    reverse(d, d+N);

    int count = 0;
    for(int i = 0; i < N; i++) {
        if(d[i] != d[i+1]) {
            count++;
        }
    }
    cout << count << endl;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    vector<ll> luca(N+2);
    luca[0] = 2;
    luca[1] = 1;
    for (int i=2;i<=N;i++) {
        luca[i] = luca[i-1] + luca[i-2];
    }
    cout<<luca[N]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int X;
    cin >> X;
    int ans = 1;
    for (int i = 2; i * i <= X; ++i) {
        int j = i * i;
        while (j <= X) {
            ans = max(ans, j);
            j *= i;
        }
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll n;
   ll a;
   cin>>a>>n;
   ll arr[n];
   ll i;vector <ll> v;
   for(i=0;i<n;i++)
   cin>>arr[i];
   for(i=0;i<n-1;i++)
   {
       v.push_back(arr[i+1]-arr[i]);
       
   }
   v.push_back(a-arr[n-1]+arr[0]);
   sort(v.begin(),v.end());
   
   cout<<a-v[n-1]<<endl;
   return 0;
   
}

Measured memory_bytes: 3956
def resolve():
    '''
    code here
    '''
    W, H, N = [int(item) for item in input().split()]
    query = [[int(item) for item in input().split()] for _ in range(N)]

    x_low = 0
    x_high = W
    y_low = 0
    y_high = H

    for x, y, a in query:
        if a == 1:
            x_low = max(x_low, x)
        elif a == 2:
            x_high = min(x_high, x)
        elif a == 3:
            y_low = max(y_low, y)
        else:
            y_high = min(y_high, y)

        # print(x,y,a)
        # print(x_low, x_high, y_low, y_high)
        # print('-----------')
    
    # print('##############')
    # print(x,y,a)
    # print(x_low, x_high, y_low, y_high)
    # print('-----------')

    x_delta = x_high - x_low
    y_delta = y_high - y_low

    if x_delta >= 0 and y_delta >= 0:
        print(x_delta*y_delta)
    else:
        print(0)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
    char a[101], b[101];
    scanf("%s %s", a, b);

    int len_a = strlen(a);
    int len_b = strlen(b);
    if (len_a > len_b) {
        goto g;
    } else if (len_a < len_b) {
        goto l;
    } else {
        for (int i = 0; i < len_a; ++i) {
            if (a[i] > b[i]) {
                goto g;
            } else if (a[i] < b[i]) {
                goto l;
            }
        }
        goto e;
    }
g:
    puts("GREATER");
    return 0;
l:
    puts("LESS");
    return 0;
e:
    puts("EQUAL");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;

int main()
{
    int p,q,r;
    cin>>p>>q>>r;
    cout<<p+q+r-max(p,max(q,r))<<endl;
}


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

using namespace std;
 
#define IOS		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld 		    long double
#define ll 		    long long int
#define ull 	   	    unsigned long long int
#define pb		    push_back
#define mp		    make_pair
#define F		    first
#define S		    second
#define lb		    lower_bound
#define ub		    upper_bound
#define deb(x)      	    cout<<"#x "<<x<<"\n";
#define trace(x,y)  	    cout<<"#x "<<x<<" #y "<<y<<"\n";
#define cn          	    cout<<"\n";


bool SBF(const pair <int,int>& a, const pair<int,int>& b){return a.F<b.F;}
bool SBS(const pair <int,int>& a, const pair<int,int>& b){return a.S<b.S;}


const long double PI  = 3.1415926535;
const long long   mod = 1e9+ 7; 
const int 	  mxN = 1000;
const long long   INF = 1e9;









int n , a, b;


void solve(){
    
       string s;
       cin >> s;
       n = s.length();       

       int l = 0, r =n-1;
       for(int i=0;i<n;i++){
	       if(s[i] == 'A'){
		       l = i;
		       break;
	       }
       }
       for(int i =n-1;i>=0;i--){
	       if(s[i] =='Z'){
		       r = i;
		       break;
	       }
       }
       cout<<r-l+1<<"\n";
}


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


Measured memory_bytes: 640
#include <stdio.h>

int main() {
  long N,H,W,A,B,i,c=0;
  
  scanf("%ld %ld %ld",&N,&H,&W);
  
  for(i=0;i<N;i++) {
    scanf("%ld %ld",&A,&B);
    if(A>=H && B>=W) c++;
  }
  
  printf("%ld\n",c);
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1172&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int n;
const ll MAX_PRIME = 300000;
vector<int> primes;
vector<int> is_prime(MAX_PRIME + 1,true);
void init_primes(){
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= MAX_PRIME;i++){
        if(is_prime[i]){
            primes.push_back(i);
            for(int j = i*2; j <= MAX_PRIME; j+=i) is_prime[j] = false;
        }
    }
}
ll solve(){
    return upper_bound(primes.begin(),primes.end(),2*n) - upper_bound(primes.begin(), primes.end(), n);
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    init_primes();
    while(cin>>n,n){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 4260
#include <cstdio>
#include <algorithm>
using namespace std;

#define M 1000000

int odd[M + 10], all[M + 10];

void update(int *ar, int x){
	for(int i = x; i <= M; ++i){
		ar[i] = min(ar[i], ar[i - x] + 1);
	}
}

int main(){
	for(int i = 1; i <= M; ++i){
		odd[i] = all[i] = 10000000;
	}

	for(int i = 1; ; ++i){
		int x = i * (i + 1) * (i + 2) / 6;
		if(x > M){ break; }
		update(all, x);
		if(x & 1){ update(odd, x); }
	}
	
	int n;
	while(scanf("%d", &n), n){
		printf("%d %d\n", all[n], odd[n]);
	}
}

Measured memory_bytes: 8840
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n;
vi in,to;
ll vtol(vi a){
	ll t=0;
	rep(i,a.size()){
		t*=10;
		t+=a[i];
	}
	return t;
}
map<ll,int>tmp;
void f(vi a,int c){
	if(c==(n-1)/2)return;
	rep(i,n-1)loop(j,i+1,n){
		vi t=a;
		loop(k,i,j+1)if(k<j-k+i)
			swap(t[k],t[j-k+i]);
		ll s=vtol(t);
		if(tmp.count(s))tmp[s]=min(tmp[s],c+1);
		else tmp[s]=c+1;
		f(t,c+1);
	}
}
int main(){
	cin>>n;
	in=vi(n);
	rep(i,n)cin>>in[i];
	to=vi(n);
	rep(i,n)to[i]=i,in[i]--;
	tmp[vtol(to)]=0;
	f(to,0);
	map<ll,int>A=tmp;
	tmp.clear();
	tmp[vtol(in)]=0;
	f(in,0);
	map<ll,int>B=tmp;
	int out=n-1;
	for(auto it:A)if(B.count(it.first)){
		out=min(out,A[it.first]+B[it.first]);
	}
	cout<<out<<endl;
}
















Measured memory_bytes: 50872
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>

using namespace std;

const double PI = 3.14159265358979;

struct Node {
	int parent = -1;
	int left = -1, right = -1;

};

Node* tree;
int* pre;
int* mid;
int pos;
int n;
int first = 1;

void postorder(int root) {

	if (root != -1) {
		postorder(tree[root].left);
		postorder(tree[root].right);
		if (first) {
			printf("%d", root);
			first = 0;
		}
		else printf(" %d", root);

	}
}

int find_root(int key) {
	for (int i = 0; i < n; i++)	{
		if (mid[i] == key) 
			return i;
	}
}


int reconstruct(int left, int right) {

	if (right - left == 1) 
		return pre[pos++];
	else if (left + 1 < right) {
		int root = pre[pos++];
		int xxx = find_root(root);
		tree[root].left = reconstruct(left, xxx);
		tree[root].right = reconstruct(xxx + 1, right);
		return root;
	}
	else {
		return -1;
	}
}

int main() {

	cin >> n; 

	tree = new Node[n + 1];

	pre = new int[n];
	mid = new int[n];

	for (int i = 0; i < n; i++)	{
		scanf("%d", &pre[i]);
	}

	for (int i = 0; i < n; i++)	{
		scanf("%d", &mid[i]);
	}
	pos = 0;

	reconstruct(0, n);
	postorder(pre[0]);
	printf("\n");

	return 0;
}



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

int main() {
  string word[4] = {"dream", "dreamer","erase", "eraser"};
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  rep(i,4){
    reverse(word[i].begin(),word[i].end());
  }
  
  bool ok = true;
  for (int i = 0; i < s.size();){
    bool ok2 = false;
    rep(j,4){
      string d = word[j];
      if (d == s.substr(i,d.size())){
        ok2 = true;
        i += d.size();
      }
    }
    if (!ok2){
      ok = false;
      break;
    }
  }
  if (ok){
    cout <<"YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;

  vector<int> par(100010);
  vector<int> treerank(100010);
  vector<long> conc(100010);
  
  void init(int n){
    rep(i, n) par[i] = i, treerank[i] = 0, conc[i] = 1;
  }
  
  int find(int x){
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  
  void unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return;
    if(treerank[x] < treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) treerank[x]++;
    par[y] = x;
    conc[x] += conc[y];
    return;
  }
  
  bool same(int x, int y){
    return find(x) == find(y);
  }
  
  long getconc(int x){
    return conc[find(x)];
  }


int main(){
  long n; int m; cin >> n >> m;
  int a[m], b[m]; rep(i, m) cin >> a[m-1-i] >> b[m-1-i];
  long inco[m];
  inco[0] = n * (n-1) / 2;
  init(n);
  For(i, 1, m){
    if(same(a[i-1], b[i-1])) inco[i] = inco[i-1];
    else inco[i] = inco[i-1] - getconc(a[i-1]) * getconc(b[i-1]);
    unite(a[i-1], b[i-1]);
  }
  rep(i, m) cout << inco[m-1-i] << endl;
}

Measured memory_bytes: 4480
x,y = map(int,input().split())
max_kame = int(y/4)
for kame in range(max_kame,-1,-1):
  turu = x - kame
  sum_leg = 2 * turu + 4 * kame
  if sum_leg == y:
    print('Yes')
    break
  if kame == 0:
    print('No')
    break

Measured memory_bytes: 9172
S = input()

if 1 <= int(S[:2]) <= 12:
  if 1 <= int(S[2:]) <= 12:
    ans = 'AMBIGUOUS'
  else:
    ans = 'MMYY'
else:
  if 1 <= int(S[2:]) <= 12:
    ans = 'YYMM'
  else:
    ans = 'NA'

print(ans)

Measured memory_bytes: 2940
N, M = map(int, input().split())

for i in range(M):
    l, r = map(int, input().split())
    
    if i==0:
        left = l
        right = r

    else:
        if l>left:
            left = l
        if r<right:
            right = r

print(0) if left>right else print(right-left+1)

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

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	char c[310][310];
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> c[i][j];
	int ans[310][310];
	vector<int> a(h);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (c[i][j] == '#') {
				a[i]++;
			}
		}
	}
	vector<int> check(h);
	int now = 1;
	for (int i = 0; i < h; i++) {
		bool flag = false;
		for (int j = 0; j < w; j++) {
			if (a[i] != 0) {
				if (c[i][j] == '#') {
					if (flag) {
						now++;
					}
					flag = true;
				}
				ans[i][j] = now;
				check[i] = 1;
			}
		}
		if (check[i]) now++;
	}
	for (int i = 0; i < h; i++) {
		if (!check[i]) {
			for (int x = i - 1; x >= 0; x--) {
				if (check[x]) {
					for (int j = 0; j < w; j++) {
						ans[i][j] = ans[x][j];
					}
					break;
					check[i] = 1;
				}
			}
		}
		if (!check[i]) {
			for (int x = i + 1; x < h; x++) {
				if (check[x]) {
					for (int j = 0; j < w; j++) {
						ans[i][j] = ans[x][j];
					}
					break;
					check[i] = 1;
				}
			}
		}
	}
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++) {
			cout << ans[i][j] << ' ';
		}
		cout << endl;
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;

template <class T> using Vec = vector<T>;

/* 定数 */
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    string S;
    u64 K;
    cin >> S >> K;
    u32 one = 0;
    u32 i;
    for (i = 0; i < S.size(); i++) {
        if(S[i] == '1') one++;
        else break;
    }
    if (one >= K) cout << 1 << endl;
    else cout << S[i] << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_N 210000

int par[MAX_N];
int rnk[MAX_N];

// 初期化
void init(){
	for(int i = 0; i < MAX_N; i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

// x の親を返す
int find(int x){
	if(par[x] == x){
		return x;
	}
	return par[x] = find(par[x]);
}

// x と y を併合する
void unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return;
	}
	
	if(rnk[x_par] < rnk[y_par]){
		par[x_par] = y_par;
	}else{
		par[y_par] = x_par;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
}

// x, y が同じグループか判定
bool same(int x, int y){
	return (find(x) == find(y));
}

int main(){
	
	int N;
	cin >> N;
	
	init();
	
	int Q = 110000 - 1;
	vector<P> v;
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		v.push_back(P(num, i));
		for(int j = 2; j * j <= num; j++){
			while(num % j == 0){
				num /= j;
				unite(i, j + Q);
			}
		}
		if(num > 1){
			unite(i, num + Q);
		}
	}
	
	sort(v.begin(), v.end());
	
	bool flag = true;
	for(int i = 0; i < N; i++){
		if(!same(v[i].second, i)){
			flag = false;
		}
	}
	
	cout << flag << endl;
	
	return 0;
}



Measured memory_bytes: 6564
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	string s;
	cin>>s;
	for(int i=0;i<5;i++)cout<<s[i];
	cout<<' ';
	for(int i=6;i<13;i++) cout<<s[i];
	cout<<' ';
	for(int i=14;i<19;i++)cout<<s[i];
	cout<<endl;
	return 0;
}

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

const int N = 1e5 + 10;
int p[N];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> p[i];
    vector<int> v;
    for (int i = 0; i < n; i++)
        if (p[i] == i + 1)
            v.push_back(i);
    int cnt = (v.size()? 1: 0), ans = 0;
    for (int i = 1; i < v.size(); i++) {
        if (v[i] == v[i - 1] + 1)
            cnt++;
        else {
            ans += (cnt + 1) / 2;
            cnt = 1;
        }
    }
    if (cnt)
        ans += (cnt + 1) / 2;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1276
//
// Created by kuroneko on 2019-09-01.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
    int a, b; cin >> a >> b;
    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }
    int tap = a, res = 1;

    while (tap < b) {
        tap += a - 1;
        res++;
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

struct BiConnectedComponents
{
  UnionFind uf;
  vector< vector< int > > g;
  vector< pair< int, int > > edges;
  vector< int > used, ord, low, comp;

  BiConnectedComponents(size_t v) : uf(v), g(v), used(v, 0), comp(v), ord(v), low(v)
  {
  }

  void add_edge(int x, int y)
  {
    g[x].push_back(y);
    g[y].push_back(x);
    edges.push_back(minmax(x, y));
  }

  void dfs(int idx, int &k, int par = -1)
  {
    used[idx] = true;
    ord[idx] = k++;
    low[idx] = ord[idx];

    for(auto &to : g[idx]) {
      if(!used[to]) {
        dfs(to, k, idx);
        low[idx] = min(low[idx], low[to]);
        if(ord[idx] >= low[to]) uf.unite(idx, to);
      } else if(to != par) {
        low[idx] = min(low[idx], ord[to]);
      }
    }
  }

  int operator[](int k)
  {
    return (comp[k]);
  }

  size_t size()
  {
    return (g.size());
  }

  void build(vector< vector< int > > &t)
  {
    int kk = 0;
    dfs(0, kk);

    int ptr = 0;
    vector< int > cc(g.size());
    for(int i = 0; i < g.size(); i++) {
      if(i == uf.find(i)) cc[i] = ptr++;
    }

    t.resize(ptr);
    for(int i = 0; i < g.size(); i++) {
      comp[i] = cc[uf.find(i)];
    }
    for(auto &e : edges) {
      int x = comp[e.first], y = comp[e.second];
      if(x == y) continue;
      t[x].push_back(y);
      t[y].push_back(x);
    }
  }
};

int N, M, W[100000];
vector< vector< int > > g;
vector< int > weightSum, sz;
int dp1[100000], dp2[100000], dp3[100000];

int rec(int idx, int par = -1)
{
  int ret = 0;
  for(auto &to : g[idx]) {
    if(to == par) continue;
    rec(to, idx);
    dp2[idx] = max(dp2[idx], dp2[to]);
    dp1[idx] += dp1[to];
  }
  dp2[idx] += weightSum[idx];
  if(sz[idx] >= 3 || dp1[idx] > 0) dp1[idx] += weightSum[idx];
  for(auto &to : g[idx]) {
    if(to == par) continue;
    else ret = max(ret, dp1[idx] - dp1[to] + dp3[to]);
  }
  return (dp3[idx] = max(dp2[idx], ret));
}

int main()
{
  cin >> N >> M;
  BiConnectedComponents tree(N);
  for(int i = 0; i < N; i++) {
    cin >> W[i];
  }
  while(M--) {
    int U, V;
    cin >> U >> V;
    tree.add_edge(--U, --V);
  }
  tree.build(g);
  weightSum.assign(g.size(), 0);
  sz.assign(g.size(), 0);
  for(int i = 0; i < N; i++) {
    weightSum[tree[i]] += W[i];
    sz[tree[i]]++;
  }
  cout << rec(tree[0]) << endl;
}

Measured memory_bytes: 28172
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<pii,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};
int main(){
	int t=-1;
	vi in(15);
	in[0]=1;
	rep(i,14)in[i+1]=in[i]*10;
	rep(i,10){
		cout<<"? "<<in[i+1]<<endl;
		char a;cin>>a;
		if(a!='Y'){
			t=i+1;
			break;
		}
	}
	if(t==-1){
		rep(i,11){
			cout<<"? "<<2*in[i]<<endl;
			char a;cin>>a;
			if(a=='Y'){
				t=i+1;
				break;
			}
		}
		cout<<"! "<<in[t-1]<<endl;
		return 0;
	}
	ll l=in[t-1],r=in[t]-1;
	while(r-l>1){
		ll h=(l+r)/2;
		cout<<"? "<<10*h<<endl;
		char a;cin>>a;
		if(a=='Y')r=h;
		else l=h;
	}
	cout<<"! "<<r<<endl;
}







Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;
    c = min(c, a + b + 1);
    cout << c + b << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String str = sc.next();
		boolean n = false, w = false, s = false, e = false;
		for (int i = 0; i < str.length(); i++) {
			char c = str.charAt(i);
			if (c == 'N') {
				n = true;
			} else if (c == 'W') {
				w = true;
			} else if (c == 'S') {
				s = true;
			} else if (c == 'E') {
				e = true;
			}
		}
		if ((n && s || !n && !s) && (w && e || !w && !e)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23252
a,b = map(int,input().split())
ans = 0
if a == 1:
  ans += 300000
elif a == 2:
  ans += 200000
elif a == 3:
  ans += 100000

if b == 1:
  ans += 300000
elif b == 2:
  ans += 200000
elif b == 3:
  ans += 100000

if a == 1 and b == 1:
  ans += 400000

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    static class Edge implements Comparable<Edge> {
        int from, to, cost;

        public Edge(int from, int to, int cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }

        @Override
        public int compareTo(Edge o) {
            return cost - o.cost;
        }
    }

    static class UnionFind {
        int[] size;
        int[] id;

        public UnionFind(int n) {
            size = new int[n];
            id = new int[n];

            for (int i = 0; i < n; ++i) {
                size[i] = 1;
                id[i] = i;
            }
        }

        void unify(int p, int q) {
            int root1 = find(p);
            int root2 = find(q);

            if (size[root1] > size[root2]) {
                size[root1] += size[root2];
                id[root2] = root1;
            } else {
                size[root2] += size[root1];
                id[root1] = root2;
            }
        }

        int find(int p) {
            int root = p;
            while (root != id[root]) root = id[root];
            while (p != root) {
                int next = id[p];
                id[p] = root;
                p = next;
            }
            return root;
        }

        boolean connected(int p, int q) {
            return find(p) == find(q);
        }
    }

    static int kruskal() {
        int mstCost = 0;
        UnionFind uf = new UnionFind(N);
        PriorityQueue<Edge> pq = new PriorityQueue<>(edges);

        while (!pq.isEmpty()) {
            Edge e = pq.poll();
            if (uf.connected(e.from, e.to)) continue;

            uf.unify(e.from, e.to);
            mstCost += e.cost;
        }

        return mstCost;
    }

    static int N;
    static List<Edge> edges;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        edges = new ArrayList<>();
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                int cost = Integer.parseInt(sc.next());
                if (cost != -1)
                    edges.add(new Edge(i, j, cost));
            }

        }

        System.out.println(kruskal());
    }
}


Measured memory_bytes: 41376
/**
 *    author: codeforces-yuhongtao 
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=0x3f3f3f3f;
const int maxn=5e5+5;
const int mod=1e9+7;
//priority_queue<ll,vector<ll>,greater<ll> > q;//小根堆 
//vector<int> vt[205];
//pair<int,int> p;
//map<string,int> m;
int main(){
	ios::sync_with_stdio(false);
	int k,a,b;
	int f=0;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			f=1;break;
		}
	}
	if(f==1) cout<<"OK";
	else{
		cout<<"NG";
	}
	cout<<endl;
}


Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
const int n_max = 8;
int n,m,ans = 0;
vector<int> v[n_max];
vector<bool> seen;
void dfs(int pos)
{
    bool flag = true;
    for(int i = 0;i < n;i++)
    {
        if(!seen[i])
        {
            flag = false;
            break;
        }
    }
    if(flag)
    {
        ans++;
        return;
    }
    for(int i = 0;i < v[pos].size();i++)
    {
        if(!seen[v[pos][i]])
        {
            seen[v[pos][i]] = true;
            dfs(v[pos][i]);
            seen[v[pos][i]] = false;
        }
    }
    return;
}
int main()
{
    cin >> n >> m;
    seen.resize(n,false);
    seen[0] = true;
    for(int i = 0;i < m;i++)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(0);
    cout << ans << "\n";

    return 0;
}

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

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

vector<ll>lim(5);
 ll max=0;
  int mem=0;

for(int i=0;i<5;i++){
  cin>>lim[i];
  if(N/lim[i]>max){
    max=(N/lim[i]);
    mem=i;
}
}
  if(N%lim[mem]==0){
cout<<4+max<<endl;
  }
  
  else{
cout<<5+max<<endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<math.h>
using namespace std;
long long a,b,k,l,m,n;
int main() {
  cin>>a>>b;
  n=__gcd(a,b);
  for(k=2;k<=sqrt(n);k++){
    if(n%k==0){
      while(n%k==0){
        n=n/k;
      };
      l++;
    };
  };
  if(n>1) cout<<l+2;
  else cout<<l+1;
}

Measured memory_bytes: 256
__DEUBG__ = 0

import math
N = int(input())
high = list(map(int, input().split()))
stack = []
#total = sum(high)
for idx, h in enumerate(high):
    if idx == 0:
        stack.append((idx, h))
    elif h > stack[-1][-1]:
        stack.append((idx, h))

if __DEUBG__:
    print(N, stack)
    #estack.append((N, stack[-1][-1]))

prev = 3
prev = N
total = 0
for idx, h in stack[::-1]:
    if __DEUBG__:
        print(prev, idx, h)
        print((prev - idx) * h)
    total += (prev - idx) * h
    prev = idx

if __DEUBG__:
    print(total, sum(high))
print(total - sum(high))


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 998244353;
 
////////////////////////////////////////////////////////////////////

const int N = 18 + 1;

pii DP[1 << N];

void Add(pii &a, int x) {
	if (a.first < x) a.second = a.first, a.first = x;
	else if (a.second < x) a.second = x;
}
pii Sync(pii a, pii b) {
	Add(a, b.first), Add(a, b.second);
	return a;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	int n; cin >> n;
	for (int i = 0; i < (1 << n); i++) {
		int x; cin >> x;
		DP[i] = make_pair(x, 0);
	}
	for (int i = 0; i < n; i++) for (int mask = (1 << n) - 1; mask >= 0; mask--) {
		if ((mask >> i) & 1) DP[mask] = Sync(DP[mask], DP[mask ^ (1 << i)]);
	}
	int ans = 0;
	for (int i = 1; i < (1 << n); i++) {
		ans = max(ans, DP[i].first + DP[i].second);
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 7168
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        int z = sc.nextInt();
        int w = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        if (n == 1) {
            System.out.println(Math.abs(a[0] - w));
            return;
        }

        int last = a[n - 1];
        int evlast = a[n - 2];
        System.out.println(Math.max(Math.abs(last - evlast), Math.abs(w - last)));
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


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

using namespace std;

int main(int argc, char const *argv[]) {
	string str;
	std::cin >> str;
	// 最初のサイズ
	int size = str.size() / 2;
	// 真ん中の文字
	char half = str[size];

	while (size < str.size()) {
		if (str[size] == half && str[str.size()-1-size] == half) {
			size++;
		}
		else {
			break;
		}
	}
	std::cout << size << '\n';
	return 0;
}


Measured memory_bytes: 512