akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

struct COODINATE
{
public:
    int x, y, n;
};

vector<string> Gin;
Graph Gout;
queue<COODINATE> Q;

void search(int x, int y, int n, int h, int w){
    if(x<0 || w<=x || y<0 || h<=y || Gin[y][x] == '#' || Gout[y][x] != -1){
        return;
    }
    Gout[y][x] = n;
    Q.push(COODINATE{x+1, y, n+1});
    Q.push(COODINATE{x-1, y, n+1});
    Q.push(COODINATE{x, y+1, n+1});
    Q.push(COODINATE{x, y-1, n+1});
}

int main(){
    int h, w;
    cin >> h >> w;
    int b_cnt = 0;
    for(int i=0;i<h;i++){
        string s;
        cin >> s;
        Gin.push_back(s);
        for(int j=0;j<w;j++){
            if(s[j] == '#'){
                b_cnt++;
            }
        }
    }
    Gout.assign(h, vector<int>(w, -1));
    int ans = h * w - b_cnt;
    bool flg = false;
    
    Q.push(COODINATE{0, 0, 1});
    while(!Q.empty()){
        COODINATE coodinate = Q.front();
        Q.pop();
        if(coodinate.x == w-1 && coodinate.y == h-1){
            ans -= coodinate.n;
            flg = true;
            break;
        }
        search(coodinate.x, coodinate.y, coodinate.n, h, w);
    }

    if(flg){
        cout << ans << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main() {
    int n, ans = 1000;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        int cnt=0;
        cin >> a.at(i);
        while(a.at(i)%2 == 0){
            cnt++;
            a.at(i)/=2;
        }
        ans = min(ans, cnt);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2001;
typedef long long ll;
const ll mod=1e9+7;
ll fact[N];
ll invfact[N];

ll mp(ll a,ll b){
ll res=1;
while(b){
if(b&1){ res=(res*a)%mod;}
a=(a*a)%mod;
b>>=1;
}
return res;
}
ll inv(ll a){
return mp(a,mod-2); 
}

void compute(){
fact[0]=invfact[0]=1;
for(int i=1;i<N;i++){
fact[i]=(i*fact[i-1])%mod;
invfact[i]=inv(fact[i]); 
}
}
ll choose(ll n, ll r){
if(n<r||n<0||r<0) return 0;
ll res=((fact[n]*invfact[r])%mod*invfact[n-r])%mod;
return res;
}
int main(){
compute();
ll s; cin>>s;
ll res=0;
for(int i=1;i<=(s/3);i++){
res=(res+choose(s-2*i-1,i-1))%mod;
}
cout<<res<<'\n';
return 0;
}

Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define mset(a,x) memset(a,x,sizeof(a))
#define OUT(x) cout<<(x)<<"\n"
#define SZ(x) (int)(x).size()
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)


int main() {
    ll a, b;
    cin >> a >> b;
    if(a*b <= 0) {
        puts("Zero");
    }
    else if(a > 0 || (b - a) % 2 == 1) {
        puts("Positive");
    }
    else {
        puts("Negative");
    }

    return 0;
}

Measured memory_bytes: 256
//##MohK..
//21/04/2020....6.09...
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll counter=0;
    string a;
    cin>>a;
    for(ll i=0;i<a.size();i++){
        if(a[i]=='7'){
            counter++;
            break;
        }
    }
    if(counter==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

int S[1000], top; 

void initialize(){
	top = 0;
}

int isEmpty() {
	return top == 0;
}

int isFull() {
	return top >= 1000 - 1;
}

void push(int x){
	if(isFull()) cout<<"ERROR: overflow"<<endl;
	top++;
	S[top] = x;
}

int pop(){
	if(isEmpty()) cout<<"ERROR: underflow"<<endl;
	top--;
	return S[top + 1];
}

int number(int num[], int t){
	int N = 0;
	for(int i = 0; i < t; i++){
		N += num[i] * pow(10, t - i - 1); 
	}
	
	return N;	
}

int main(){
	string str;
	int t = 0, N = 0, num[15] = {}, O1, O2;
	
	getline(cin, str);
	
	initialize();

	for(int i = 0; i < (int)str.size(); i++){
		if(str[i] == '+') push(pop() + pop());
		if(str[i] == '-') {
			O1 = pop();	
			O2 = pop();
			push(O2 - O1);
		}
		if(str[i] == '*') push(pop() * pop());
		if(str[i] == ' '){
			if(t) push(number(num, t));
			t = 0;
		}
		if('0' <= str[i] && str[i] <='9'){
			num[t] = str[i] - '0';
			t++;
		}
	}
	
	cout<<pop()<<endl;
	
	return 0;
}


Measured memory_bytes: 3356
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1))%mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	return (n + 9) / 10 * 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	cout << s[0][0] << s[1][1] << s[2][2];
}

Measured memory_bytes: 256
// d_vishal
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long a,b,x,lo=0,hi=0,i,ans=0,tmp,value=0;
  cin>>a>>b>>x;
  if(x>a){
    hi=b/x;
    ans=hi;//-lo+1;
    if(a==0)ans++;
  }
  else{
    tmp=a/x;
    if(a%x!=0){
    value=(tmp+1)*x;
    }
    else{
      value=a;
    }
    //for(i=a;i<=b;i++){
      //if(i%x==0){
        lo=value/x;
        hi=b/x;
        ans=hi-lo+1;
        //break;
      //}
    //}

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


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
wa = 0
wa2 = 0
for i in range(n):
    if a[i] > 0:
        wa += a[i]
for i in range(k):
    if a[i] > 0:
        wa -= a[i]
        wa2 += a[i]
    else:
        wa2 += a[i]
l = []
if wa2 > 0:
    l.append(wa+wa2)
else:
    l.append(wa)
for i in range(n-k):
    if a[i] > 0:
        wa += a[i]
        wa2 -= a[i]
    else:
        wa2 -= a[i]
    if a[i+k] > 0:
        wa -= a[i+k]
        wa2 += a[i+k]
    else:
        wa2 += a[i+k]
    if wa2 > 0:
        l.append(wa+wa2)
    else:
        l.append(wa)
print(max(l))

Measured memory_bytes: 14576
"""B - Toll Gates
https://atcoder.jp/contests/abc094/tasks/abc094_b
N M X
A_1 A_2 ... A_M

>>> main(5, 3, 3, [1, 2, 4])
1
>>> main(7, 3, 2, [4, 5, 6])
0
>>> main(10, 7, 5, [1, 2, 3, 4, 6, 8, 9])
3
"""


def main(n, m, x, a):
    line = [0 for _ in range(n)]

    for a in a:
        line[a - 1] = 1

    to_left = sum(line[x - 1:])
    to_right = sum(line[x - 1::-1])

    print(min(to_left, to_right))


if __name__ == '__main__':
    n, m, x = map(int, input().split())
    a = list(map(int, input().split()))

    main(n, m, x, a)


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

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t; cin >> t;
    while (t--) {
        int n; cin >> n;
        vector<vector<vector<int>>> f(2, vector<vector<int>>(n + 1));
        ll sum = 0;
        for (int i = 0; i < n; ++i) {
            int k, l, r; cin >> k >> l >> r;
            if (l >= r) {
                f[0][k].emplace_back(r - l);
                sum += l;
            }
            else {
                if (n - k == 0) {
                    sum += l;
                    continue;
                }
                f[1][n - k].emplace_back(l - r);
                sum += r;
            }
        }
        for (int j = 0; j < 2; ++j) {
            priority_queue<int> pq;
            for (int i = 1; i <= n; ++i) {
                for (auto p : f[j][i]) pq.emplace(p);
                while (pq.size() > i) {
                    sum += pq.top();
                    pq.pop();
                }
            }
        }
        cout << sum << '\n';
    }
}

Measured memory_bytes: 17900
#include<bits/stdc++.h>          
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)	make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long MOD = 1000000007;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	cout << ((a * b % 2 == 0) ? "No\n" : "Yes\n");
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a,b;
int main()
{
    scanf("%d%d%d",&n,&a,&b);
    int res=max(0,a+b-n);
    printf("%d %d\n",min(a,b),res);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=100050;
int main()
{
	int n,i,x,y;
	scanf("%i",&n);
	vector<int> l,r,lm,rm;
	vector<pair<int,int> > m;
	for(i=1;i<=n;i++)
	{
		scanf("%i %i",&x,&y);
		l.pb(y);
		r.pb(x);
	}
	l.pb(0);
	r.pb(0);
	sort(l.begin(),l.end());
	sort(r.begin(),r.end());
	reverse(r.begin(),r.end());
	ll ans=0;
	for(i=0;i<n;i++)
	{
		if(l[i]<r[i]) ans+=-l[i]*2+r[i]*2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1276
n,k = map(int, input().split())
b = list(range(1,n+1))
a = []
for i in range(k):
    d = int(input())
    a += list(map(int, input().split()))
a = list(set(a))
num = 0
for h in b:
    if h not in a:
        num += 1
print(num)

Measured memory_bytes: 9112
from collections import Counter
n = int(input())
s = []
#s = [sorted(input()) for i in range(n)]
for i in range(n):
    temp = sorted(input())
    temp = ''.join(temp)
    s.append(temp)

s = Counter(s)
#print(s)
result = 0
for i in s.values():
    result += (i*(i-1))//2

print(result)

Measured memory_bytes: 19760
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}}; ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    int N;
    cin >> N;
    vector<i64> A(N), B(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    sort(WHOLE(A)), sort(REV_WHOLE(B));
    i64 ans = 0;
    if(N % 2 == 0) { // 偶数
        i64 m_min = A[N / 2] + A[N / 2 - 1];
        i64 m_max = B[N / 2] + B[N / 2 - 1];
        ans = m_max - m_min + 1;
    } else { // 奇数
        i64 m_min = A[(N - 1) / 2];
        i64 m_max = B[(N - 1) / 2];
        ans = m_max - m_min + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6344
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;

use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (h, w, n) = (v[0] as i32, v[1] as i32, v[2]);
    let v = read_vec::<i32>();
    let (start_y, start_x) = (v[0], v[1]);
    let s = read::<String>().chars().collect::<Vec<_>>();
    let t = read::<String>().chars().collect::<Vec<_>>();

    let mut safe = true;

    for &(start, limit, R, L) in &[(start_x, w, 'R', 'L'), (start_y, h, 'D', 'U')] {
        let mut l = 1;
        let mut r = limit;
        for i in (0..n).rev() {
            if i != n - 1 {
                if t[i] == R && l - 1 >= 1 {
                    l -= 1;
                }
                if t[i] == L && r + 1 <= limit {
                    r += 1;
                }
                debug!((i, "aoki", l, r, safe));
            }

            if s[i] == R {
                r -= 1;
            }
            if s[i] == L {
                l += 1;
            }

            safe &= l >= 1 && l <= r && r <= limit;
            debug!((i, "taka", l, r, safe));
        }
        if start < l || start > r {
            safe = false;
        }
    }
    if safe {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6396
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////

int main(){

    ll n,k;
    L2(n,k);
    ll sum = 0;
    for(int i=1;i<=k;i++){
        ll x;
        L(x);
        sum+=x;
    }
    if(sum>=n)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a.sort()
    f = list(map(int, readline().split()))
    f.sort(reverse=True)
    af = [av * fv for av, fv in zip(a, f)]

    cor_v = 10 ** 13
    inc_v = -1
    while cor_v - inc_v > 1:
        bin_v = (cor_v + inc_v) // 2
        cost = 0
        #条件を満たすcostを全検索
        for i, v in enumerate(af):
            if v > bin_v:
                cost += ((v - bin_v) + f[i] - 1) // f[i]
        #costが制約を満たすか
        if cost <= k:
            cor_v = bin_v
        else:
            inc_v = bin_v
    print(cor_v)


if __name__ == '__main__':
    solve()


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s; cin >> s;
  vector<char> all;
  
  char c = 'a';
  rep(i,26){    
    all.push_back(c);
    c++;
  }

  rep(i,all.size()){
    bool n_in = false;
    rep(j,s.size())
      if(all[i]==s[j]) n_in = true;
    if(!n_in){
      cout << all[i] << endl;
      return 0;
    }
  }

  cout << "None" << endl;
  
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

vector<int> sieve(int n) {
  vector<int> p(n);
  REP(i,2,n) p[i]=i;
  for(int i=2; i*i<n; i++) {
    if(p[i]) {
      for(int j=i*i; j<n; j+=i) p[j]=0;
    }
  }
  //p.erase(remove(all(p),0),p.end());
  return p;
}

int main() {
  vector<int> p=sieve(1000000);
  int m[1000001];
  m[0]=0;
  REP(i,1,p.size()) {
    m[i]=m[i-1];
    if(p[i]) m[i]++;
  }
  p.erase(remove(all(p),0),p.end());
  int n,k;
  while(cin >> n >> k) {
    if(n==-1 && k==-1) break;
    vector<int> a;
    int x=m[n];
    REP(i,x,x+101) {
      REP(j,i,x+101) a.pb(p[i]+p[j]);
    }
    sort(all(a));
    pr(a[k-1]);
  }
  return 0;
}


Measured memory_bytes: 9056
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
long long i[10000][10000];
long long u[1111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e=1,f=0;
  string s;
  cin >>a>>b>>c;
  if(a<=c&&a+b>=c) cout <<"YES\n";
  else cout<<"NO\n";
  return (0);
}


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

#define int long long

int a[2111], n, k;
int sum[2111];

signed main() {
    vector<int> v;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= i; j++) {
            v.push_back(sum[i] - sum[j - 1]);
        }
    }

    // for (int i = 0; i < n; i++) {
    //     int u ;
    //     cin >> u;
    //     v.push_back(u);
    // }
    for (int i = 42; i >= 0; i--) {
        int cnt = 0;
        for (int j = 0; j < v.size(); j++) {
            if (v[j] >> i & 1) cnt += 1;
        }
        vector<int> tmp_v;
        if (cnt >= k) {
            for (int j = 0; j < v.size(); j++) {
                if (v[j] >> i & 1) {
                    tmp_v.push_back(v[j]);
                }
            }
            v = tmp_v;
        } 
        // for (int x : v) {
        //     cout << x << " ";
        // }
        // cout << endl;
    }
    int ans = v[0];
    for (int i = 0; i < k; i++) {
        ans &= v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6256
/**
 * @File   : atcoder.cpp
 * @Author : pasnger 
 * @Date   : 29/8/2020, 2:59:47 pm 
 */

#include<bits/stdc++.h>
using namespace std;
#define INF 1e17
#define int long long
#define f(i, a, b) for(int i=a; i<b; i++)
#define rf(i, a, b) for(int i=a; i>b; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() {
  cerr << "]\n";
}
template<typename T, typename ...Args> void DBG(T first, Args... args) {
  cerr << first; if (sizeof...(args))cerr<<", "; DBG(args...);
}

/////////////////////////// GLOBAL ///////////////////////////

/////////////////////////// GLOBAL ///////////////////////////

void solve() {
  string s, t;
  cin>>s>>t;
  int m = INF;
  f(i, 0, s.length()-t.length()+1){
    string n = s.substr(i, t.length());
    int count = 0;
    f(j, 0, n.length()){
      if(n[j] != t[j]) count++;
    }
    m = min(m, count);
  }
  cout<<m<<"\n";
}


int32_t main() {
  #ifndef ONLINE_JUDGE
  clock_t tStart = clock();
  freopen("in.txt", "r", stdin);
  //freopen("output.txt","w",stdout);
  #endif 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  // cin >> t;
  for (int tt=1;tt<=t;tt++) {
    //cout << "Case #"<<tt<<": ";
    solve();
  }
  #ifndef ONLINE_JUDGE
    cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
  #endif
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if (a==b) {
    cout<<c<<endl;
  } else if (a==c) {
    cout<<b<<endl;
  } else {
    cout<<a<<endl;
  }
}

Measured memory_bytes: 3500
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

B = []
for i, a in enumerate(A):
    B.extend([i+1]*a)

h = -1
ans = []
for i, b in enumerate(B):
    if i % W == 0:
        h += 1
        C = []
    C.append(b)
    if i % W == W-1:
        if h%2 == 0:
            ans.append(C)
        else:
            ans.append(C[::-1])

for C in ans:
    print(' '.join([str(c) for c in C]))


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string s;cin>>s;
    map<int,int> ma;
    REP(i,s.size())ma[s[i]]++;
    bool is=true;
    if(ma.size()!=2)is=false;
    for( auto i = ma.begin(); i != ma.end() ; ++i ) {
        if(i->second!=2)is=false;
    }
    cout<<(is?"Yes":"No")<<endl;

}

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

using namespace std;
int main()
{

    int n,i,j,k,l;
    char a1[1000];
   // freopen("input.txt","r",stdin);
    scanf("%d",&n);
    scanf("%s",&a1);

    if(n%2!=0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        for(int i=0;i<n/2;i++)
        {
            if(a1[i]!=a1[i+n/2])
            {
                 cout<<"No"<<endl;
                 return 0;
            }
        }
         cout<<"Yes"<<endl;
    }

}


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

typedef long long LL;

//container util
//------------------------------------------
#define PB push_back
#define MP make_pair
#define DECIM(digits)  cout<<fixed<<setprecision(digits)
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<pair<int,int> >gem;
    gem.resize(n);
    REP(i,n){
      int x,y;
      cin >> x >> y;
      gem[i]=MP(x,y);
    }
    int m;
    cin >> m;
    pair<int,int> pos=MP(10,10);
    REP(i,m){
      string news;
      int amount;
      cin >> news >> amount;
      while(amount--){
	if(news=="N")
	  pos.second++;
	if(news=="E")
	  pos.first++;
	if(news=="W")
	  pos.first--;
	if(news=="S")
	  pos.second--;
	for(auto j=gem.begin();j!=gem.end();)
	  if(pos==*j) j=gem.erase(j);
	  else ++j;
      }
    }
    if(gem.empty()) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	#define int long long
    int n,m;
    cin >> n >> m;
    vector <pair <int, int> > v;
    for(int i = 0; i < n; i++)
    {
    	int x,y;
    	cin >> x >> y;
    	v.pb({x,y});
	}
	sort(v.begin(),v.end());
	int bought = 0,ans = 0;
	for(int i = 0; i < v.size(); i++)
	{
		int req = m-bought;
		if(v[i].second >= req)
		{
			ans += (v[i].first*req);
			bought = m;
			break;
		}
		else if(v[i].second < req)
		{
			ans += (v[i].first*v[i].second);
			bought += v[i].second;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2420
/************************************************************LET US BREAK BAD!****************************************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
	//#ifndef ONLINE_JUDGE
	//    freopen("../input.txt", "r", stdin);
	//    freopen("../output.txt", "w", stdout);
	//#endif
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll t;
	// cin>>t;
	t = 1;
	while(t--){
		ll n;
		cin>>n;
		string ss;
		cin>>ss;
		ll cnt = 0;
		rep(i, n){
			if(ss[i]=='R'){
				cnt++;
			}
		}
		ll ans = 0;
		rep(i, cnt){
			if(ss[i]!='R'){
				ans++;
			}
		}   
		cout<<ans<<endl;
	}
return 0;
}


Measured memory_bytes: 3708
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb push_back
#define mkp make_pair
#define p_q priority_queue
#define INF 200000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

int dp[100010][13];

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

  string s; cin >> s;
  reverse(ALL(s));
  int tmp = 1;
  dp[0][0] = 1;
  REP(i, s.size()){
    REP(j, 13){
      if(s[i] == '?'){
        REP(k, 10){
          int a = tmp*k;
          a %= 13;
          if(j-a < 0) dp[i+1][j] += dp[i][j-a+13];
          else dp[i+1][j] += dp[i][j-a];
          dp[i+1][j] %= MOD;
        }
      } else {
        int a = tmp*(int)(s[i]-'0');
        a %= 13;
        if(j-a < 0) dp[i+1][j] += dp[i][j-a+13];
        else dp[i+1][j] += dp[i][j-a];
        dp[i+1][j] %= MOD;
      }
    }
    tmp *= 10; tmp %= 13;
  }
  cout << dp[s.size()][5] << endl;
}

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

int n;

int solve();

int main() {
  cin >> n;

  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 0;
  for(int i = 1; i <= n; i += 2) {
    int cnt = 0;
    for(int j = 1; j <= n; ++j)
      if(i % j == 0) ++cnt;
    if(cnt == 8) ++ans;
  }
  return ans;
}

Measured memory_bytes: 256
# AtCoder Beginner Contest 125
# https://atcoder.jp/contests/abc125
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nnn = lambda n: ss2nnn(ii2ss(n))

cache = {}


def gcdr(a, b):
    if a not in cache:
        cache[a] = {}
    if b in cache[a]:
        return cache[a][b]
    if b == 0:
        cache[a][b] = a
        return a
    n = gcdr(b, a % b)
    cache[a][b] = n
    return n

def gcd(a, b):
    if a >= b:
        return gcdr(a, b)
    else:
        return gcdr(b, a)

def main_lte(N, An):
    if N == 2:
        n = max(An[0], An[1])
        print(n)
        return
    nn = [An[0]] * N
    nn[0] = An[1]
    for i in range(1, N):
        for j in range(N):
            if i == j:
                continue
            nn[j] = gcd(nn[j], An[i])
    print(int(max(nn)))

def main_ok(N, An):
    if N == 2:
        n = max(An[0], An[1])
        print(n)
        return
    nn0 = gcd(An[0], An[1])
    nn1 = set((An[0], An[1]))
    for i in range(2, N):
        t1 = nn0
        nn0 = gcd(nn0, An[i])
        t2 = [gcd(n, An[i]) for n in nn1]
        nn1 = set(t2)
        nn1.add(t1)
    n = max(nn1)
    print(int(n))

def main(N, An):
    nnl = [0] * N
    nnr = [0] * N
    nnl[0] = An[0]
    nnr[N-1] = An[N-1]
    for i in range(1, N):
        nnl[i] = gcd(nnl[i-1], An[i])
    for i in range(N-2, -1, -1):
        nnr[i] = gcd(nnr[i+1], An[i])
    nn = [0] * N
    nn[0] = nnr[1]
    nn[N-1] = nnl[N-2]
    for i in range(1, N-1):
        nn[i] = gcd(nnl[i-1], nnr[i+1])
    n = max(nn)
    print(int(n))

N = i2n()
An = i2nn()
main(N, An)


Measured memory_bytes: 15416
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import Counter
def resolve():
    n = int(input())
    C = Counter()
    for _ in range(n):
        S = input()
        if '.' in S:
            a, b = S.split('.')
            a = int(a + b + '0' * (9 - len(b)))
        else:
            a = int(S + '0' * 9)
        two = five = 0
        while a % 2 == 0:
            two += 1
            a //= 2
        while a % 5 == 0:
            five += 1
            a //= 5
        C[two, five] += 1

    ans = 0
    for key0, val0 in C.items():
        i0, j0 = key0
        for key1, val1 in C.items():
            i1, j1 = key1
            if i0 + i1 >= 18 and j0 + j1 >= 18:
                if key0 == key1:
                    ans += val0 * (val0 - 1) // 2
                elif key0 < key1:
                    ans += val0 * val1
    print(ans)
resolve()

Measured memory_bytes: 74676
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
// #define mp make_pair
// #define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define show(x) cout << #x << " = " << x << endl;





int main(){

  int n;
  cin >> n;

  ll c[n], s[n], f[n];
  REP(i, n-1){
    cin >> c[i] >> s[i] >> f[i];
  }
  ll st, tmp;
  REP(i,n-1){
    st = s[i];
    FOR(j,i,n-2){
      st += c[j];
      if(st <= s[j+1]){
        st = s[j+1];
      }else{
        if(st % f[j+1] !=0){
          st = st - (st % f[j+1]) + f[j+1];
        }
      }
    }
    cout << st + c[n-2] << endl;
  }
  cout << 0 << endl;



  return 0;
}


Measured memory_bytes: 256
// problem: "https://atcoder.jp/contests/abc151/tasks/abc151_c"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,m,p,i;
    string s;
    int C;

    cin>>n>>m;
    vector<bool>V(n+1,0);
    vector<int>P(n+1,0);

    C = 0;
    for(i=0;i!=m;i++)
    {
        cin>>p>>s;

        if(!V[p])
        {
            if(s == "AC")
            {
                C++;
                V[p] = true;
            }

            else
                P[p]++;
        }
    }



    cout<<C<<" ";

    C = 0;
    for(i=1;i!=n+1;i++)
        if(V[i])
            C += P[i];

    cout<<C;

    return 0;
}


Measured memory_bytes: 640
o = input()
e = input()
password = ''

if len(o) >= len(e):
    times = len(e)
else:
    times = len(o)

for i in range(times):
  password = password + o[i]
  password = password + e[i]

if len(o) > len(e):
    password = password + o[-1]
elif len(e) > len(o):
    password = password + e[-1]

print(password)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << 180 * (n-2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[100005]={0};
int main()
{
	int i,n,sum=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<=n;i++)
		if(a[i]==i&&a[i+1]==i+1)
		{
			sum++;
			i++;
		}
		else if(a[i]==i&&a[i+1]!=i+1)
			sum++;
	printf("%d",sum);
	return 0;
}

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

int n, arr[100005], diff=0, x, y=1;
map<int, int> ar;
bool check=false;
int main(){
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> x;
        if(x==0){
            check=true;
        }
        if(ar[x]==0){
            ar[x]++;
            diff++;
            arr[y]=x;
            y++; 
        }
        else{
            ar[x]++;
        }
    }
    if(n%3!=0){
        if(diff==1 && check==true){
            cout << "Yes" << endl;
            return 0;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    else{
        if(diff==1 && check==true){
            cout << "Yes" << endl;
            return 0;
        }
        else if(diff==2 && check==true && ar[0]==n/3){
            cout << "Yes" << endl;
            return 0;
        }
        else if(diff==3){
            if(((arr[1]^arr[2])^arr[3])==0 && ar[arr[1]]==n/3 && ar[arr[2]]==n/3){
                cout << "Yes" << endl;
                return 0;
            }
            else{
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
//void chmin(int &a, int b) { if (a > b) a = b; }
//void chmax(int &a, int b) { if (a < b) a = b; }

const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;


int main() {
    int n,k,r,s,p;
    ll ans = 0;
    cin >> n >> k >> r >> s >> p;
    string T;
    cin >> T;
    for (int i = 0; i < n; ++i) {
        if(i >= k){
            if(T[i-k] == T[i]) T[i] = '#';
            else{
                if(T[i] == 'r') ans += p;
                if(T[i] == 's') ans += r;
                if(T[i] == 'p') ans += s;
            }
        }else{
            if(T[i] == 'r') ans += p;
            if(T[i] == 's') ans += r;
            if(T[i] == 'p') ans += s;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long dp[1001][1001];
const long long mod=1e9+7;
int main()
{
    int n,m;
    cin>>n>>m;
    int i,j;
    char a[n+1][m+1];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin>>a[i][j];
        }
    }
    dp[1][1]=0;
    if(a[1][1]=='.')
    {
        dp[1][1]=1;
    }
    for(i=2;i<=n;i++)
    {
        if(a[1][i]=='.')
            dp[1][i]=dp[1][i-1];
    }
    for(i=2;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(a[i][j]=='#')
            {
                dp[i][j]=0;
                continue;
            }
            dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
        }
    }
    cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 9088
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var K = input[0] - 1;
            var X = input[1];
            int from = -1000000;
            int end = 1000000;
            if (X - K > from)
            {
                from = X - K;
            }

            if (X + K < end)
            {
                end = X + K;
            }

            string ret = string.Empty;
            for (int i = from; i <= end; i++)
            {
                ret += i.ToString() + " ";
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13396
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}
#define int ll
vector<int> vertexs[2000];
int color[2000];
int dfs(int now) {
	for (auto x : vertexs[now]) {
		if (color[x] == -1) {
			color[x] = (color[now] + 1) % 2;
			if (dfs(x)) return 1;
		}
		else {
			if (color[x] != (color[now] + 1) % 2) {
				return 1;
			}
		}
	}
	return 0;
}
void solve(){
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0) return;
		set<int> ans;
		REP(i, n) {
			vertexs[i].clear();
		}
		REP(i, m) {
			int a, b;
			cin >> a >> b;
			a--; b--;
			vertexs[a].push_back(b);
			vertexs[b].push_back(a);
		}
		REP(i, 2) {
			REP(q, n) {
				color[q] = -1;
			}
			color[0] = i;
			if (dfs(0) == 0) {
				int now = 0;
				REP(q, n) {
					if (color[q] == 0) {
						now++;
					}
				}
				if (now % 2 == 0)ans.insert(now / 2);
			}
		}
		cout << ans.size() << endl;
		for (auto x : ans) {
			cout << x << endl;
		}
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3324
N, M, X = 3, 3, 10
ARR = [
    [60, 2, 2, 4],
    [70, 8, 7, 9],
    [50, 2, 3, 9],
]

N, M, X = 3, 3, 10
ARR = [
    [100, 3, 1, 4],
    [100, 1, 5, 9],
    [100, 2, 6, 5]
]

N, M, X = 8, 5, 22
ARR = [
    [100, 3, 7, 5, 3, 1],
    [164, 4, 5, 2, 7, 8],
    [334, 7, 2, 7, 2, 9],
    [234, 4, 7, 2, 8, 2],
    [541, 5, 4, 3, 3, 6],
    [235, 4, 8, 6, 9, 7],
    [394, 3, 6, 1, 6, 2],
    [872, 8, 4, 3, 7, 2],
]

N, M, X = map(int, input().split())
ARR = []

for i in range(N):
    ARR.append(list(map(int, input().split())))


def calculate(n, m, x, arr):
    result = []
    for i in range(2 ** n):

        tmpValue = 0
        mrr = [0] * m
        krr = [False] * m
        for j in range(n):
            res = i >> j & 1
            if res == 1:
                tmpValue = tmpValue + arr[j][0]
                for mIndex in range(m):
                    mrr[mIndex] = mrr[mIndex] + arr[j][mIndex + 1]
                    if mrr[mIndex] >= x:
                        krr[mIndex] = True
        if sum(krr) == m:
            result.append(tmpValue)

    if len(result) == 0:
        print(-1)
    else:
        print(min(result))


calculate(N, M, X, ARR)


Measured memory_bytes: 9336
#include<bits/stdc++.h>
using namespace std;
#define int long long
void Digvijay()
{
   int a,b;
   cin>>a>>b;
   int ans = a*b/__gcd(a,b);
   cout<<ans<<"\n";
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _=1;
    //cin>>_;
    for(int __=0;__<_;__++)
    {
        Digvijay();
    }
}

Measured memory_bytes: 3624
using System;

class P{
  static void Main(){
    long val = long.Parse(Console.ReadLine());
    long x=1;
    long y=1; 
    for(long i = 1; i <= Math.Sqrt(val); i++){
      if(val%i==0){x = val/i;y=i;}
    }
    
    long idou = (x-1)+(y-1);
    Console.WriteLine(idou);
  }
}

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

int main(){
  int n;
  vector<int> v;
  while(cin>>n,n){
    v.clear();
    int tmp;
    for(int i=0;i<n;i++){
      cin>>tmp;
      v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    int sum=0;
    for(int a:v){
      sum+=a;
    }
    sum-=v[0];
    sum-=v[v.size()-1];
    cout << sum / (v.size()-2)<< endl;
  }
  return 0;
}

Measured memory_bytes: 1216