akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int M = 8000 + 50, N = 2 * 9000 + 50;
bool dp1[M][N], dp2[M][N];
string s;
int x, y;
vector<int> h[2];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> s >> x >> y;
	int l = 0, r = 0;
	bool p = false;
	for (int i = 0; i < s.size(); i++){
		if(s[i] == 'T'){
			if(!p){
				x -= l;
				l = 0;
				p = 1;
				r = 1 - r;
				continue;
			}
			if(l != 0){
				h[r].push_back(l);
				l = 0;
			}
			r = 1 - r;
		}
		else
			l++;
	}
	if(l > 0){
		if(!p)
			x -= l;
		else
			h[r].push_back(l);
	}
	int mid = 8000 + 10;
	
	for (int i = 0; i < h[0].size(); i++){
		if(i == 0){
			dp1[0][mid + h[0][0]] = 1;
			dp1[0][mid - h[0][0]] = 1;
		}else{
			for (int j = 0; j < N; j++){
				if(j + h[0][i] < N)
					dp1[i][j] |= dp1[i - 1][j + h[0][i]];
				if(j - h[0][i] >= 0)
					dp1[i][j] |= dp1[i - 1][j - h[0][i]];
			}
		}	
	}
	
	for (int i = 0; i < h[1].size(); i++){
		if(i == 0){
			dp2[0][mid + h[1][0]] = 1;
			dp2[0][mid - h[1][0]] = 1;
		}else{
			for (int j = 0; j < N; j++){
				if(j + h[1][i] < N)
					dp2[i][j] |= dp2[i - 1][j + h[1][i]];
				if(j - h[1][i] >= 0)
					dp2[i][j] |= dp2[i - 1][j - h[1][i]];
			}
		}	
	}
	
	bool t1;
	if(h[0].size() == 0){
		if(x != 0)
			return cout << "No", 0;
		t1 = 1;
	}else
		t1 = dp1[h[0].size() - 1][mid + x];
	bool t2;
	if(h[1].size() == 0){
		if(y != 0)
			return cout << "No", 0;
		t2 = 1;
	}else
		t2 = dp2[h[1].size() - 1][mid + y];
						
	if(t1 && t2)
		cout << "Yes";
	else
		cout << "No";
}



Measured memory_bytes: 73984
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll n, k;
    cin >> n >> k;

    cout << min(abs(n - k * (n / k)), abs(n - k * (n / k + 1)));



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,P;
  cin >>N >>P;
  int a[N];
  int evena=0;
  int odda=0;
  long long ans=1;
  for (int i=0;i<N;i++){
    cin >>a[i];
    if(a[i]%2==0){
      evena++;
    }
    else odda++;
  }
  
  if((evena==N)&&(P==0)){
    ans=pow(2,N);
    cout<<ans<<endl;
    return 0;
  }
  if((evena==N)&&(P==1)){
    ans=0;
    cout<<ans<<endl;
    return 0;
  }
  ans=pow(2,N-1);
  cout<<ans<<endl;
  return 0;
}

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

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//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);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N,A,B;
  cin >> N >> A >> B;
  
  LL x = N/(A+B), y = N%(A+B);
  
  LL ans;
  ans += x*A;
  
  ans += min(y,A);
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}




void smain() {

    int a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    if(w>=v){
        cout<<"NO";
        return;
    }
    int st=abs(a-b);
    int sp=v-w;
    if(st/sp+(st%sp!=0)<=t)
        cout<<"YES";
    else
        cout<<"NO";



}

Measured memory_bytes: 3636
#include<iostream>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n,k; cin >> n >>k;
	ll ans=1;
	ll a=n/k;
	ll b=2*n/k;
	ll c=(n+1)/k;
	ll d=b-a;
	if(k%2==1){
		ans=a*a*a;
	}
	else if(k==2){
		ans=a*a*a+c*c*c;
	}
	else{
		ans=a*a*a+d*d*d;
	}
	cout << ans << endl;
}

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

const int mod = 1e9 + 7;
long long h, w, a, b, fact[200010], ans = 0;

long long power(int a, int n) {
    if(n == 0) return 1;
    if(n == 1) return a;
    long long b = power(a, n/2);
    b = (b*b) % mod;
    if(n&1) b = (b*a) % mod;
    return b;
}

long long C(int k, int n) {
    return fact[n] * power(fact[k] * fact[n-k] % mod, mod - 2) % mod;
}

int main() {
    fact[0] = 1;
    for(int i = 1; i < 200010; i++) fact[i] = (fact[i-1] * i)% mod;
    scanf("%lld%lld%lld%lld", &h, &w, &a, &b);
    for(int i = 1; i <= h - a; i++) ans = (ans + C(i-1, b-1+i-1) * C(h-i, h-i + w-b-1) % mod) % mod;
    printf("%lld", ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
	return 0;
}


Measured memory_bytes: 384
import numpy as np

n = int(input())
p = np.array([int(_) for _ in input().split()])
pp = sorted(p)
dif = pp - p
non_zero = len(p)-np.count_nonzero(dif==0)
if (non_zero == 2) or (non_zero == 0):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 12444
N=int(input())
m = {}
for i in range(N):
  s = input()
  if s in m:
    m[s] += 1
  else:
    m[s] = 1
M=int(input())
for i in range(M):
  t = input()
  if t in m:
    m[t] -= 1
  else:
    m[t] = -1
ans = 0
for k,v in m.items():
  ans = max( ans, v )
print(ans)

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

ll a[100009],b[100009],c[100009];

void solve()
{
	int n,m,i;
	cin>>n>>m;
	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<m;i++) cin>>b[i]>>c[i];
	sort(a,a+n);
	vi ind(m);
	iota(all(ind),0);
	sort(all(ind),[](int A, int B){return c[A]>c[B];});
	i=0;
	for(auto u: ind)
	{
		while(i<n && b[u]!=0)
		{
			if(a[i]>=c[u]) break;
			a[i++]=c[u];
			b[u]--;
		}
	}
	ll sum=0;
	for(i=0;i<n;i++) sum+=a[i];
	cout<<sum<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
#define Y1 "YES"
#define N1 "NO"
#define ENDL '\n'
#define count2(x) _builtin_popcount(x)
#define MaxN 211
#define MaxBit 62
ll num[MaxN];
char s[MaxN];
ll d[MaxBit];
bool add(ll x){
	for(int i=MaxBit-1;i>=0;--i){
		if((x>>i)&1){
			if(d[i])x^=d[i];
			else{
				d[i]=x;
				return 1;
			}
		}
	}
	return 0;
}
ll search(ll x){
	for(int i=MaxBit-1;i>=0;--i){
		if((x^d[i])>x)
		x^=d[i];
	}
	return x;
}
int main(){
	int n;
	int T;
	cin>>T;
	while(T--){
		cin>>n;
		for(int i=1;i<=n;++i)
		cin>>num[i];
		for(int i=1;i<=n;++i)
		cin>>s[i];
		int flag=0;
		for(int i=1;i<=n;++i){
			if(s[i]=='1'){
				memset(d,0,sizeof(d));
				for(int j=i+1;j<=n;++j){
					if(s[j]=='0')
					add(num[j]);
				}
				if(add(num[i])==1){
					flag=1;
					break;
				}
			}
		}
		if(flag==1)
			cout<<"1\n";
		else
			cout<<"0\n";
	LOOP: 1==1;
	}
	return 0;
}



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

int main(){
	int n, x, y, px, py;
	scanf("%d%d%d%d%d", &x, &y, &n, &px, &py);
	int ans = 0, tx, ty;n--;
	while(n--){
		scanf("%d%d", &x, &y);
		tx = x-px;ty = y-py;
		px = x;py = y;
		if((tx > 0 && ty > 0) || (tx < 0 && ty < 0))
		ans += max(abs(tx), abs(ty));
		else ans += abs(tx)+abs(ty);
	}
	printf("%d\n", ans);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
    ll a, b;
    while (cin >> a >> b) {
        if (a!=0 || b!=0) {
            cout << min(a, b) << ' ' << max(a, b) << endl;
        }
    }
}


Measured memory_bytes: 3036
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}


int id[1010]={};
int from[1010]={};
int x[1010];
int y[1010];
int prev[1010];
int done[1010];

struct NODE{
	int to;
	double cost;
	int prev;
	NODE(int to,double cost,int prev) : to(to) ,cost(cost) , prev(prev) {}
};
bool operator < (const NODE &a,const NODE &b){
	return a.cost > b.cost;
}
int main(){
	ios_base::sync_with_stdio(false);
	int n;
	while(cin >> n && n){
		for(int i = 0 ; i < n ; i++){
			cin >> id[i] >> x[i] >> y[i];
			from[id[i]] = i;
		}
		int m;
		cin >> m;
		for(int xx = 0 ; xx < m ; xx++){
			int s,g;
			cin >> s >> g;
			s = from[s];
			g = from[g];
			priority_queue<NODE> Q;
			Q.push(NODE(s,0,-1));
			memset(done,0,sizeof(done));
			while(Q.size()){
				NODE q = Q.top(); Q.pop();
				if( done[q.to]++ ) continue;
				else prev[q.to] = q.prev;
				if( q.to == g ){
					vector<int> r;
					r.push_back(q.to);
					q.to = prev[q.to];
					while(q.to != -1 ){
						r.push_back(q.to);
						q.to = prev[q.to];
					}
					for(int i = r.size() -1 ; i >= 0 ; i--)
						cout << id[r[i]] << (i?" ":"\n");
					goto exit;
				}
				for(int i = 0 ; i < n ; i++){
					if( (x[q.to]-x[i])*(x[q.to]-x[i])+(y[q.to]-y[i])*(y[q.to]-y[i]) > 2500 ) continue;
					Q.push(NODE(i,q.cost+sqrt((x[q.to]-x[i])*(x[q.to]-x[i])+(y[q.to]-y[i])*(y[q.to]-y[i])),q.to));
				}
			}
			cout << "NA" << endl;
			exit:;
			
		}
	}
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
    int x, n;
    cin >> x >> n;
    vector<bool> p(102,true);
    for (int i = 1; i <= n;i++){
        int t;
        cin >> t;
        p[t] = false;
    }
    int ans = 0;
    for (int i = 1; i <= 101;i++){
        if(p[i] && abs(x - i) < abs(x - ans))
            ans = i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).trim().split('\n');
main();

function main(){
  for(var i = 0, len = input.length; i < len; i+=2){
    var hit = brow = 0;
    var a = input[i].trim().split(' ');
    var b = input[i + 1].trim().split(' ');
    for(var j = 0, lenj = a.length; j < lenj; j++){
      if((c=b.indexOf(a[j])) != -1)
        c!=j?brow++:hit++;
    }
    console.log(hit, brow);
  }
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int X, N;
	cin >> X >> N;
	vector<int> p(N);
	rep(i,N) cin >> p[i];
	for(int i=0; i<=1000; i++){
		int d1=X-i, d2=X+i;
		rep(j,N){
			if(p[j]==d1) break;
			if(j==N-1){
				cout << d1 << endl;
				return 0;
			}
		}
		rep(j,N){
			if(p[j]==d2) break;
			if(j==N-1){
				cout << d2 << endl;
				return 0;
			}
		}		
	}
	cout << X << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#include <vector>

typedef long long LL;
const int MN = 100005;

int N, p[MN], siz[MN], ok;
LL dis[MN], sum[MN];
bool cmp(int i, int j) { return dis[i] > dis[j]; }
std::vector<int> G[MN];

void DFS(int u, LL d) {
	if (d != dis[u]) ok = 0;
	for (auto v : G[u]) DFS(v, d + N - 2 * siz[v]);
}

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%lld", &dis[i]), p[i] = i, siz[i] = 1;
	std::sort(p + 1, p + N + 1, cmp);
	for (int i = 1; i < N; ++i) {
		int u = p[i];
		if (2 * siz[u] >= N) return puts("-1"), 0;
		dis[0] = dis[u] - N + 2 * siz[u];
		int pos = std::lower_bound(p + i + 1, p + N + 1, 0, cmp) - p;
		if (pos > N) return puts("-1"), 0;
		int v = p[pos];
		G[v].push_back(u);
		siz[v] += siz[u];
		sum[v] += sum[u] + siz[u];
	}
	ok = 1;
	DFS(p[N], sum[p[N]]);
	if (!ok) return puts("-1"), 0;
	for (int i = 1; i <= N; ++i)
		for (auto v : G[i]) printf("%d %d\n", i, v);
	return 0;
}

Measured memory_bytes: 10752
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    t = list(map(int, input().rstrip('\n').split()))
    m = int(input().rstrip('\n'))
    px = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    st = sum(t)
    for p, x in px:
        print(st - t[p-1] + x)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
const long long INF = 1LL << 60;
const int inf = 1e9;
ll mod = 1e9 + 7;

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<int> q;
    vector<int> dist(n, inf);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (int u : G[v])
        {
            if (dist[u] != inf)
                continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    rep(i, n)
    {
        if (i == 0)
            continue;
        cout << pre[i] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 10560
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
int main(){
  int m,n;
  cin>>n>>m;
  vector<bool>in(m);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    if(a+b<n)loop(i,a,a+b)in[i]=true;
    else{
      loop(i,a,n)in[i]=true;
      rep(i,(a+b)%n)in[i]=true;
    }
  }

  bool count=0;
  int tmp=0;
  int out[101]={0};
  rep(i,n){
    int co=0;
    while(in[i]){
      co++;i++;
      if(i==n)break;
    }
    if(co==0&&i==n-1)out[tmp]++;
    else if(i>n-1)out[co+tmp]++;
    else if(count==0);
    else out[co]++;
    if(co)i--;
    if(!count){
      count=true;
      tmp=co;
    }
  }
  //rep(i,n)cout<<" "<<in[i];
  //cout<<endl;
  for(int i=100;i>0;i--)if(out[i])cout<<i<<" "<<out[i]<<endl;

}


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

int main(){

  int x[3];

  cin>>x[0]>>x[1]>>x[2];

  sort(x, x+3);

  if(x[0]+x[1]==x[2]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main()
{
    fast;
    char n,m;
    cin>>n>>m;
    string s1="";
    string s2 = "";
    for(int i=0;i<(m-'0');i++)
        s1.pb(n);
    for(int i=0;i<(n-'0');i++)
        s2.pb(m);
    cout<<min(s1,s2);
}   

Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#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))

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

bool cango[8][8];
bool visited[8];
int main() {

	int N, M;
	cin >> N >> M;
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		cango[a][b]=cango[b][a] = true;
		
	}
	VI X(N);
	REP(i, N) {
		X[i] = i;
	}
	int num = 0;
	do {
		

		CLR(visited);
		visited[X[0]] = true;
		bool all = true;

		for (int i = 0; i < SZ(X) - 1; i++) {
			if (cango[X[i]][X[i + 1]] == false) {
				goto NEXT;
			}
			visited[X[i + 1]] = true;
		}
		REP(i, SZ(X)) {
			if (!visited[i]) {
				goto NEXT;
			}
		}
		num++;
	NEXT:;
	} while (next_permutation(X.begin()+1,X.end()));
	cout << num << endl;

}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;
extern crate num;

fn calclate_score(D: i32, s: Vec<Vec<i32>>, c: Vec<i32>, out: Vec<i32>) -> i32 {
    let mut sat = 0;
    let mut last = vec![0; 26];
    for d in 0..D {
        assert!(1 <= out[d as usize] && out[d as usize] <= 26);
        let j = out[d as usize] - 1;
        last[j as usize] = d + 1;
        for i in 0..26 {
            sat -= (d + 1 - last[i]) * c[i];
        }
        sat += s[d as usize][j as usize];
        println!("{}", sat);
    }
    sat
}

fn main() {
    input! {
        D: i32,
        mut c: [i32; 26],
        mut s: [[i32; 26]; D],
        mut out: [i32; D]
    }
    calclate_score(D, s, c, out);
}


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

using namespace std;

const string table[] = {
    "",
    "',.!?",
    "abcABC",
    "defDEF",
    "ghiGHI",
    "jklJKL",
    "mnoMNO",
    "pqrsPQRS",
    "tuvTUV",
    "wxyzWXYZ",
};

int main() {
    string s;
    while(cin >> s && !cin.eof()) {
        char cur = s[0];
        int seq = 1;
        for(int i = 1; i < s.size(); ++i) {
            if(s[i] == cur) ++seq;
            else {
                int idx = cur-'0';
                if(idx == 0) for(int j = 0; j < seq-1; ++j) cout << ' ';
                else cout << table[idx][(seq-1) % table[idx].size()];

                cur = s[i];
                seq = 1;
            }
        }
        int idx = cur-'0';
        if(idx == 0) for(int j = 0; j < seq-1; ++j) cout << ' ';
        else cout << table[idx][(seq-1) % table[idx].size()];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 0
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
double dp[3000][3000];

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<double> p(n);
  rep(i, n)cin >> p[i];
  dp[0][0] = 1.;
  rep(i, n){
    rep(j, n+1){
      if(j>0)dp[i+1][j] = dp[i][j] * (1.-p[i]) + dp[i][j-1] * p[i];
      else dp[i+1][j] = dp[i][j] * (1.-p[i]);
    }
  }
  double res = 0.;
  FOR(i, (n+1)/2, n+1)res += dp[n][i];
  cout << setprecision(12);
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    int list[N][3];
    list[0][0] = 0;
    list[0][1] = 0;
    list[0][2] = 0;
    for(int i = 1; i<=N; i++) {
        cin >> list[i][0] >> list[i][1] >> list[i][2];
    }

    string res = "Yes";
    for(int i = 0; i<N; i++) {
        int dt   = list[i + 1][0] - list[i][0];
        int dist = abs(list[i + 1][1] - list[i][1]) +  abs(list[i + 1][2] - list[i][2]);
        if(dt < dist) {
            res = "No";
            break;
        }
        if(dt % 2 != dist % 2) {
            res = "No";
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
//12 rows and columns I can control 
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w,k;cin>>h>>w>>k;
  	int tot=0;
  	int totbits=h+w;
  	vector<vector<char > >mat(h,vector<char >(w,'.'));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin>>mat[i][j];
  	for(int s=0;s<(1<<totbits);s++){
    	//iterating through all subsets of selected rows and  columsn
      	//first h bits rows,second w bits columns
      int  count=0;
     // cout<<s<<' ';
      for(int i=0;i<h;i++){
          if(((1<<i)& s))continue;
          //cout<<i<<' ';
        for(int j=0;j<w;j++)
        { //coloured red
            if(( s & (1<<(j+h))))continue;

         	if(mat[i][j]=='#')count++; //not coloured
        }
      }
      //cout<<count<<'\n';
      if(count==k){tot++;}
    }
  cout<<tot;
}

Measured memory_bytes: 3604
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  char a[] = {'w', ' ', 'k', 's', 't', 'n', 'h', 'm', 'y', 'r',}, b[] = {'a', 'i', 'u', 'e', 'o'};
  map<char, int> m;
  m['T'] = 0; m['L'] = 1; m['U'] = 2; m['R'] = 3; m['D'] = 4;
  string s; cin >>s;
  for(int i = 0; i + 1 < (int)(s.length()); i += 2){
    int _a = s[i] - '0', _b = m[s[i + 1]];
    if(s[i] == '0' && s[i + 1] == 'U'){
      cout <<"nn";
      continue;
    }
    if(_a != 1) cout <<a[_a];
    cout <<b[_b];
  }  cout <<endl;
  return 0;
}

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

using namespace std;

const int DIM = (1 << 12) + 7;
const int INF = 1e9;

int dp[DIM];

main()
{
	int n, m;
	cin >> n >> m;
	
	for(int i = 1; i < (1 << n); i++)
		dp[i] = INF;
	
	dp[0] = 0;
	
	for(int i = 1; i <= m; i++)
	{
		int a, b;
		cin >> a >> b;
		
		int mask = 0;
		
		for(int j = 1; j <= b; j++)
		{
			int x;
			cin >> x;
			
			x--;
			
			mask |= (1 << x);
		}
		
		for(int j = 0; j < (1 << n); j++)
			dp[mask | j] = min(dp[mask | j], dp[j] + a);
	}
	
	if(dp[(1 << n) - 1] == INF)
		cout << -1;
	else
		cout << dp[(1 << n) - 1];
}

Measured memory_bytes: 256
import java.util.*;
class Main{

public static void main(String[] args){

Scanner s = new Scanner(System.in);
long d = s.nextInt() , n = s.nextInt();

	if(d == 0){
		if(n!=100)
		System.out.println(n);
		else
			System.out.println(101);
	}
	else if(d == 1){
		if(n!=100)
		System.out.println(100*n);
		else
			System.out.println(100*n+100);
	}
	else
	{
		if(n!=100)
		System.out.println(10000*n);
		else
			System.out.println(10000*n+10000);
	}
}
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (A > K){
    cout << K << endl;
  }  
  else if(A + B >= K) {
    cout << A << endl;  
  }
  else {
    cout << A - (K - A - B) << endl;
  }
}

Measured memory_bytes: 3632
import sys
import math
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

N = int(input())
X = list(map(int,input().split()))
ans = INF
for i in range(1, 101):
    temp = 0
    for l in X:
        temp += (l-i)**2
    if temp < ans:
        ans = temp
print(ans)

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

int main()
{
    long long ans ,a ,b,c,d; 

    cin>>a>>b>>c>>d; 

    long long int m[] = {a*c, a*d , b*d , b*c}; 


    for(int i=0 ; i<4;i++ )
    {
        if( i==0 )
        {
            ans =m[i];
        }
        else if(m[i] > ans)
        {
            ans = m[i];
        }
    } 

    cout<<ans;

    
}

Measured memory_bytes: 3596
import fractions

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a, b = list(map(int, input().split()))
print(len(set(prime_factorize(fractions.gcd(a, b))))+1)

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

ll i,j,k,l;
ll dp[200001],cnt[2019];//

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

    //同じあまりの2数を選択することを考える
    for(i=0;i<200001;i++){dp[i]=0;}
    for(i=0;i<2019;i++){dp[i]=0;}
    
    cnt[0]++;//0を選択する場合もある　1817181712114なら12114と0を選んで引き算

    ll pow_ten=1,ans=0;
    for(i=s.size()-1;i>=0;i--){
        //下から順に2019で割ったあまりを考える→同じあまりの2数をこの中から選んで、差が2019で割れれば題意を満たす
        dp[i]=(dp[i+1]+(s[i]-'0')*pow_ten)%2019;
        pow_ten*=10;
        pow_ten%=2019;
        cnt[dp[i]]++;
    }

    for(i=0;i<2019;i++){
        ans+=cnt[i]*(cnt[i]-1)/2;
    }
    

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

Measured memory_bytes: 5292
/** Author: Nicklaus **/
 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;

int main(){
	int n;
	cin>>n;
	vector<int> a(n), b(n);
	for(int i=0; i<n; i++) cin>>a[i];
	for(int i=0; i<n; i++) cin>>b[i];
	int ans = 0;
	for(int i=0; i < (1<<n) ; i++){
		int x=0,y=0;
		for(int j=0; j<n; j++){
			if((1<<j)&i){
				y+=b[j];
				x+=a[j];
			}
		}
		ans = max(ans, x-y);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
class Main {

    private static final int CONST= 1000000007;
    public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
        long M = Integer.parseInt(sc.next());
        long N = Integer.parseInt(sc.next());
        System.out.println(myPow(M, N));
        sc.close();
    }

    private static long myPow(long m, long n){
        if(n == 0)  return 1;

        long res = myPow(m*m%CONST, n/2);
        if(n%2 == 1) res = res * m %CONST;
        return res;
    }
}


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

using ll = long long int;

const int MAX_N = (int)1e5 + 5;

int n;
ll a[3 * MAX_N];

priority_queue<ll, vector<ll>, greater<ll>> leftpq;
priority_queue<ll> rightpq;

ll l, r;
ll scorel[3 * MAX_N];
ll scorer[3 * MAX_N];
ll ans;

int main(void){
    // Here your code !
    scanf("%d", &n);
    for (int i = 0; i < 3 * n; ++i) {
      scanf("%lld", &a[i]);
    }

    for (int i = 0; i < n; ++i) {
      leftpq.push(a[i]);
      l += a[i];
    }
    scorel[n] = l;

    for (int i = 3 * n - 1; i >= 2 * n; --i) {
      rightpq.push(a[i]);
      r += a[i];
    }
    scorer[2 * n] = r;

    for (int i = n; i < 2 * n; ++i) {
      leftpq.push(a[i]);
      l += a[i];
      l -= leftpq.top();
      leftpq.pop();
      scorel[i + 1] = l;
    }

    for (int i = 2 * n - 1; i >= n; --i) {
      rightpq.push(a[i]);
      r += a[i];
      r -= rightpq.top();
      rightpq.pop();
      scorer[i] = r;
    }

    ans = scorel[n] - scorer[n];
    for (int i = n; i <= 2 * n; ++i) {
      ans = max(ans, scorel[i] - scorer[i]);
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 7796
n,m,x,y = map(int,input().split(" "))

xak = list(map(int,input().split(" ")))
yak = list(map(int,input().split(" ")))

x_max = max(xak)
y_min = min(yak)

if x_max >= y_min:
    print("War")
else:
    for i in range(x_max+1,y_min+1):
        if x < i <= y:
            print("No War")
            break
    else:
        print("War")

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

int main(void)
{
 char X, Y;
 cin >> X >> Y;
 if(X==Y){
  cout << '=' << endl;
 }else if(X > Y){
  cout << '>' << endl;
 }else{
  cout << '<' << endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,K,A[100'000];
int ceilDiv(int x,int y){
  return(x+y-1)/y;
}
main(){
  cin>>N>>K;
  for(int i=0;i<N;++i)cin>>A[i];
  const int ans=ceilDiv(N-1,K-1);
  cout<<ans<<endl;
}


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

int main()
{
    int n,k,i,count=0,x;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>x;
        if(x>=k)
         count++;
    }
    cout<<count<<"\n";
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  in(int,n,m,k);
  if(k==0)
    {
      puts("Yes");
      return 0;
    }
  int sum=n*m;
  int i,j;
  int judge=0;
  rep(i,n)
    rep(j,m)
    if(i*j+(n-i)*(m-j)==k)
      judge=1;
  if(judge)
    puts("Yes");
  else
    puts("No");
  return 0;
}


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

a = [0] * M
for i in range(M):
    a[i] = int(input())
    



memo = [-1] * (N+1)
memo[0] = 1

for i in range(M):
    memo[a[i]] = 0


for i in range(1,N+1):
    if i == 1 and memo[i] == -1:
        memo[i] = memo[i-1]
    elif memo[i] >= 0:
       memo[i] = 0
        ## memo[i] i 番目の階段にいくまでのルート数
    else:
          memo[i] = memo[i-1] +memo[i-2]


print(memo[N] % 1000000007)


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;

const int M_MAX = 2000;
const int N_MAX = 2000;

int main() {
  int N, M; cin >> N >> M;
  int S[N]; rep(i,N) cin >> S[i];
  int T[M]; rep(i,M) cin >> T[i];

  ll sum[N+1][M+1]={}; 
  rep(i,N+1) sum[i][0] = 1; rep(i,M+1) sum[0][i] = 1;
  rep(i,N) rep(j,M) {
    ll tmp = sum[i+1][j] + sum[i][j+1];
    if (S[i]!=T[j]) tmp -= sum[i][j];
    tmp = (tmp%MOD+MOD)%MOD;
    sum[i+1][j+1] = tmp;
  }

  // rep(i,N+1) { rep(j,M+1) cout << sum[i][j] << " "; cout << endl; }
  cout << sum[N][M] << endl;
  return 0;
}

Measured memory_bytes: 31488
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

def knapsack(sm,W,n,V):
    K = [[0]*(sm+1) for i in range(n+1)]
    for i in range(1,n+1):
        for j in range(1,sm+1):
            K[i][j] = K[i-1][j]
            if W[i-1] <= j:
                K[i][j] = max(V[i-1]+K[i-1][j-W[i-1]], K[i-1][j])
    return K[n][sm]

n,wt = ip()
V,W = [0]*n,[0]*n
for i in range(n):
    w,v = ip()
    V[i] = v
    W[i] = w
ans = knapsack(wt,W,n,V)
print(ans)
    


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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

ll calc(ll a, ll b) {
	if(a==0 || b==0) return a?-a:-b;
	if(a>b) return calc(b, a);
	return b/a*2*a + calc(b%a, a);
}
int main(){
	ll x,a;
	cin >> x >> a;
	cout << x + calc(a, x-a) <<endl;
	return 0;
}

Measured memory_bytes: 256
S = input()#.split()

#print(S);

s = len(S)  #become int form
intS = int(S)
answer = []
A = []
j = 1
abcd = []
#create array using calculation
if 4 <= s <= 10:
    for i in range(s-2):
        Sarray = S[j-1:j+2]
        answer = answer + [int(Sarray)]
        #print(answer)
        j += 1
        A = A + [753]

#calculation
for i in range(s-2):
    abc = abs(answer[i] - A[i])
    abcd = abcd + [abc]
    # print(abcd)


# abc1 = abc.split( )
abcd.sort()

#print(abcd)
print(abcd[0])
#print(A)
#print(abc)
# print(format(abc))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class393
    {
        static void Main()
        {
            string b = Console.ReadLine();
            Console.WriteLine(bond(b));
        }
        static string bond(string b)
        {
            if (b == "A") return "T";
            if (b == "T") return "A";
            if (b == "G") return "C";
            return "G";
        }
    }
}


Measured memory_bytes: 25740
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int s, ans = 0;

  for (int i=0; i<3; i++) {
    scanf("%1d", &s);
    ans += s;
  }

  cout << ans << endl;

  return 0;
}


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

int gcd(int a,int b){
    if(a==0)
        return b;
    if(b==0)
         return a;
    if(a>b){
        return(gcd(b,a%b));
    }
    else
        return(gcd(a,b%a));
    }


int main()
{
    int x;
    int i,j,k,n;
    long long int c=0;
    cin>>n;
    for(i=1;i<=n;i++){
         for(j=1;j<=n;j++){
              for(k=1;k<=n;k++){
                  x=gcd(j,k);
                  c+=gcd(i,x);
              }
         }
    }
    
    
    cout<<c;
   
}


Measured memory_bytes: 3636
a,b,c,x = map(int,[input() for i in range(4)])
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if i * 500 + j * 100 +k * 50 == x:
        ans += 1
print(ans)

Measured memory_bytes: 2940
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *P = map(int, read().split())
    
    if P == sorted(P):
        print('YES')
        return
    
    for i in range(N-1):
        for j in range(i+1, N):
            B = P[:]
            B[i] = P[j]
            B[j] = P[i]
            if B == sorted(P):
                print('YES')
                return
                
    print('NO')
    return


if __name__ == '__main__':
    main()


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

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

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  int n;
  cin >> n;
  
  vector<int> a(4,0);
  vector<char> s(n);
  
  for ( int i = 0; i < n; i++){
    cin >> s[i];
    if ( s[i] == 'Y' ){
      cout << "Four" << endl;
      return 0;
    }
  }
  
  cout << "Three" << endl;

}

Measured memory_bytes: 256