akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
int main()
{
	LL a,b,i;
	char c[10];
	cin>>a>>c>>b;
	for( i=0 ; ; i++)
	{
		if(c[i]!=' ')
		break;
	}
	if(c[i]=='+')
	cout<<a+b;
	else
	cout<<a-b;
	return 0;
}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

struct Data {
	char t, d;
};

int main()
{
	LL N, Q;
	cin >> N >> Q;

	string S;
	cin >> S;

	vector<int> isOuts(N, 0);

	vector<Data> qs(Q);

	REP(i, Q) {
		cin >> qs[i].t >> qs[i].d;
	}
	
	int left = 0;
	int right = N - 1;

	REP(ri, Q) {
		int i = Q - 1 - ri;

		if (qs[i].d == 'L') {
			if (S[left] == qs[i].t) {
				left++;
			}

			if (right + 1 < N && S[right + 1] == qs[i].t) {
				right++;
			}
		}
		if (qs[i].d == 'R') {
			if (S[right] == qs[i].t) {
				right--;
			}

			if (left - 1 >= 0 && S[left - 1] == qs[i].t) {
				left--;
			}
		}
	}

	int total = right - left + 1;
	if (total < 0) {
		total = 0;
	}

	cout << total << endl;

	return 0;
}


Measured memory_bytes: 1796
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int L = 0;
		int L_max = 0;
		for(int i = 0;i < N;i++) {
			int l = scn.nextInt();
			L +=l;
			L_max = Math.max(L_max, l);
		}
		
		System.out.println(L_max < L - L_max?"Yes":"No");
	}

}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<int> H(N); for (auto& h : H) cin >> h;
    int cnt = 0;
    for (int i = 1; i <= 100; i++) {
        int l = -1;
        for (int j = 0; j < N; j++) {
            if (H[j] >= i && l < 0) l = j;
            if (H[j] < i && l >= 0) cnt++, l = -1;
        }
        if (l >= 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll aa = (a+x-1)/x, bb = (b/x);
    cout << max(0LL, bb-aa+1) << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(ll x, ll y, ll mod){
    ll ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}
void kill()
{
    cout << -1 << endl;
    exit(0);
}

int main() {
    sonic();
    int n;
    i64 next, prev, total, i, t;
    R n;
    i64 ans = 0;
    priority_queue<pair<int, int>> q;
    vi A(n), B(n);
    rep(i, n)R A[i];
    rep(i, n){
        R B[i];
        q.push(make_pair(B[i], i));
    }
    while(0<q.size()) {
        i = q.top().second;
        q.pop();
        if(B[i]==A[i])continue;
        if(B[i]<A[i])kill();
        next = (i + 1 + n) % n;
        prev = (n + i - 1) % n;
        total = B[next] + B[prev];
        t = (B[i] - A[i]) / total;
        if(t==0)kill();
        ans += t;
        B[i] -= t * total;
        q.push(make_pair(B[i], i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 6896
import copy

def partition(p, r):
    i = p
    for j in range(p, r):
        if A[r][1] >= A[j][1]:
            A[i], A[j] = A[j], A[i]
            i += 1
    A[r], A[i] = A[i], A[r]
    return i

def quick_sort(p, r):
    if p < r:
        q = partition(p, r)
        quick_sort(p, q-1)
        quick_sort(q+1, r)

def is_stable():
    for i in range(N-1):
        if A[i][1] == A[i+1][1]:
            small_idx, large_idx = 0, 0
            for j in range(N):
                if A[i] == orig_list[j]:
                    small_idx = j
                elif A[i+1] == orig_list[j]:
                    large_idx = j
            if small_idx > large_idx:
                return False
    return True


N = int(input())
A = []
for _ in range(N):
    suit, num = input().split()
    num = int(num)
    A.append([suit, num])
orig_list = copy.copy(A)

quick_sort(0, N-1)

is_stable = is_stable()
if is_stable:
    print("Stable")
else:
    print("Not stable")

for card in A:
    print("%s %d" % (card[0], card[1]))


Measured memory_bytes: 19228
n = int(input())
aaa = list(map(int, input().split()))
max_a = max(aaa)
cnt = [0] * (max_a + 3)
cnt_sum = [0] * (max_a + 2)
for a in aaa:
    if a == 0:
        cnt[a] += 1
        cnt[a + 2] -= 1
    else:
        cnt[a - 1] += 1
        cnt[a + 2] -= 1
cnt_sum[0] = cnt[0]
for i in range(1, max_a + 2):
    cnt_sum[i] = cnt_sum[i - 1] + cnt[i]
print(max(cnt_sum))

Measured memory_bytes: 13964
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

int n;
string p;

Int dp[3300][3300];
Int dp_sum[3300][3300];

int main(){
    cin >> n;
    cin >> p;
    dp[0][0] = 1;
    for(int i = 1;i < n;i++){
        for(int j = 0;j <= i;j++){
            if(p[i-1] == '<'){
                for(int k=0; k<j; k++){
                  dp[i][j] += dp[i-1][k];
                }
            }else{
                for(int k=j; k<=i-1; k++){
                  dp[i][j] += dp[i-1][k];
                }
            }
            dp[i][j] %= MOD;
        }
    }
    
    Int ans = 0;
    for(int i = 0;i < n;i++){
        ans += dp[n-1][i];
        ans %= MOD;
    }
    if(ans < 0)ans += MOD;
    cout << ans << endl;

  return 0;

rep(i, n){
  rep(j, n)cout<<dp[i][j]<<' ';
  cout<<endl;
}

    return 0;
}


Measured memory_bytes: 50544
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int i=0,pas=0,jui=0;
            
            while ((line = br.readLine()) != null) {
            	if(i<3){
            		if(pas==0){
            			pas=Integer.parseInt(line);
            		}else{
            			pas=Integer.min(Integer.parseInt(line), pas);
            		}
            	}else{
            		if(jui==0){
            			jui=Integer.parseInt(line);
            		}else{
            			jui=Integer.min(Integer.parseInt(line), jui);
            		}
            	}
            	i++;
            	if(i==5){
            		break;
            	}
            }
            System.out.println(pas+jui-50);
        }
    }

}

Measured memory_bytes: 24156
N,A,B = map(int,input().split())

ans = 0
if (B-A)%2 == 0:
    ans = (B-A)//2
else:
    if (A-1)<(N-B):
        ans = A+(B-A-1)//2
    else:
        ans = (N-B+1) + (B-A-1)//2
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) string((s).rbegin(), (s).rend())
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

const int INF = 1000;

void pp(int (*v)[10]){
	rep(i, 10){
		rep(j, 10){
			printf("%5d", v[i][j]);
		}
		cout << endl;
	}
	cout << endl;
}

int sum_v(int *v){
	int sum = 0;
	rep(i, 10){
		if(v[i] == 1000) break;
		sum += v[i];
	}

	return sum;
}

int main(){

	while(1){
		int n;
		cin >> n;
		if(!n) break;

		int v[10][10];
		rep(i, 10){
			rep(j, 10){
				v[i][j] = INF;
				if(i == j)v[i][j] = 0;
			}
		}

		rep(i, n){
			int a, b, c;
			cin >> a >> b >> c;
			v[a][b] = v[b][a] = c;
		}

		//pp(v);

		rep(i, 10){
			rep(j, 10){
				rep(k, 10){
					v[j][k] = min(v[j][k], v[j][i] + v[i][k]);
				}
			}
		}

		int idx = 0;
		int sum = sum_v(v[0]);
		rep(i, 10){
			if(sum_v(v[i]) == 0)continue;
			if( sum_v(v[i]) < sum){
				idx = i;
				sum = sum_v(v[i]);
			}
		}

		//pp(v);

		cout << idx << ' ' << sum << endl;
	}

	

	return 0;
}

Measured memory_bytes: 1160
// ================
// Himanshu Lal
// MNIT Jaipur
// ================
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define INF 1e18
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp map<ll,ll>
#define test ll tp; cin>>tp; while(tp--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    TEZ;
    ll x,n;
    cin>>x>>n;
    set<ll> s;
    f(i,0,n){
        ll a;
        cin>>a;
        s.insert(a);
    }
    ll el=10000,diff=INF;
    f(i,0,1000){
        if(s.find(i)==s.end()){
            diff=min(diff,abs(x-i));
        }
    }
    f(i,0,1000){
        if(s.find(i)==s.end() and diff==abs(x-i)){
            el=min(el,i);
        }
    }
    cout<<el;
}


Measured memory_bytes: 3664
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 100005
#define BLOCK 555
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
inline ll myceil(ll a, ll b) { if (a % b == 0)	return (a / b);	return (a / b + 1);}
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast
	ll n;
	// cin >> n;
	string s;
	cin >> s;
	ll ans = 0, i = 0;
	while (i < 3)
	{
		if (s[i] == 'R')
		{
			ll len = 0;
			while (i < 3 && s[i] == 'R')
				++len , ++i;
			ans = max(ans, len);
		}
		else
			++i;
	}
	cout << ans << END;



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long long> a(n + 1), sum(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
        sum[i] %= MOD;
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        long long tmp = (sum[n] - sum[i] + MOD) % MOD;
        tmp *= a[i];
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6328
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static int mod = 1000000007;

    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int[] C = new int[N];
        int[][]A  = new int[N][M];
        int ans = Integer.MAX_VALUE;

        for(int i=0;i<N;i++){
            C[i] = sc.nextInt();
            for(int j=0;j<M;j++){
                A[i][j] = sc.nextInt();
            }
        }

        for(int i = 0;i<Math.pow(2,N);i++){

            int[] level = new int[M];
            int totalPrice = 0;
            boolean allMastered = true;
            int bit = i;
            for(int j=0;j<N;j++){

                if(bit % 2 == 1){
                    totalPrice += C[j];
                    for(int k=0;k<M;k++){
                        level[k] += A[j][k];
                    }
                }
                bit = bit / 2;
            }

            for(int j=0;j<M;j++){
                if(level[j] < X){
                    allMastered = false;
                }
            }
            if(allMastered){
                ans = Math.min(ans,totalPrice);
            }
        }


        if(ans == Integer.MAX_VALUE){
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
    }

}









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

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}

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

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);
	deque <char> d;
	string s;
	int q;
	cin >> s >> q;
	for(int i=0;i<s.size();i++)
	d.PB(s[i]);
	int ind = 0;
	while(q--)
	{
		int op;
		cin >> op;
		int pos;
		char x;
		if(op == 1)
		ind++;
		else
		{
			cin >> pos >> x;
			if(pos == 1 and ind%2==0)
			d.PF(x);
			else if(pos == 1 and ind%2==1)
			d.PB(x);
			else if(pos == 2 and ind%2==0)
			d.PB(x);
			else
			d.PF(x);
		}
	}
	if(ind%2==0)
	for(auto x:d)
	cout << x;
	else
	for(int i=d.size()-1;i>=0;i--)
	cout << d[i];
	return 0;
}



Measured memory_bytes: 976
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

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

    vs c;
    string n;
    while (cin >> n) {
        c.pb(n);
    }
    stack<int> s;
    rep(i, sz(c)) {
        if (isdigit(c[i][0])) {
            int x = 0;
            reverse(all(c[i]));
            int p = 1;
            rep(j, sz(c[i])) {
                x += (c[i][j] - '0') * p;
                p *= 10;
            }
            s.push(x);
            continue;
        }
        int b, a;
        b = s.top(); s.pop();
        a = s.top(); s.pop();
        if (c[i] == "+") {
            s.push(a+b);
        } else if (c[i] == "-") {
            s.push(a-b);
        } else {
            s.push(a*b);
        }
    }
    cout << s.top() << endl;
}



Measured memory_bytes: 3228
#include<stdio.h>
int main(void)
{
    int N,schoolx,schooly;
    while(scanf("%d%d",&schoolx,&schooly),schoolx)
    {
        int a,o,bre[100][100]={{0}},i,j,find[100][100]={{0}};
        scanf("%d",&N);
        for(i=1;i<=N;i++)
        {
            scanf("%d%d",&a,&o);
            bre[a][o]=1;
        }
        find[1][1]=1;
        for(i=1;i<=schooly;i++)
        {
            for(j=1;j<=schoolx;j++)
            {
                if(i+j==2)continue;
                find[j][i]=find[j-1][i]+find[j][i-1];
                if(bre[j][i]==1)
                {
                    find[j][i]=0;
                }
            }
        }
        printf("%d\n",find[schoolx][schooly]);
    }
    return 0;
}

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

int main() {
	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if((x-r < 0 || x+r > W) || (y-r < 0 || y+r > H)) {
		cout << "No" << endl;
	}else if((x-r >= 0 && x+r <= W) && (y-r >= 0 && y+r <= H)) {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n,k;
  cin>>n>>k;
  int x[n],y[n];
  char c[n];
  REP(i,n){
    cin>>x[i]>>y[i]>>c[i];
    x[i] = (x[i]%(2*k) + 2*k)%(2*k);
    y[i] = (y[i]%(2*k) + 2*k)%(2*k);
    if(c[i]=='W'){
      x[i] = (x[i] + k)%(2*k);
      c[i] = 'B';
    }
  }
  
  int d[2*k][2*k] = {};
  REP(i,n){
    d[x[i]][y[i]] += 1;
  }
  int dsum[2*k][2*k];
  REP(i,2*k){
    REP(j,2*k){
      if(i==0 && j==0){
        dsum[i][j] = d[i][j];
      }else if(i==0){
        dsum[i][j] = dsum[i][j-1] + d[i][j];
      }else if(j==0){
        dsum[i][j] = dsum[i-1][j] + d[i][j];
      }else{
        dsum[i][j] = dsum[i-1][j] + dsum[i][j-1] - dsum[i-1][j-1] + d[i][j];
      }
    }
  }
  
  int ans = 0;
  REP(i,k){
    REP(j,k){//黒を塗る場所の左上を一つ固定する
      int temp = 0;
      if(i==0 && j==0){
        temp += dsum[i+k-1][j+k-1];
      }else if(i==0){
        temp += dsum[i+k-1][j+k-1] - dsum[i+k-1][j-1];
      }else if(j==0){
        temp += dsum[i+k-1][j+k-1] - dsum[i-1][j+k-1];
      }else{
        temp += dsum[i+k-1][j+k-1] - dsum[i+k-1][j-1] - dsum[i-1][j+k-1] + dsum[i-1][j-1];
      }
      if(i != 0 && j!= 0){
        temp += dsum[i-1][j-1];
      }
      if(i != 0){
        temp += dsum[i-1][2*k-1] - dsum[i-1][j+k-1];
      }
      if(j != 0){
        temp += dsum[2*k-1][j-1] - dsum[i+k-1][j-1];
      }
      temp += dsum[2*k-1][2*k-1] - dsum[i+k-1][2*k-1] - dsum[2*k-1][j+k-1] + dsum[i+k-1][j+k-1];
      
      temp = max(temp,n-temp);
      ans = max(ans, temp);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 32384
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
 
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
int N,K;
int T[111111],D[111111];
 
bool ex[111111];
 
signed main(){
    cin>>N>>K;
    rep(i,N)cin>>T[i]>>D[i];
 
    vector<pint>vs;
    rep(i,N)vs.pb(pint(D[i],i));
    sort(all(vs));reverse(all(vs));
 
    int ans=0;
    int num=0,sum=0;
    priority_queue<int,vint,greater<int>>que;
    for(int i=0;i<N;i++){
        int k=vs[i].se;
        if(i<K){
            sum+=D[k];
            if(!ex[T[k]]){
                ex[T[k]]=true;
                num++;
            }
            else{
                que.push(D[k]);
            }
        }
        else if(!ex[T[k]]&&que.size()){
            sum-=que.top();
            que.pop();
            ex[T[k]]=true;
            num++;
            sum+=D[k];
        }
        chmax(ans,num*num+sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4980
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    int n;
    string s;
    cin>>n>>s;
    int count=1;
    REP(i,s.length()-1){
        if(s[i]!=s[i+1]){
            count++;
        }
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in(),X=in();
	int sum=0,minM=1e9;
	REP(i,N){
		int v=in();
		sum+=v;
		minM = min(minM,v);
	}
	int n = (X-sum)/minM;
	cout << N+n << endl;
	return 0;
}


Measured memory_bytes: 256
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N = int(input())
A = list(map(int, input().split()))

ans = 2*(10**9)
S = sum(A)

x = 0
for i in range(N-1):
    x += A[i]
    y = S - x
    ans = min(ans, abs(x-y))

print(ans)

Measured memory_bytes: 33012
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define ll  long long

int main()
{
	ll n;
	cin>>n;
	ll a[n],i;
	for(i=0;i<n;i++)
		cin>>a[i];
	ll mn=a[0],c=1;
	for(i=1;i<n;i++)
	{
		if(a[i]<mn)
		{
			mn=a[i];
			c++;
		}
	}
	cout<<c<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef int ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll MOD=1e9+7;
const ll maxs=1e5+10;
ll max2d=1e3+3;
// ll INF = 1e18;
const ll lg=22; 

void code_idhr_h(){
    ll X,N; cin>>X>>N;
    if(N==0){
        cout<<X;
        return;
    }
    ll A[N+1]; ll frq[105]; mem(frq , 0);
    for(ll i=1; i<=N; i++){
        cin>>A[i];
        frq[A[i]] = 1;
    }
    ll dif = INT_MAX, ans;
    for(ll i=0; i<=101; i++){
        if(dif > abs(X-i) and frq[i]==0){
            ans = i;
            dif = abs(X-i);
        }
    }
    cout<<ans;
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        code_idhr_h();
    }
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const LL MOD = 1e9+7;
const int INF = 1<<30;
int MAXN = 1e5+2;
const double eps = 1e-13;

int f[26];
char s[1000][1000];

int main(){
	DRII(h,w);
	REP(i,h){
		RS(s[i]);
		REP(j,w){
			f[s[i][j]-'a']++;
		}
	}
	if(h%2){
		if(w%2){
			int no=0;
			REP(i,26){
				if(f[i]%2){no++;f[i]--;}
			}
			if(no!=1){puts("No");return 0;}
			no=0;
			REP(i,26){
				if(f[i]%4){no++;f[i]-=2;}
			}
			if(no>h/2+w/2)puts("No");
			else puts("Yes");
		}
		else{
			int no=0;
			REP(i,26){
				if(f[i]%2){no++;f[i]--;}
			}
			if(no){puts("No");return 0;}
			no=0;
			REP(i,26){
				if(f[i]%4){no++;f[i]-=2;}
			}
			if(no>w/2)puts("No");
			else puts("Yes");
		}
	}
	else{
		if(w%2){
			int no=0;
			REP(i,26){
				if(f[i]%2){no++;f[i]--;}
			}
			if(no){puts("No");return 0;}
			no=0;
			REP(i,26){
				if(f[i]%4){no++;f[i]-=2;}
			}
			if(no>h/2)puts("No");
			else puts("Yes");
		}
		else{
			REP(i,26){
				if(f[i]%4){
					puts("No");return 0;
				}
			}puts("Yes");
		}
	}
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
# include <bits/stdc++.h>
using namespace std;
int main() {
    long long N,A[200001];
    cin>>N;
    long long sum[200001];
    sum[0]=0;
    long long xor_sum[200001];
    xor_sum[0]=0;
    for (int i = 0; i < N; i++) {
        cin >>A[i];
        sum[i+1]=sum[i]+A[i];
        xor_sum[i+1]=(xor_sum[i]^A[i]);
    }
    long long res=0;
    long long r,l;
    r=0;
    l=0;
    long long count=0;
    while(r<N && l<N){
        if(sum[r+1]-sum[l]==(xor_sum[r+1]^xor_sum[l])){
            count++;
            if(r<N-1){
                r++;
            }else{
                res+=count;
                count-=2;
                l++;
            }
        }else{
            res+=count;
            count--;
            l++;
        }
        if(l>r && r!=N-1){
            l=r;
        }
    }
    
    std::cout << res << std::endl;
    return 0;
}



Measured memory_bytes: 4992
#include <ciso646>
#include <cstdlib>
#include <iostream>


int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	long long k, s;
	std::cin >> k >> s;
	long long ans = 0;
	for (long long x = 0; x <= k; x++)
	{
		for (long long y = 0; y <= k; y++)
		{
			auto z = s - x - y;
			if (0 <= z and z <= k)
			{
				ans++;
			}
		}
	}
	std::cout << ans << std::endl;
	return EXIT_SUCCESS;
}

Measured memory_bytes: 256
n=[int(input()) for i in range(6)]
x=n[5]+1
flg=0
if n[1]-n[0] < x and n[2]-n[0] < x and n[3]-n[0] < x and n[4]-n[0] < x:
    if n[2]-n[1] < x and n[3]-n[1] < x and n[4] - n[1] < x:
        if n[3]-n[2] < x and n[4]-n[2] < x:
            if n[4]-n[3] < x:
                flg=1
print(':(' if flg==0 else 'Yay!')


Measured memory_bytes: 9100
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

MOD = 10**9+7

S = int(input())
T = S // 3
ans = 0
for t in range(1,T+1):
    re = S - (3*t)
    ans += comb(re+(t-1), t-1) % MOD# re+(t-1)C(t-1)
print(ans % MOD)

Measured memory_bytes: 9184
import java.util.Scanner;

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

		int N=sc.nextInt();
		long x=sc.nextLong();
		long kosu=0L;
		long[] ame=new long[N];

		for(int i=0; i<N; i++) {
			ame[i]=sc.nextInt();
		}

		long tmp1=0; long tmp2=0;
		if(N>=3) {
			for(int i=0; i<=N-2; i++) {
				if(ame[i]+ame[i+1]>x) {
					tmp1=ame[i];
					tmp2=ame[i+1];
					if(ame[i]+ame[i+1]-x>ame[i+1]) {
						ame[i]=tmp1-x;
						ame[i+1]=0;
						kosu+=(tmp1+tmp2-x);
					}
					else if(ame[i]+ame[i+1]-x<=ame[i+1]) {
						ame[i+1]=tmp2-(tmp1+tmp2-x);
						kosu+=(tmp1+tmp2-x);
					}
				}
			}
		}
		else if(N==2){
			kosu=Math.max(ame[0]+ame[1]-x,0);
		}
		System.out.println(kosu);
	}
}

Measured memory_bytes: 58952
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
ans = n + 1 - 2
for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
        ans = min(ans,i + n//i - 2)
print(ans)

Measured memory_bytes: 3060
from collections import deque

S = deque(list(input()))
Q = int(input())
l = []
for i in range(Q):
  l.append(list(input().split()))
    
flag = 1 #1ならふつう, -1なら逆


for i in range(Q):
    if l[i][0] == "1":
        flag *= -1
    elif flag == 1:
        if l[i][1] == "1":
            S.appendleft(l[i][2])
            
        else:
            S.append(l[i][2])
            
    else:
        if l[i][1] == "2":
            S.appendleft(l[i][2])
            
        else:
            S.append(l[i][2])


if flag == 1:
    print("".join(S))
else:
    S.reverse()
    print("".join(S))

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

using namespace std;

int main()
{
  	int d, t, s;
  	cin >> d >> t >> s;
//  	if (d / s <= t)
//      	cout << "Yes";
 // 	else
   //   	cout << "No";
  	if (t * s >= d)
      	cout << "Yes";
  	else
      	cout << "No";
  	//return 0;
}

Measured memory_bytes: 3612
def main():
    H, W, D = map(int, input().split())
    a = [list(map(int, input().split())) for i in range(H)]
    max_ = (((H * W) // D) + 1)
    cost = [[0] * max_ for i in range(D)]
    xy = [None] * (H*W)
    for i in range(H):
        for j in range(W):
            xy[a[i][j] - 1] = [i, j]
    
    cost = [0] * (H*W)
    for start in range(1, D+1):
        now = start + D - 1
        while now < H*W:
            x, y = xy[now]
            px, py = xy[now-D]
            cost[now] = cost[now - D] + abs(px - x) + abs(py - y)
            now += D
    
    Q = int(input())
    for i in range(Q):
        l, r = map(int, input().split())
        print(cost[r-1] - cost[l-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 26224
w,h,n=map(int,input().split())
x=[0]*n
y=[0]*n
a=[0]*n
ans=0
a1=0
a2=w
a3=0
a4=h
for i in range(n):
    x[i],y[i],a[i]=map(int,input().split())
for i in range(n):
    if a[i]==1:
        a1=max(a1,x[i])
    elif a[i]==2:
        a2=min(a2,x[i])
    elif a[i]==3:
        a3=max(a3,y[i])
    else:
        a4=min(a4,y[i])
#print(a1,a2,a3,a4)
if a1>=a2 or a3>=a4:
    print(0)
else:
    print((a2-a1)*(a4-a3))

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

#define ll long long

using namespace std;

int main(){


    int n,m;

    cin >> n >> m;

    int lmax = 0;
    int rmin = n + 1;

    for(int i = 0; i < m; i++){
        int l,r;
        cin >> l >> r;
        lmax = max(lmax,l);
        rmin = min(rmin,r);
    }

    if(rmin - lmax >= 0){
        cout << rmin - lmax + 1 << endl;
    }else{
        cout << 0 << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


ll cal(ll mid){
    string s=to_string(mid);
    ll n=s.size();
    ll dp[n][3][10];memset(dp,0,sizeof(dp));
    rep(i,0,s[0]-'0'){
        if(i==s[0]-'0')dp[0][2][i]=1;
        else if(i==0)dp[0][0][i]=1;
        else dp[0][1][i]=1;
    }
    rep(i,0,n-2){
        rep(j,0,9){
            rep(k,0,9){
                if(k==0)dp[i+1][0][k]+=dp[i][0][j];
                else dp[i+1][1][k]+=dp[i][0][j];
            }
            rep(k,j-1,j+1){
                if(k<0||k>9)continue;
                dp[i+1][1][k]+=dp[i][1][j];
            }
            rep(k,j-1,j+1){
                if(k<0||k>9)continue;
                if(k>s[i+1]-'0')continue;
                if(k==s[i+1]-'0')dp[i+1][2][k]+=dp[i][2][j];
                else dp[i+1][1][k]+=dp[i][2][j];
            }
        }
        
    }
    /*
    rep(i,0,n-1){
        rep(k,0,2){
            rep(j,0,9)cout<<dp[i][k][j]<<" ";cout<<endl;
        }
        cout<<endl;
    }*/
    ll sum=0;
    rep(j,1,2)rep(k,0,9)sum+=dp[n-1][j][k];
    return sum;
}

int main(){fastio
    //cal(10);
    
    //cout<<cal(3234566667)<<endl;
    //rep(i,1,120) cout<<i<<":"<<cal(i)<<endl;
    
    
    ll k;cin>>k;
    ll ng=0,ok=3234566670;
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        ll sum=cal(mid);
        if(sum>=k){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout<<ok<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
//abc170
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll x,y;
    cin>>x>>y;
    bool ok=1;
    
    if(2*x<=y&&y<=4*x){
        ok=1;
    }else{
        ok=0;
    }
    if(y%2==1) ok=0;
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3636
M=10^9+7
A=(x->parse(Int,x)).(split(readlines()[2]))
i=s=r=0
f=1
for a=A
	s=(s+powermod(i+=1,M-2,M))%M
	r=(r+a*(s-1)+A[end+1-i]*s)%M
	f=f*i%M
end
print(r*f%M)

Measured memory_bytes: 180476
#include <bits/stdc++.h>
using i64 = long long;

auto pre_kmp(const std::string &s) {
    std::vector<int> a(s.size() + 1);
    a[0] = -1;
    for (int i = 0, j = -1; i < s.size(); i++) {
        while (j >= 0 && s[i] != s[j]) j = a[j];
        j++;
        a[i + 1] = s[i + 1] == s[j] ? a[j] : j;
    }
    return a;
}

auto find(const std::string &s, const std::string &pat, const std::vector<int> &a, int ss = 0, int ts = 0) {
    for (int i = ss, j = ts; i < s.size(); i++) {
        while (j >= 0 && s[i] != pat[j]) j = a[j];
        if (++j == pat.size()) return i - pat.size() + 1;
    }
    return s.size();
}

auto find_all(const std::string &s, const std::string &pat, const std::vector<int> &a, int ss = 0, int ts = 0) {
    std::vector<int> ret;
    for (int i = ss, j = ts; i < s.size(); i++) {
        while (j >= 0 && s[i] != pat[j]) j = a[j];
        if (++j == pat.size()) {
            ret.push_back(i - pat.size() + 1);
            j = a[j];
        }
    }

    return ret;
}

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n), b(n);
    for (auto &e : a) std::cin >> e;
    for (auto &e : b) std::cin >> e;

    std::vector<int> cnt(n + 1);
    for (int i = 0; i < 30; i++) {
        std::string s, t;
        int bit = 1 << i;
        for (int j = 0; j < n; j++) {
            s.push_back('0' + ((bit & a[j]) > 0));
            t.push_back('0' + ((bit & b[j]) > 0));
        }

        s = s + s;

        auto p = pre_kmp(t);
        for (auto e : find_all(s, t, p)) cnt[e]++;
        for (auto &c : t) c = '1' - c + '0';
        p = pre_kmp(t);
        for (auto e : find_all(s, t, p)) cnt[e]++;
    }

    for (int i = 0; i < n; i++) {
        if (cnt[i] != 30) continue;
        std::cout << i << ' ' << (a[i] ^ b[0]) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 7124
#include<iostream>

using namespace std;

int main () {

    int i, n, R[200000], maxv, minv;

    cin >> n;

    for (i = 0; i < n; i++) {

        cin >> R[i];

    }

    minv = R[0];
    maxv = R[1] - R[0];

    for (i = 1; i < n; i++) {

        if (maxv < R[i] - minv) {

            maxv = R[i] - minv;
        }

        if (R[i] < minv) {

            minv = R[i];

        }

    }

    cout << maxv << endl;

}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3560
s=input()
n=len(s)
d=[0]*2019
d[0]=1
j=1
ans=0
now=0
for i in s[::-1]:
  now=(now+int(i)*j)%2019
  ans+=d[now]
  d[now]+=1
  j*=10
  j%=2019
print(ans)

Measured memory_bytes: 80048
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val n = next()
    println(n.replace('1', 'a').replace('9', '1').replace('a', '9'))
}

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

int main(){
    string S; cin>>S;
    if(S=="Sunny") cout<<"Cloudy"<<endl;
    if(S=="Cloudy") cout<<"Rainy"<<endl;
    if(S=="Rainy") cout<<"Sunny"<<endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<long> a(N);
    long P = (long)1e9+7;
    long right = 0;
    REP(i, N){
        cin >> a[i];
        right = (right + a[i]) % P;
    }
    long result = 0;
    long left = 0;
    REP(i, N){
        left += a[i];
        left %= P;
        result += (right - left) * a[i];
        result %= P;
    }
    if(result < 0) result += P;
    cout << result << "\n";

    return 0;
}

Measured memory_bytes: 4776
#include <stdio.h>

#define N 44

int fib(int);

int main(){
  int n;

  scanf("%d",&n);
  n = fib(n);
  printf("%d\n",n);
  return 0;
}

int fib(n){
  int F[N];
  int i;

  F[0] = 1;
  F[1] = 1;
  for(i=2;i<=n;i++){
    F[i] = F[i-2] + F[i-1];
  }
  return F[n];
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <queue>
#define int long long
using namespace std;

int n,m,q,v[100000],d[100000],c[100000];
int color[100000] = {},maxd[100000] = {};
vector<int> G[100000];

signed main(){
	cin >> n >> m;
	for(int i = 0;i < n;i++) maxd[i] = -1;
	for(int i = 0;i < m;i++){
		int a,b;
		cin >> a >> b;a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	cin >> q;
	for(int i = 0;i < q;i++) {
		cin >> v[q - i - 1] >> d[q - i - 1] >> c[q - i - 1];
		v[q - i - 1]--;
	}
	queue<int> que;
	for(int i = 0;i < q;i++){
		if(maxd[v[i]] < d[i]){
			que.push(v[i]);
			for(int j = d[i];j >= 0;j--){
				int siz = que.size();
				for(int k = 0;k < siz;k++){
					int nowv = que.front();que.pop();
					maxd[nowv] = j;
					if(!color[nowv]) color[nowv] = c[i];
					for(int l = 0;l < G[nowv].size();l++){
						int to = G[nowv][l];
						if(maxd[to] < j - 1) que.push(to);
					}
				}
			}
		}
	}
	for(int i = 0;i < n;i++) cout << color[i] << endl;
	return 0;
}

Measured memory_bytes: 11636
//https://atcoder.jp/contests/dwacon6th-prelims/tasks/dwacon6th_prelims_a
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-3.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;
    vector<pair<string,ll>> stn;
    FOR(i,0,N){
        string s; cin>>s;
        ll t; cin>>t;
        stn.push_back({s,t});
    }    
    string X; cin>>X;
    bool flag=false;
    ll ans=0;
    for(auto&p:stn){
        dump(p.first, ans);
        if(flag) {
            ans+=p.second;
        }else if(p.first == X) flag=true;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, m;

int main() {
	ll l;
	cin >> l >> n;
	ll x[n+1], cumsum[n+1], icumsum[n+1];
	for(ll i = 1; i <= n; i++){
		cin >> x[i];
	}
	for(ll i = 0; i <= n; i++){
		cumsum[i] = 0;
		icumsum[i] = 0;
	}
	
	for(ll i = 1; i <= n; i++){
		cumsum[i] = cumsum[i-1]+x[i];
		icumsum[i] = icumsum[i-1]+l-x[n-i+1];
	}
	ll max = 0;
	//for(ll i = 0; i <= n; i++){
	//	cout << cumsum[i] << "," << icumsum[i] << endl;
	//}
	for(ll i = 1; i <= n; i++){
		ll buf = 0;
		if((n-i)%2 == 0){
			ll end = (n+i)/2;
			buf += 2*(cumsum[end-1]-cumsum[i-1]+icumsum[n-end])+x[end];
		}
		else{
			ll end = (n+i)/2+1;
			buf += 2*(cumsum[end-1]-cumsum[i-1]+icumsum[n-end])+(l-x[end]);
		}
		if(buf > max){
			max = buf;
		}
	}
	for(ll i = 1; i <= n; i++){
		ll buf = 0;
		if(i%2 == 0){
			ll end = i/2;
			buf += 2*(cumsum[end-1]+icumsum[n-end]-icumsum[n-i])+x[end];
		}
		else{
			ll end = i/2+1;
			buf += 2*(cumsum[end-1]+icumsum[n-end]-icumsum[n-i])+(l-x[end]);
		}
		if(buf > max){
			max = buf;
		}
	}
	cout << max;
		

	return 0;
}

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


int main()
{
	int64_t h, w;
	cin >> h >> w;

	int64_t ans = 0;
	if (h == 1 || w == 1) {
		ans = 1;
	} else {
		int64_t a;
		a = w / 2;
		if (w % 2 == 0) {
			ans = a * h;
		} else {
			if (h % 2 == 0) {
				ans = (a + a + 1) * (h / 2);
			} else {
				ans = (a + a + 1) * (h / 2) + a + 1;
			}
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256