akhauriyash/Code-Regression huggingface dataset:
a, b = map(int, input().split())
s = input().split("-")

flag = True
if len(s) != 2:
    flag = False
if flag:
    if len(s[0]) != a:
        flag = False
    if len(s[1]) != b:
        flag = False
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N=int(input())
soinsu=[0]*N
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr
for n in range(2,N+1):
  for a in factorization(n):
    soinsu[a[0]-1]+=a[1]
over2=0
over4=0
over14=0
over24=0
over74=0
for i in range(N):
  if soinsu[i]>=74:
    over74+=1
  if soinsu[i]>=24:
    over24+=1
  if soinsu[i]>=14:
    over14+=1
  if soinsu[i]>=4:
    over4+=1
  if soinsu[i]>=2:
    over2+=1
print(over74 + over24*(over2-1) + over14*(over4-1) + over4*(over4-1)*(over4-2)//2 + (over2-over4)*over4*(over4-1)//2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N, M, K;
    cin >> N >> M >> K;
 
    for( int i = 0; i <= N; ++i )
    {
        for( int j = 0; j <= M; ++j )
        {
            if( i * ( M - j ) + j * ( N - i )  == K )
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def mergeSort(A, left, right, n):
    if left + 1 < right:
        mid = int((right + left ) / 2 )
        mergeSort(A, left, mid, n)
        mergeSort(A, mid, right, n)
        return (merge(A, left, mid, right, n))

def merge(A, left, mid, right, n):
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]  + [10 ** 9 + 1]
    R = A[mid:right] + [10 ** 9 + 1]
    L.append(1000000001)
    R.append(1000000001)
    i = j = 0
    for k in range(left, right):
        A[n] += 1
        if L[i] <= R[j]:
            key = L[i]
            A[k] = key
            i += 1
        else:
            key = R[j]
            A[k] = key
            j += 1
    return A

n = int(input())
A = list(map(int, input().split()))
A.append(0)
S = mergeSort(A, 0, len(A) - 1, n)
print(' '.join(list(map(str, S[:n]))))
print(S[n])


Measured memory_bytes: 70612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    set<ll> st;
    ll max1 = 0;
    ll max2 = 0;
    rep(i, 0, n) {
        ll a;
        cin >> a;
        if (st.count(a)) {
            st.erase(a);
            if (max1 <= a || max2 <= a) {
                if (max1 <= max2) max1 = a;
                else max2 = a;
            }
        } else {
            st.insert(a);
        }
    }

    cout << max1 * max2 << endl;
    return 0;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

ll modPow(ll a, ll b, ll c) {
	if(b==0){return 1;}
	else{
		if(b % 2 == 1){
			return a * modPow(a,b-1,c) % c;
		}else{
			ll temp = modPow(a, b/2, c);
			return temp*temp%c;
		}
	}
}

int main(){
	int n,i,j;
	string s;
	cin>>n;
	cin>>s;
	int cnt1 = 0;
	for(i=0;i<s.size();i++){
		if(s[i] == '1'){cnt1++;}
	}
	
	ll bilModMin = 0, bilModPlus = 0;
	int pangkat = 0;
	ll bilBener = 0;

	for(i=n-1;i>=0;i--){
		if(s[i] == '1'){
			bilModPlus += modPow(2, pangkat, cnt1 + 1);
			bilModPlus %= (cnt1 + 1);

			if((cnt1 - 1) > 0){
				bilModMin += modPow(2, pangkat, cnt1 - 1);
				bilModMin %= (cnt1 - 1);
			}
			bilBener += (1LL<<pangkat);
			// printf("bilModMin: %lld bilModPlus: %lld\n",bilModMin, bilModPlus);
			// printf("i: %d bilBener: %lld\n",i, bilBener);
		}
		pangkat++;
		// printf("pangkat: %d bilBener: %lld\n",pangkat, bilBener);
	}

	// printf("bilModPlus: %lld bilModMin: %lld bilBener: %lld\n", bilModPlus, bilModMin,bilBener);

	pangkat = 0;
	vi list;
	for(i=n-1;i>=0;i--){
		ll bil;
		if(s[i] == '1')	{
			bil = bilModMin;
			int mod = cnt1 - 1;
			if(mod == 0){
				bil = 0;
				list.pb(0);
				continue;
			}
			bil -= modPow(2, pangkat, mod);
			bil %= (mod);
			if(bil < 0){bil += mod;}


		}else{
			bil = bilModPlus;
			int mod = cnt1 + 1;
			bil += modPow(2, pangkat, mod);
			bil %= mod;
		}
		// printf("i: %d bil: %lld\n",i, bil);
		pangkat++;
		int ans = 1;
		while(bil){
			int popcount = __builtin_popcount(bil);
			bil = bil % popcount;
			ans++;
		}
		list.pb(ans);
		// printf("%d\n",ans);
	}
	reverse(list.begin(), list.end());
	for(i=0;i<n;i++){
		printf("%d\n",list[i]);
	}
	
	return 0;
};

Measured memory_bytes: 4516
#include <stdio.h>
#include <math.h>

int main(){

    int H,W;

    while(true){
        scanf("%d%d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }
        for(int j=0;j<H;j++){
            for(int i = 0;i<W;i++){
                if((i+j)%2 == 0){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }


    return 0;
}



Measured memory_bytes: 2600
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int n;
int a[105000];

int main()
{
	cin >> n;
	int ai;
	for (int i = 0; i < n; i++) {
		cin >> ai;
		ai++;
		a[ai - 1]++;
		a[ai]++;
		a[ai + 1]++;
	}
	int  max = 0;
	for (int i = 0; i <= 100000; i++) {
		if (a[i] > max) {
			max = a[i];
		}
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;
using ll = long long;
const int INF = 100000;


int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll ans =0;
    ll num = 0;
    for(int i=0;i<(1<<(n-1));i++){
        num = s[0] - '0';
        for (int j = 0; j < n-1;j ++){
            if(i&(1<<j)){
                ans += num;
                num = 0;
            }
            num = num * 10 + s[j+1] - '0';
        }
        ans += num;
    }
    cout << ans << endl;
}



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

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 310, Mod = 1e9 + 7;
void pls(int &x, int y) {
	x += y;
	if (x >= Mod) x -= Mod;
}
bool vis[N << 1], flg[N << 1];
int f[N << 1][N][N], a[N << 1];
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n = gi<int>();
	for (int i = 1; i <= 2 * n; i++) a[i] = gi<int>();
	int cnt1 = 0, cnt2 = 0;
	for (int i = 1; i < 2 * n; i += 2) {
		if (a[i] == a[i + 1])
			cnt2++;
		else {
			if (a[i] > a[i + 1]) swap(a[i], a[i + 1]);
			if (a[i] == -1) cnt1++, flg[a[i + 1]] = 1;			
			else vis[a[i]] = vis[a[i + 1]] = 1;
		}
	}
	int m = 0;
	f[0][0][0] = 1;
	for (int i = 2 * n; i >= 1; i--)
		if (!vis[i]) {
			m++;
			if (!flg[i]) {
				for (int j = 0; j <= cnt1 + cnt2; j++)
					for (int k = 0; k <= cnt1; k++) {
						pls(f[m][j + 1][k], f[m - 1][j][k]);
						if (j) pls(f[m][j - 1][k], f[m - 1][j][k]);
						if (k) pls(f[m][j][k - 1], 1ll * k * f[m - 1][j][k] % Mod);
					}
			}
			else {
				for (int j = 0; j <= cnt1 + cnt2; j++)
					for (int k = 0; k <= cnt1; k++) {
						pls(f[m][j][k + 1], f[m - 1][j][k]);
						if (j) pls(f[m][j - 1][k], f[m - 1][j][k]);
					}
			}
		}
	int ans = f[m][0][0];
	for (int i = 1; i <= cnt2; i++)
		ans = 1ll * ans * i % Mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 227200
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,m,*ab = map(int,read().split())

m = iter(ab)

s1 = set()
s2 = set()
for a,b in zip(m,m):
    a -= 1
    b -= 1
    if a==0: s1.add(b)
    if a==n-1: s2.add(b)
    if b==0: s1.add(a)
    if b==n-1: s2.add(a)

#print(s1,s2,s1&s2)    

if len(s1&s2):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
    
    



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

using namespace std;

int main() {
	long long int N, M;
	cin >> N >> M;
	vector<string>A( N ), B( M );
	for( size_t i = 0; i < N; i++ ) {
		cin >> A[i];
	}
	for( size_t i = 0; i < M; i++ ) {
		cin >> B[i];
	}
	for( size_t i = 0; i <= N - M; i++ ) {
		for( size_t j = 0; j <= N - M; j++ ) {
			bool f = true;
			for( size_t a = 0; a < M; a++ ) {
				for( size_t b = 0; b < M; b++ ) {
					if( A[i + a][j + b] != B[a][b] ) {
						f = false;
					}
				}
			}
			if( f ) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
l = deque(sys.stdin.readlines())
n, m = (int(x) for x in l[0].split())
l.popleft()

from_1, to_n = set(), set()
for a, b in ((int(x) for x in l[i].split()) for i in range(m)):
    if a == 1: from_1.add(b)
    elif b == n: to_n.add(a)

print("POSSIBLE" if from_1 & to_n else "IMPOSSIBLE")


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;

	vector <int> num(N);
	int cnt = 0;
	bool aflag = false;
	for (int ii = 0; ii < N; ++ii){
		if (aflag){
			if (S[ii] == 'C'){
				cnt++;
			}
		}
		if (S[ii] == 'A'){
			aflag = true;
		} else {
			aflag = false;
		}
		num[ii] = cnt;
	}

	for (int ii = 0; ii < Q; ++ii){
		int l, r;
		cin >> l >> r;
		l--; r--;
		int ans = num[r] - num[l];
		cout << ans << "\n";
	}

	return 0;
}


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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;

bool isPossible(vector<int> &arr, int k, int p)
{
    ll count = 0;
    for(int i=0;i<arr.size();i++)
    {
        if(arr[i] >p)
            count += ( arr[i]) /p;
    }

    if(count >k)
        return false;

    return true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    vector<int> arr(n);

    int maxVal = 0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        maxVal = max(maxVal, arr[i]);
    }

    int start = 1;
    int end = maxVal;

    while(start <= end)
    {
        int mid = (start + end)/2;

        if(isPossible(arr,k,mid))
            end = mid -1;
        else
            start = mid +1;
        
        //cout<<mid<<" "<<start<<" "<<end<<endl;
    }

    cout<<start<<endl;

    return 0;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n);
    vector<int> mt(n),ans(n);
    in(mt);
    ll sum=0;
    for(int i=0;i<n;i++){
        if(i%2==0)sum+=(ll)mt[i];
        else sum-=(ll)mt[i];
    }
    ans[0]=sum;
    for(int i=n-1;i>=1;i--){
        if(i==n-1)ans[i]=2*mt[i]-ans[0];
        else ans[i]=2*mt[i]-ans[i+1];
    }
    out(ans);
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;

int main() {FIN
	
	ll i, j, n, c = 0;
	string s;
	cin >> n;
	cin >> s;
	vll rs(n + 1), gs(n + 1), bs(n + 1);
	for (i = 0; i < n; i++) {
		rs[i + 1] = (s[i] == 'R' ? rs[i] + 1 : rs[i]);
		gs[i + 1] = (s[i] == 'G' ? gs[i] + 1 : gs[i]);
		bs[i + 1] = (s[i] == 'B' ? bs[i] + 1 : bs[i]);
	}
	
	for (i = 1; i < n - 1; i++) {
		for (j = i + 1; j < n; j++) {
			if (s[i - 1] != s[j - 1]) {
				if (s[i - 1] == 'R') {
					if (s[j - 1] == 'G')
						c += (bs[n] - bs[j]) - (j + (j - i) <= n and s[j + (j - i) - 1] == 'B' ? 1 : 0);
					else
						c += (gs[n] - gs[j]) - (j + (j - i) <= n and s[j + (j - i) - 1] == 'G' ? 1 : 0);
				} else if (s[i - 1] == 'G') {
					if (s[j - 1] == 'R')
						c += (bs[n] - bs[j]) - (j + (j - i) <= n and s[j + (j - i) - 1] == 'B' ? 1 : 0);
					else
						c += (rs[n] - rs[j]) - (j + (j - i) <= n and s[j + (j - i) - 1] == 'R' ? 1 : 0);
				} else {
					if (s[j - 1] == 'G')
						c += (rs[n] - rs[j]) - (j + (j - i) <= n and s[j + (j - i) - 1] == 'R' ? 1 : 0);
					else
						c += (gs[n] - gs[j]) - (j + (j - i) <= n and s[j + (j - i) - 1] == 'G' ? 1 : 0);
				}
			}
		}
	}
	
	cout << c << "\n";
	
	return 0;
}


Measured memory_bytes: 3688
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        Double num = Double.parseDouble(str);
        Double Ans1 = Math.PI * num * num;
        Double Ans2 = 2 * Math.PI * num;
        String Ans1_str = String.format("%.5f", Ans1);
        String Ans2_str = String.format("%.5f", Ans2);
        System.out.println(Ans1_str+" "+Ans2_str);
    }
    
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using vve = vector<vector<Edge>>;

vi ans;
void dfs(vve &graph, int v)
{
    for(auto n : graph[v]) {
        int u = n.to;
        int w = n.weight;
        if(ans[u] != -1) continue;
        ans[u] = (ans[v] + w) % 2;
        dfs(graph, u);
    }
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vve graph(N);
    REP(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        --u; --v;
        graph[u].push_back(Edge(v, w));
        graph[v].push_back(Edge(u, w));
    }
    ans.assign(N, -1);
    ans[0] = 0;
    dfs(graph, 0);

    for(auto n : ans) {
        cout << n << endl;
    }

    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define ll long long
#define ull unsigned long long
#define MOD  1000000007
#define MAX  1e9
#define pb   push_back
#define F    first
#define S    second


int main() {
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		int a[n+1]={0};
		rep(i,n-1){
			int b;
			cin>>b;
			a[b]++;
		}
		for(int i=1;i<=n;++i){
			cout<<a[i]<<endl;
		}
		
	}
	
}

Measured memory_bytes: 4376
import java.util.*;

class Main {
	
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		int result = (X - A) - ((X - A) / B) * B;

		System.out.println(result);

	}

}

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

int distance(int a, int b){
  return (a-b)*(a-b);
}

int main() {
  int N, dist, sum =0, a, max =0;
  cin >> N;
  
  vector<int> x(N);
  
  vector<int> total;
  
  rep(i, N) cin>> x[i];
  
  for(int i=0;i<100;i++){
    for(int j=0;j<N; j++){
      sum += distance(i, x[j]);
    }  
    total.push_back(sum);
    //cout<<sum<<endl;
    sum = 0;
  }
  
  sort(total.begin(), total.end());
 
  cout<<total[0]<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

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

	int N; cin >> N;
	int X; cin >> X;

	int ans = 0;

	for (int i = 0;i < N;i++){
		int x; cin >> x;
		ans = gcd(ans,abs(X-x));
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

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

    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

    if(0 <= (y-r) && (y+r) <= H){
		if( 0 <= (x-r) && (x+r) <= W){
            printf("Yes\n");
		}
		else{
            printf("No\n");
		}
    }

    else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2672
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()

using namespace std;

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

    string s;
    cin >> s;

    if(s=="Sunny") cout << "Cloudy" << endl;
    if(s=="Cloudy") cout << "Rainy" << endl;
    if(s=="Rainy") cout << "Sunny" << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a,const void *b){
  return *(long*)a-*(long*)b;
}

int main(void){
  long N,A,B;
  scanf("%ld%ld%ld",&N,&A,&B);
  long h[N];

  for(long i = 0;i < N;i++) scanf("%ld",&h[i]);
  qsort(h,N,sizeof(long),compare_int);

  long left = 0,right = h[N-1];
  long mi = (left+right)/2;

  while(right-left > 1){
    mi = (left+right)/2;
    long cnt = 0;
    for(int i = N-1;i >= 0;i--){
      if(h[i]-mi*B > 0) cnt += (h[i]-mi*B+(A-B-1))/(A-B);
      else break;
    }
    if(cnt <= mi) right = mi;   //True
    else left = mi;             //False
  }

  printf("%ld\n",right);

  return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <ctime>
#include <assert.h>
using namespace std;

const unsigned long long BASE = (unsigned long long)(1e9 + 7);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter != vec.end(); iter++)

long long notFull[2001][2001];
long long full[2001][2001];
long long combine[2001][2001];

long long getFull(int ball, int box);
long long getNotFull(int ball, int box)
{
    if (notFull[ball][box] >= 0)
        return notFull[ball][box];
    else
    {
        long long sum = 0;
        if (combine[box][0] < 0)
        {
            vector<unsigned long long> comVec;
            comVec.push_back(1);
            FROM_0(i, box)
            {
                vector<unsigned long long> tmp;
                tmp.push_back(1);
                for (int j = 0; j < comVec.size() - 1; j++)
                {
                    tmp.push_back((comVec[j] + comVec[j + 1]) % BASE);
                }
                tmp.push_back(1);
                comVec = tmp;
            }
            for (int i = 0; i <= box; i++)
            {
                combine[box][i] = comVec[i];
            }
        }
        FROM_S(m, 1, box + 1)
        {
            sum = (sum + getFull(ball, m) * combine[box][m]) % BASE;
        }
        notFull[ball][box] = sum;
        return sum;
    }
}

long long getFull(int ball, int box)
{
    if (ball < box)
        return 0;
    if (full[ball][box] >= 0)
        return full[ball][box];
    else
    {
        long long ret = getNotFull(ball - box, box);
        full[ball][box] = ret;
        return ret;
    }
}


int main()
{
    int s;
    cin >> s;
    FROM_0(i, 2001)
    {
        FROM_0(j, 2001)
        {
            combine[i][j] = -1;
            if (i < j || i == 0)
                full[i][j] = 0;
            else if (i == j || j == 1)
                full[i][j] = 1;
            else
                full[i][j] = -1;
            if (i == 1)
                notFull[i][j] = j;
            else if (i == 0)
                notFull[i][j] = 1;
            else if (j == 1)
                notFull[i][j] = 1;
            else
                notFull[i][j] = -1;
        }
    }
    int box = s / 3;
    if (box == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    int rest = s % 3;
    long long result = 0;
    while (box > 0)
    {
        result = (result + getNotFull(rest, box)) % BASE;
        rest += 3;
        box--;
    }
    cout << result << endl;

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  int n, k;
  cin >> n >> k;
  vi v(n);
  rep(i,n) cin >> v[i];
  int ans = 0;
  for(int x = 0; x <= min(n,k); x++) { // x = 拾う個数
    int y = min(k-x,x); // y = 捨てる個数の最大値
    for(int l = 0; l <= x; l++) { // l = 左から取る個数
      int r = x-l;
      vi j;
      rep(i,l) j.push_back(v[i]);
      rep(i,r) j.push_back(v[n-i-1]);
      sort(rall(j));
      rep(i,y) {
        if(j.back() < 0) j.pop_back();
        else break;
      }
      int tot = 0;
      rep(i,sz(j)) tot += j[i];
      ans = max(ans, tot);
    }
  }
  cout << ans << endl;
}

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

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    int *a = new int[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    int *pre = new int[n];
    pre[0] = 0;
    int maxi = 0;
    for(int i = 1 ; i< n ; i++){
        if(a[i-1] >= a[i]){
            pre[i] = pre[i-1] + 1;
            maxi = max(maxi , pre[i]);
        }
        else pre[i] = 0;
    }
    cout<<maxi<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
cnt = [0 for i in range(N+1)]

for x in range(1, 110):
    for y in range(1, 110):
        for z in range(1, 110):
            a = x*x + y*y + z*z +z*x + z*y + x*y
            if a <= N:
                cnt[a] += 1

for i in range(1, N+1):
    print(cnt[i])

Measured memory_bytes: 9428
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[200000], b[200000], bit[262145];
void add(int i, int x) {
	while (i <= n) bit[i] += x, i += i & -i;
}
int sum(int i) {
	int ret = 0;
	while (i > 0) ret += bit[i], i -= i & -i;
	return ret;
}
int sum(int l, int r) {
	return sum(r - 1) - sum(l - 1);
}
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]), b[i] = a[i];
	sort(b, b + n);
	long long ret = 0;
	for(int i = 0; i < n; i++) {
		int ptr = lower_bound(b, b + n, a[i]) - b; add(ptr + 1, 1);
 		ret += sum(ptr + 2, n + 1);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 5604
import java.util.*;
class Main {
  public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   int W = sc.nextInt();
   int H = sc.nextInt();
   int x = sc.nextInt();
   int y = sc.nextInt();
   int r = sc.nextInt();
   if ( x-r<0 || y-r<0 || x+r>W || y+r>H ) {
     System.out.println("No");
   }else{
     System.out.println("Yes");
   }
  }
}


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

#define pii pair<int, int>
#define mp make_pair

const int maxN = 1e6 + 10, mod = 1e9 + 7, I = (mod + 1) / 2;
const int mv[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

int n, m, s, ans, clk;
int v1[maxN + 1], v2[maxN + 1];
int id1[105], id2[105], w, h;
int t1[105], t2[105];
int val[105][105], vis[105][105], dep[105][105];

map<pii, bool> f;

inline void update(int &x, int y) { x = x + y >= mod ? x + y - mod : x + y; }

inline void bfs(int xs, int ys)
{
	clk ++;
	queue<pii> q;
	q.push( mp(xs, ys) ); 
	vis[xs][ys] = clk; dep[xs][ys] = 0;
	while(!q.empty())
	{
		int x = q.front().first, y = q.front().second; q.pop();
		for(int i = 0; i < 4; i++)
		{
			int nx = x + mv[i][0], ny = y + mv[i][1];
			if(nx < 1 || ny < 1 || nx > w || ny > h) continue;
			if(vis[nx][ny] != clk && val[nx][ny])
			{
				vis[nx][ny] = clk;
				dep[nx][ny] = dep[x][y] + 1;
				q.push( mp(nx, ny) );
			}
		}
	}
}

int main()
{
	scanf("%d %d", &n, &m);
	scanf("%d", &s);
	for(int i = 1; i <= s; i++)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		x ++, y ++;
		v1[x] ++, v2[y] ++;
		f[ mp(x, y) ] = true;
	}

	int sum = 0;
	for(int i = 1; i < n; i++)
	{
		update(sum, v1[i]);
		if(v1[i] || v1[i + 1]) continue;
		int a = (1ll * i * m - sum) % mod, b = (1ll * (n - i) * m - (s - sum)) % mod;
		update(ans, 1ll * a * b % mod);
	}
	sum = 0;
	for(int i = 1; i < m; i++)
	{
		update(sum, v2[i]);
		if(v2[i] || v2[i + 1]) continue;
		int a = (1ll * n * i - sum) % mod, b = (1ll * n * (m - i) - (s - sum)) % mod;
		update(ans, 1ll * a * b % mod);
	}

	int l = 1, r;
	while(l <= n)
	{
		r = l;
		while(!v1[r] && r <= n) r ++;
		w ++;
		if(l == r) id1[w] = r, t1[w] = 1, l = r + 1;
		else id1[w] = r - 1, t1[w] = r - l, l = r;
	}
	l = 1, r;
	while(l <= m)
	{
		r = l;
		while(!v2[r] && r <= m) r ++;
		h ++;
		if(l == r) id2[h] = r, t2[h] = 1, l = r + 1;
		else id2[h] = r - 1, t2[h] = r - l, l = r;
	}

	for(int i = 1; i <= w; i++)
		for(int j = 1; j <= h; j++)
			if(f.find( mp(id1[i], id2[j]) ) != f.end()) val[i][j] = 0;
			else val[i][j] = 1ll * t1[i] * t2[j] % mod;

	int res = 0;
	for(int i = 1; i <= w; i++)
		for(int j = 1; j <= h; j++)
		{
			if(!val[i][j]) continue;
			bfs(i, j);
			for(int k = 1; k <= w; k++)
				for(int t = 1; t <= h; t++)
					update(res, 1ll * dep[k][t] * val[k][t] % mod * val[i][j] % mod);
		}
	update(ans, 1ll * res * I % mod);

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


Measured memory_bytes: 4060
from itertools import product
 
N = int(input())
S = input()
 
cnt = 0
for i, j, k in product("0123456789", repeat=3):
    try:
        x = S.index(i)
        y = S.index(j, x + 1)
        z = S.index(k, y + 1)
    except:
        continue
    cnt += 1
 
print(cnt)

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


int main() {
  int ans = 0;
  rep(i,3){
    char s;
    cin >> s;
    if(s == '1'){
      ans++;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<vector>

using namespace std;

vector<int> v;
vector<int> vodd;
const int N = 1000001;

int dp[N];
int dpodd[N];

void dodp(int arr[], vector<int>& v) {
    for (int i = 0; i < N; ++i) {
        arr[i] = 1000;
    }
    arr[0] = 0;

    for (int vi : v) {
        for (int i = 0; i < N; ++i) {
            if (i - vi >= 0 && arr[i - vi] != 1000) {
                arr[i] = min(arr[i], arr[i - vi] + 1);
            }
        }
    }
}

int main() {
    v.push_back(1);
    vodd.push_back(1);
    int tri = 1;
    int i = 2;
    while(v.back() <= 1000000 ) {
        tri += i;
        int tmp = v.back() + tri;
        v.push_back(tmp);
        if (tmp % 2 == 1) vodd.push_back(tmp);
        ++i;
    }
    // v.size() = 181

    dodp(dp, v);
    dodp(dpodd, vodd);

    // for (int i = 0; i < N; ++i) {
    //     cout << dpodd[i] << " ";
    // }
    // cout << endl;
    while(1) {
        int n;
        cin >> n;
        if (n == 0) break;
        cout << dp[n] << " " << dpodd[n] << endl;
    }
}



Measured memory_bytes: 10952
#include<bits/stdc++.h>
int main()
{
    int n ,t ,max1=-1 ,min1=2000000000;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&t);
        if(t > max1)
            max1 = t;
        if(t < min1)
            min1 = t;
    }
    printf("%d",max1-min1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
vector<vector<int>> tree(200010, vector<int> ());
vector<ll> ans(200010, 0ll);
vector<bool> vis(200010, 0);
int n, q, a, b;
void dfs(int v){
	vis[v]=1;
	for (auto u : tree[v]) if (!vis[u]){
		ans[u]+=ans[v];
		dfs(u);
	}
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>n>>q;
	for (int i=0; i<n-1; ++i){
		cin>>a>>b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	while(q--){
		cin>>a>>b;
		ans[a]+=b;
	}
	dfs(1);
	for (int i=1; i<=n; ++i) cout<<ans[i]<<" ";
	return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b == c + d) {
    cout << "Balanced" << endl;
  } else if (a + b > c + d) {
    cout << "Left" << endl;
  } else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo

@mt
def slv(N):
    c = defaultdict(list)
    for i in range(1, N+1):
        s = str(i)
        c[int(s[0])*10+int(s[-1])].append(s)
    ans = 0
    for i, j in product(range(1, 10), repeat=2):
        a = len(c[10*i+j])
        b = len(c[10*j+i])
        ans += a * b

    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


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

#pragma region
typedef long long ll;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define rep(i, begin, end)                              \
    for (__typeof(end) i = (begin) - ((begin) > (end)); \
         i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define REP(i, j) rep(i, 0, j)
#define testcase \
    int _;       \
    cin >> _;    \
    while (_--)
#define io                            \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    if (fopen("./input.txt", "r")) freopen("./input.txt", "r", stdin);
#define en '\n'
#pragma endregion

int main() {
    io;
    int h, w, k;
    cin >> h >> w >> k;
    char c;
    int arr[h][w];
    REP(i, h) REP(j, w) cin >> c, arr[i][j] = (c == '.' ? 0 : 1);
    int res = 0;
    REP(i, (1 << h) - 1)
    REP(j, (1 << w) - 1) {
        int kk = 0;
        REP(a, h)
        REP(b, w)
        if (!((i >> a) & 1) and !((j >> b) & 1) and arr[a][b]) kk++;
        if (kk == k) res++;
    }
    cout << res << en;
    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<vector>
#include<map>
#include<list>

using namespace std;

int main() {
  long long n,a,b,ans,rem;
  cin >> n >> a >> b;
  ans = n / (a+b) * a;
  rem = n % (a+b);
  ans += min(rem,a);
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class MyClass
{
    static void Main(string[] args)
    {
        int q =int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);
            int step = 0;
            while (n >= 10)
            {
                int max = 0;
                for (int j = 1; j < str.Length; j++)
                {
                    int a = (int)Math.Floor(n / Math.Pow(10.0, (double)j));
                    int b = n - a * (int)Math.Pow(10.0, (double)j);
                    int c = a * b;
                    if (max < c)
                    {
                        max = c;
                    }
                }
                n = max;
                step++;
            }
            Console.WriteLine(step);
        }
    }
}


Measured memory_bytes: 19940
# 入力
S = gets.chomp

sum = 0
n = S.size - 1
# bit全探索を行う
(1 << n).times do |i|
  expr = []
  # S[0]は最初の文字なのでここで入れておけばいい
  expr = S[0]
  n.times do |j|
    if i[j] == 1
      # i[j]が1のときS[j]とS[j+1]の間に'+'をつける
      expr = expr + '+' + S[j+1]
    else
      # i[j]が0のときは'+'をつけない'
      expr = expr + S[j+1]
    end
  end
  # jループ終了時点でexprは完成しているので、
  # それを+でsplitする(ここまで文字配列)
  # それをinteger型にmapして、それらを集計して足し合わせたものを、sumに加える
  sum = sum + expr.split('+').map(&:to_i).inject(:+)
end

puts sum

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define ff first
#define ss second
 
ll mod=1e9+7;
ll maxs=1e5+2;
ll mx=INT_MAX;
ll mn=INT_MIN;

int main()
{
    ll n,m;
    cin>>n>>m;

    string a[n];
    ll i,j;
    char ch;
    ll dp[n][m];
    memset(dp,0,sizeof(dp));
    
    for(i=0;i<n;i++)
        cin>>a[i];
    
    for(i=0;i<m;i++)
    {
        if(a[0][i]=='#')
            dp[0][i]=0;
        else if(i==0)
            dp[0][0]=1;
        else
            dp[0][i]=dp[0][i-1];
    }
            
    for(i=0;i<n;i++)
    {
        if(a[i][0]=='#')
            dp[i][0]=0;
        else if(i==0)
            dp[0][0]=1;
        else
            dp[i][0]=dp[i-1][0];
    }
        
    for(i=1;i<n;i++)
    {
        for(j=1;j<m;j++)
        {
            if(a[i][j]=='.')
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            else
                dp[i][j]=0;
        }
    }
    
    cout<<dp[n-1][m-1];
    
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector< ll > vt(N+1, 0LL);
  std::vector< ll > vx(N+1, 0LL);
  std::vector< ll > vy(N+1, 0LL);
  for (ll i = 1; i <= N; i++) {
    std::cin >> vt[i] >> vx[i] >> vy[i];
  }

  bool judge = true;
  for (ll i = 1; i <= N; i++) {
    ll time = vt[i] - vt[i-1];
    ll dist = std::abs(vx[i] - vx[i-1]) + std::abs(vy[i] - vy[i-1]);
    if (time < dist) judge = false;
    if (time % 2 != dist % 2) judge = false;
  }

  if (judge) print("Yes");
  else print("No");

  return 0;
}


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

int main()
{
    string search_string = "ABC";
    int N; string S; cin >> N >> S;

    int ans = 0;
    rep(i, N - 2) {
        if (S.substr(i, 3) == search_string) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using std::min; using std::max;
using std::swap; using std::sort;
typedef long long ll;

template<typename T>
void read(T &x) {
	int flag = 1; x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') flag = -flag; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= flag;
}

const int _ = 4e2 + 10, P = 1e9 + 7;
int n, m, a[_], b[_], f[_][_], pw[_][_], p[_][_];

int main () {
	read(n), read(m);
	for(int i = 1; i <= n; ++i) read(a[i]);
	for(int i = 1; i <= n; ++i) read(b[i]);
	for(int i = 1; i <= 400; ++i) {
		p[i][0] = 1;
		for(int j = 1; j <= m; ++j)
			p[i][j] = 1ll * p[i][j - 1] * i % P;
	}
	f[0][0] = 1;
	for(int i = 1; i <= n; ++i) {
		int tmp = 1;
		for(int j = a[i]; j <= b[i]; ++j) tmp = 1ll * tmp * j % P;
		pw[i][0] = b[i] - a[i] + 1;
		for(int k = 1; k <= m; ++k)
			for(int j = a[i]; j <= b[i]; ++j)
				(pw[i][k] += p[j][k]) %= P;
	}
	for(int i = 1; i <= n; ++i)
		for(int j = 0; j <= m; ++j)
			for(int k = 0; k <= j; ++k)
				(f[i][j] += 1ll * f[i - 1][j - k] * pw[i][k] % P) %= P;
	printf("%d\n", f[n][m]);
	return 0;
} 


Measured memory_bytes: 2048
s = gets.chomp!
A, B, K = s.split.map(&:to_i)

(0...K).each do |i|
  if i % 2 == 0
    if A % 2 == 1
      A -= 1
    end
    A = A / 2
    B += A
  else
    if B % 2 == 1
      B -= 1
    end
    B = B / 2
    A += B
  end
end

puts A.to_s + ' ' + B.to_s


Measured memory_bytes: 1788
#include<stdio.h>
int main(void){
  int n,m,h[100001],a[100001],b[100001],i,j,c[100001],d[100001],e;
  e=0;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  for(i=0;i<m;i++){
    scanf("%d %d",&a[i],&b[i]);
    /*printf("%d %d\n",a[i],b[i]);*/
  }
  for(i=1;i<=n;i++){
    c[i]=1;
    d[i]=0;
  }
  for(i=0;i<m;i++){
    if(h[a[i]-1]>=h[b[i]-1]){
      c[a[i]]=1;
      d[b[i]]=1;
    }if(h[a[i]-1]<=h[b[i]-1]){
      c[b[i]]=1;
      d[a[i]]=1;
    }
    /*printf("%d\n",d[4]);*/
  }
  for(i=1;i<=n;i++){
    /*printf("%d\n",d[i]);*/
    if(d[i]==0){
      e++;
    }
  }
  printf("%d\n",e);
  return 0;
}    


Measured memory_bytes: 3288
a, b = [int(i) for i in input().split()]

def calc(x, y):
    if x < 0:
        return -1
    if x > 9:
        return -1
    if y < 0:
        return -1
    if y > 9:
        return -1
    return x * y

print(calc(a, b))


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{for(T&x:v)i>>x;return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;for(T&x:v)s<<' '<<x;return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}

const int MX = 2505, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int n;
int a[MX];
bitset<MX> dp[MX];

int main() {
  scanf("%d",&n);
  rep(i,n) scanf("%d",&a[i]);
  int sum = 0;
  rep(i,n) sum += a[i];
  dp[0][0] = 1;
  rep(i,n) {
    drep(j,MX) {
      if (j+a[i] < MX) {
        dp[j+a[i]] |= dp[j];
      }
      dp[j] |= dp[j]<<a[i];
    }
  }
  int ans = INF;
  rep(i,MX)rep(j,MX) if (dp[i][j]) {
    int now = max({i,j,sum-i-j});
    mins(ans,now);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4028
K, N = gets.split.map(&:to_i)
As = gets.split.map(&:to_i)
min_distance = 100000000000000000000000000000
N.times do |n|
  dis = 0
  if n == 0
    dis = As[-1] - As[0]
  else
    dis = K - As[n] + As[n - 1]
  end
  if dis < min_distance
    min_distance = dis
  end
end
puts min_distance

Measured memory_bytes: 17412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ESP 1e-5

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
	cin >> a[i];
    }
    
    for(int i = 0; i + k < n; i++){
	if(a[i] < a[i + k]){
	    cout << "Yes" << endl;
	}else{
	    cout << "No" << endl;
	}
    }

    return 0;
}


Measured memory_bytes: 4048
N = int(input())
S = input()
l = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans = ''
for i in range(len(S)):
    a = l.index(S[i])+N
    if a > 25:
        ans += l[a-26]
    else:
        ans += l[a]
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 0;
        String[] week = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
        for(int i=0; i<week.length; i++) {
            if(s.equals(week[i])) System.out.println(i+1);
        }
    }
}

Measured memory_bytes: 35548
#include<iostream>
    #include<vector>
    #include<algorithm>
    using namespace std;
     
    int main(){
        long N;
        vector<long long> sunuke;
        vector<long long> candidate;
        cin >> N;
        for(int i=0;i<N;i++){
            long long baf;
            cin >> baf;
            sunuke.push_back(baf);
            candidate.push_back((baf-(i+1)));
        }
        sort(candidate.begin(),candidate.end());
        long long b = 0;
        for(int i=0;i<N;i++){
            b+=abs(sunuke[i]-(candidate[(N-1)/2]+(i+1)));
        }
        cout << b << endl;
        return 0;
    }

Measured memory_bytes: 3692
import math
def digit_num(N):
    if N < 10:
        return 1
    return 1 + digit_num(N // 10)

N = int(input())
ans = 15
for i in range(1, int(math.sqrt(N)) + 1):
    if N % i == 0:
        ans = min(ans, max(digit_num(i), digit_num(N // i)))
        
print(ans)

Measured memory_bytes: 3060