akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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

int main() {

	string S;
	cin >> S;

	ll N = S.size();

	vector<ll> a(N + 1);
	repn(i, N) a[i] = S[i - 1] - '0';

	vector<vector<ll>> dp(2*N + 1, vector<ll>(2 * N + 1, 0));

	dp[0][0] = 1;

	ll b = 0;

	repn(i, N) {
		b += a[i];

		for (ll j = max(b - i,0); j <= b; j++) {
			if (j > 0) { dp[i][j] += dp[i - 1][j - 1]; }
			dp[i][j] += dp[i - 1][j];


			dp[i][j] %= MOD;

			//cout << i << j << dp[i][j] << endl;
		}
	}

	for (ll i = N + 1; i <= 2*N; i++) {
		for(ll j=max(b+i-2*N,0); j<=b; j++) {
			if (j > 0) { dp[i][j] += dp[i - 1][j - 1]; }
			dp[i][j] += dp[i - 1][j];


			dp[i][j] %= MOD;

			//cout << i << j << dp[i][j] << endl;
		}
	}

	cout << dp[2 * N][b];
	
	
	system("PAUSE");
}


Measured memory_bytes: 125688
#include <stdio.h>
int main()
{	
	int i, j, k;
	int build[4][3][10];
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 3; j++)
		{
			for(k = 0; k < 10; k++)
			{
				build[i][j][k] = 0;
			}	
		}
	}

	int n = 0;
	scanf("%d", &n);
	while(n--)
	{
		int b, f, r, v;
		scanf("%d %d %d %d", &b, &f, &r, &v);
		build[b-1][f-1][r-1] += v;
		 
	}
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 3; j++)
		{
			for(k = 0; k < 10; k++)
			{
				printf(" %d", build[i][j][k]);
			}
			printf("\n");	
		}
		if(i != 3)
		{
			printf("####################\n"); 
		}
	}
	return 0;
		
}


Measured memory_bytes: 2600
import bisect

N = int(input())
A = [int(input()) for i in range(N)]

def lis(S):
    from bisect import bisect_right
    L = [S[0]]

    for s in S[1:]:
        if s >= L[-1]:
            L.append(s)
        else:
            L[bisect_right(L, s)] = s
    return len(L)

print(lis(A[::-1]))

Measured memory_bytes: 15216
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    mod_arr = []
    a = 1
    while True:
        _ = (a*A)%B
        if _ == C:
            TF = 'YES'
            break
        elif _ in mod_arr:
            TF = 'NO'
            break
        else:
            mod_arr.append(_)
            a+=1
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
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 dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())

int L[100010] = { 0 };
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin >> n >> m;
    
    for (int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        
        ++r;
        L[l]++;
        L[r]--;
    }
    for (int i = 1; i <= n; ++i) {
        L[i+1] += L[i];
    }
    int ans = 0;
    for (int i = 1; i <= n ; ++i) {
        if (L[i] == m) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    int n, m; cin >> n >> m;
    vector<int> T(n);
    vector<vector<int>> S(2);
    loop (n, i) cin >> T[i];
    loop (m, i) {
        int v; cin >> v;
        loop (v, j) {
            S[0].push_back(i%2);
            S[1].push_back((i+1)%2);
        }
    }

    int ans = 1<<29;
    loop (2, i) {
        int tpop = 0, spop = 0;
        for (int v : T) tpop += v;
        for (int v : S[i]) spop += v;
        if (tpop != spop) continue;

        int c = tpop < (n - tpop);
        int ti = 0, si = 0, cnt = 0;
        while (ti < n && si < n) {
            while (ti < n && T[ti] != c) ti++;
            while (si < n && S[i][si] != c) si++;
            cnt += abs(ti - si);
            ti++, si++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3152
s = gets.chomp
t = gets.chomp

ns = s.size
nt = t.size

ss = []
(ns - nt + 1).times do |i|
    nt.times do |j|
        break if s[i + j] != "?" && s[i + j] != t[j]
    end or next
    x = s.clone
    x[i, nt] = t
    x.gsub!("?", "a")
    ss << x
end

puts ss.empty? ? "UNRESTORABLE" : ss.min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>x>>a>>b>>n;
    rep(i,n){
        cin>>s;
        if(s[0]=='n')x+=a;
        else if(s[0]=='t')x+=b;
        else x=0;
        x=max(x,0LL);
    }
    Cout(x);
    return 0;
}


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

ll p[MX][MX];

int main(){
  int h,w; scanf("%d %d", &h, &w);
  bool bck = false;

  for(int i=1;i<=h;i++){
    string s; cin >> s;
    for(int j=0;j<w;j++){
      if(i==1){ 
        if(s[j] == '.') p[1][j+1] = 1;
        else{
          for(int k=j;k<w;k++){
            p[1][k+1] = 0;
          }
          break;
        }
      }else{
        if(s[j] == '.'){
          if(j == 0){
            if(bck) p[i][1] = 0;
            else p[i][1] = 1;
          }
          else  p[i][j+1] = p[i-1][j+1] + p[i][j];
        }else{
          p[i][j+1] = 0; 
          if(j==0) bck = true;
        }
      }
      if(p[i][j+1] > 1000*1000*1000+7) p[i][j+1] =  p[i][j+1] % (1000*1000*1000 + 7);
    }
  }
  cout << p[h][w];
  return 0;
}


Measured memory_bytes: 8064
// ABC043 A - キャンディーとN人の子供イージー

#include <stdio.h>

int main(void) {

    int N;
    int i = 0;
    int result = 0;

    // input
    scanf("%d", &N);

    for (i = 1; i <= N; i++) {
        result += i;
    }

    // output
    printf("%d\n", result);

    return 0;
}

Measured memory_bytes: 128
n,m,r,t,i,j,k,a[100][100],b[100][100];
main(){
    long long c[100][100]={};
    scanf("%d%d%d",&n,&m,&r);
        for(i=0;i<n;i++)
            for(j=0;j<m;j++)
                scanf("%d",&a[i][j]);
        for(i=0;i<m;i++)
            for(j=0;j<r;j++)
                scanf("%d",&b[i][j]);
    for(i=0;i<n;i++)
        for(j=0;j<r;j++){
            for(k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
            printf("%lld%s",c[i][j],j==r-1?"\n":" ");
        }
}

Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
void solve() {
	var(int, n);
	vec(int, l, n * 2);
	sort(all(l));
	int ans = 0;
	rep(i, 0, n) {
		ans += min(l[i * 2], l[i * 2 + 1]);
	}
	print(ans);
}
int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 #define int long long
using namespace std;
int ans,many[300005],a[300005];
int C(int x,int y){
    if(x < 0 || y < 0 || y > x )return 0;
    int res = 1;
    for(int i=x, j = 0; j < y; i--,j++)
        res*=i;
    int domn = 1;
    for(int i =1; i<=y; i++)
        domn*=i;
    return(res/domn);
}
 main()
{
    int n;
    cin>>n;
    for(int i =0; i<n; i++){
        cin>>a[i];
        many[a[i]]++;
    }

    for(int i =0; i<=n; i++){
        ans+=C(many[i],2);
    }
    for(int i =0; i<n; i++){
        int cur = ans;
        cur-=C(many[a[i]],2);
        many[a[i]]--;
        cur+=C(many[a[i]],2);
        many[a[i]]++;
        cout<<cur<<endl;
    }






    return 0;
}



Measured memory_bytes: 6144
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {1,0,-1,0};

string num2str(int num){
	string res="";
		int multi = num / 1000;
		
		if(multi > 1) res.push_back(multi+'0');
		if(multi >= 1) res.push_back('m');
		num %= 1000;

		multi = num / 100;
		if(multi > 1) res.push_back(multi+'0');
		if(multi >= 1) res.push_back('c');
		num %= 100;

		multi = num / 10;
		if(multi > 1) res.push_back(multi+'0');
		if(multi >= 1) res.push_back('x');
		num %= 10;

		multi = num / 1;
		if(multi > 1) res.push_back(multi+'0');
		if(multi >= 1) res.push_back('i');
		num %= 1;

	return res;
}

int main(){
	string str1,str2;
	int n;
	cin >> n;
	for(int t=0;t<n;t++){
		cin >> str1;
		cin >> str2;
		//mcxi,1000,100,10,1
		int sum = 0;
		int multi = 1;
		for(int i=0;i<str1.size();i++){
			if(isdigit(str1[i])){
				multi = str1[i] - '0';
			}
			else{
				if(str1[i] == 'm') sum += multi * 1000;
				if(str1[i] == 'c') sum += multi * 100;
				if(str1[i] == 'x') sum += multi * 10;
				if(str1[i] == 'i') sum += multi * 1;
				multi = 1;
			}
		}

		multi = 1;
		for(int i=0;i<str2.size();i++){
			if(isdigit(str2[i])){
				multi = str2[i] - '0';
			}
			else{
				if(str2[i] == 'm') sum += multi * 1000;
				if(str2[i] == 'c') sum += multi * 100;
				if(str2[i] == 'x') sum += multi * 10;
				if(str2[i] == 'i') sum += multi * 1;
				multi = 1;
			}
		}

		printf("%s\n",num2str(sum).c_str());
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int N, A, B; cin >> N >> A >> B;
	cout << min(A*N, B) << 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 __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

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

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


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

 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
int32_t main(){
    IOS;
    ll a,b,c,d;
    cin >> a>> b >> c >> d;
    // cout <<
    ll mx =  max(a*c,a*d);
    ll mx2 =  max(b*c,b*d);
    cout << max(mx,mx2)<<"\n";
    

} 

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		int[] n = new int[N + 1];
		String ans = "No";
		int c4 = 0, c2 = 0;

		for (int i = 0; i < N; i++) {
			n[i] = sc.nextInt();
			if (n[i] % 4 == 0) {
				c4++;
			} else if (n[i] % 2 == 0) {
				c2++;
			}
		}

		if (c2 == N) {
			ans = "Yes";
		} else {
			if (c2 >= 2) {
				N -= c2;
				if ((N % 2) == 0 && (N / 2) <= c4) {
					ans = "Yes";
				} else if ((N % 2) != 0 && (c4 * 2) >= (N + 1)) {
					ans = "Yes";
				}
			} else {
				if ((N % 2) == 0 && (N / 2) <= c4) {
					ans = "Yes";
				} else if ((N % 2) != 0 && (c4 * 2) >= (N - 1)) {
					ans = "Yes";
				}
			}
		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 49704
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000000000000000
#define MOD 100000000 

void func()
{
   ll l,r,d;
   cin>>l>>r>>d;
   ll ans=(r/d) - (l-1)/d;
   cout<<ans<<"\n"; 
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 3632
#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 vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
using namespace std;
using ll = long long;

int main(){
    int ans=0,n,k;
    cin>>n>>k;
    vector<int> vec(n);
    vec_input(vec);
    sort(all(vec));
    rep(i,k){
        ans+=vec[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0){
		solve(n);
	    }
	}
    }

    static void solve(int n){
	int w = kbd.nextInt();
	int h = kbd.nextInt();
	boolean[][] field = new boolean[w][h];
	putTree(field, n);
	int s = kbd.nextInt();
	int t = kbd.nextInt();
	int maxTree = 0;
	int tree = 0;

	int i, j;
	for(i=0; i+s-1<w; i++){
	    for(j=0; j+t-1<h; j++){
		//System.out.println(i+" "+j+" "+s+" "+t);
		tree = search(field, i, s, j, t);
		if(tree > maxTree) maxTree = tree;
	    }
	}
	System.out.println(maxTree);
    }

    static void putTree(boolean[][] field, int n){
	while(n>0){
	    int x = kbd.nextInt();
	    int y = kbd.nextInt();
	    field[x-1][y-1] = true;
	    n--;
	}
    }

    static int search(boolean[][] field, int bi, int s, int bj, int t){
	int tree=0;
	int x, y; 
       	for(x=bi; x-bi<s; x++){
	    for(y=bj; y-bj<t; y++){
		//System.out.println(x+" "+y+" *"+bi+" "+bj+" *"+s+" "+t);
		if(field[x][y]) {
		    tree++;
		    //System.out.println((x+1)+" "+(y+1));
		}
	    }
	}
	//System.out.println(tree);
	return tree;
    }
}

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

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

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

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

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

int N, W;
int v[111], w[111];
int dp[111][11111];

int main() {
    cin >> N >> W;
    rep (i, N) { cin >> v[i] >> w[i]; }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if (j >= w[i]) {
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 7416
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;


class UF{
    public:
    int N;
    vector<int> par;
    vector<int> rank;
    vector<int> diff_weight;
    UF(int N=1){
        par.resize(N);
        diff_weight.resize(N);
        rank.resize(N);
        for(int i=0; i<N; i++) par[i] = i, rank[i] = diff_weight[i] = 0;
    }
    int root(int x){
        if(par[x]==x) return x;
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }
    int weight(int x){
        root(x);
        return diff_weight[x];
    }
    int diff(int x, int y){
        return weight(y) - weight(x);
    }
    bool isSame(int x, int y){
        return root(x)==root(y);
    }

    bool merge(int x, int y, int w=0){
        w += weight(x);
        w -= weight(y);
        int rx = root(x);
        int ry = root(y);
        if(rx==ry) return false;
        if(rank[rx]<rank[ry]) swap(rx, ry), w=-w;
        if(rank[rx]==rank[ry]) ++rank[rx];
        par[ry] = rx;
        diff_weight[ry] = w;
        return true;
    }
};
signed main(){
    int N, q; cin>>N>>q;
    UF uf(N);
    for(long long i=0; i<q; i++){
        int x; cin>>x;
        if(x==0){
            int x, y, z;
            cin>>x>>y>>z;
            uf.merge(x, y, z);
        }
        else{
            int x, y; cin>>x>>y;
            if(uf.isSame(x, y)) cout << uf.diff(x, y) << endl;
            else cout << "?" << endl;;
        }
    }
    return 0;
}


Measured memory_bytes: 3884
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-26 20:23:33
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int a, b;
    cin >> a >> b;

    if (a + b < 10) cout << a+b << endl;
    else cout << "error" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> pi;
#define inf 1000000000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define ss second
#define pb push_back
//#define mp make_pair

int a, b, h;

int main(){

cin >> a >> b >> h;
cout << (a+b)*h/2;



return 0;}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int n,t;
	cin >> n >> t;
	vector<pair<int,int> > arr(n);

	for(int i=0 ; i<n ; i++)
		cin >> arr[i].first >> arr[i].second;

	sort(arr.begin() , arr.end());

	for(int i=0  ; i<n ; i++)
	{
		if(arr[i].second <= t)
		{
			cout << arr[i].first;
			return 0;
		}
	}
	cout << "TLE";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(void){
    int K,S,cnt=0;
    cin>>K>>S;
 
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            if(i+j<=S&&S-i-j<=K)
                cnt++;
        }
    }
 
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool bubbleSort(string c[], int& n){
	string hold;
	for(int i=0;i<n;i++){
		for(int j=n-1;j>=1;j--){
			if(c[j][1]<c[j-1][1]){
				hold = c[j-1];
				c[j-1] = c[j];
				c[j] = hold;
			}
		}
	}
	return true;
}

bool selectionSort(string c[], int& n){
	string hold;
	int i,j;
	for(i=0;i<n;i++){
		int minj = i;
		for(j=i;j<n;j++){
			if(c[j][1] < c[minj][1]){ minj = j; } //string[1] is '0' to '9'
		}
		if(i!=minj){
			hold = c[i];
			c[i] = c[minj];
			c[minj] = hold;
		}
	}
	return true;
}

void output_arrayString(string c[], int&n){
	for(int i=0;i<n;i++){
		cout << c[i];
		if(i+1==n){
			cout << endl;
		} else {
			cout << ' ';
		}
	}
}

bool isSameArrayString(string c1[], int n1, string c2[], int n2){
	if(n1!=n2){
		return false;
	} else {
        for(int i=0;i<n1;i++){
			if(c1[i]!=c2[i]){
				return false;
			}
        }
	}
	return true;
}

int main(){
	int n;
	cin >> n;
	string cs1[n],cs2[n];
	for(int i=0;i<n;i++){
		cin >> cs1[i];
		cs2[i] = cs1[i];
	}

	bubbleSort(cs1, n);
	selectionSort(cs2, n);

	output_arrayString(cs1,n);
	cout << "Stable" << endl;
	output_arrayString(cs2,n);
	cout << (isSameArrayString(cs1,n,cs2,n)?"Stable":"Not stable") << endl;

	return 0;
}



Measured memory_bytes: 3216
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

N, X = map(int, input().split())
x = list(map(int, input().split()))

x.insert(0, X)
distance = []
for i in range(1, len(x)):
    distance.append(abs(x[i] - x[i - 1]))


ans = distance[0]
for i in range(1, len(distance)):
    ans = gcd(distance[i], ans)
print(ans)

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

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

	vector<int> c(n);
	vector<vector<int>> av(n, vector<int>(m, 0));
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
		for (auto& j : av[i]) {
			cin >> j;
		}
	}
	int ret = INT_MAX;
	int last = 1 << n;
	for (int i = 1; i < last; ++i) 
	{
		int cs = 0;
		vector<int> as(m, 0);
		for(int j = 0; j < n; ++j)
		{
			if ((1 << j) & i) {
				cs += c[j];
				for (int k = 0; k < m; ++k) {
					as[k] += av[j][k];
				}
			}
		}

		bool ok = true;
		for (auto& a : as) {
			if (a < x) {
				ok = false;
			}
		}
		if (ok) {
			ret = min(ret, cs);
		}
	}

	if (ret == INT_MAX) {
		cout << -1 << endl;
	}
	else {
		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 3604
#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() {
    int n, cnt = 0;
    ll tmp;
    vector<ll> l(n);
    cin >> n;
    rep(i, n) {
        cin >> tmp;
        l.push_back(tmp);
    }
    for(int i = 0; i < n-2; i++) {
        for(int j = i + 1; j-1 < n; j++) {
            for(int k = j + 1; k < n; k++) {
                if((l[i] < l[j] + l[k]) && (l[j] < l[i] + l[k]) &&
                   (l[k] < l[j] + l[i]) && (l[i] != l[j]) && (l[i] != l[k]) &&
                   (l[j] != l[k])) {
                    cnt++;
                    // cout << l[i] << l[j] << l[k] << endl;
                }
            }
        }
    }
 
    cout << cnt << endl;
 
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

#define INF 1000000007
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define Min(a,b) (((a) < (b))?(a):(b))
#define Max(a,b) (((a) > (b))?(a):(b))
#define Abs(a) (((a) > 0)?(a):(-1)*(a))
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define S(a) ((a)*(a))
#define gc getchar
#define pc putchar

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<int>::iterator viit;
typedef vector<long long> vll;
typedef vector<long long>::iterator vllit;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

inline void read(int &x) {
	register int c = gc();
	x = 0;
	bool neg = false;
	for(;(c<48)||(c>57);c=gc()) { if(c=='-') neg = true; }
	for(;(c>47)&&(c<58);c=gc()) { x = (x<<1) + (x<<3) + (c-48);	}
	if(neg) x = -x;
}

inline void write(long long int n) {
	bool neg = (n<0);
	if(n == 0) { pc('0'); pc('\n'); }
	else if(n == -1) { pc('-'); pc('1'); pc('\n'); }
	else {
		if(neg) n=-n,pc('-');
		char buf[20];
		buf[19] = '\n';
		int i = 18;
		while(n) { buf[i--] = n % 10 + '0'; n /= 10; }
		while(buf[i] != '\n') pc(buf[++i]);
	}
}

ll exp (ll b, ll e) {
	if (b == 1 || e == 0) return 1;
	if(e == 1) return b%INF;
	if(e == 2) return (b*b)%INF;
	return ( (e%2 == 0)? exp(exp(b,e/2),2)%INF : (b * (exp(exp(b,e/2),2)%INF))%INF );
}

ll gcd ( ll a, ll b ) {
	return ( (b == 0)?a:gcd(b,a%b) );
}

int p[100004], ispar[100004], d[100004];
vi mem[100004];

int dfs (int v, int p) {
	vi b;
	if (mem[v].empty()) return 0;
	for (viit it = mem[v].begin(), ite = mem[v].end() ; it != ite ; ++it) {
		int t = dfs (*it, v);
		b.PB(t);
	}
	sort(b.begin(), b.end());
	int l = b.size(), k = l;
	for (int i = 0 ; i < l ; ++i, --k) {
		d[v] = Max (b[i]+k, d[v]);
	}
	b.clear();
	return d[v];
}

int main() {
	int n,i,j,k = -1;
	scanf("%d",&n);
	for (i = 0 ; i <= n ; ++i) { d[i] = -1; ispar[i] = p[i] = 0; }
	p[1] = 1;
	for (i = 2 ; i <= n ; ++i) {
		scanf("%d",&j);
		p[i] = j;
		mem[j].PB(i);
	}
	/*
	int ans = INF;
	for (i = 1 ; i <= n ; ++i) {
		if (ispar[i] == 0) {
			int par = p[i], prv = i, cnt = 0;
			while (1) {
				if (par == 1) {
					mem[prv].PB(cnt);
					sort (mem[prv].begin(), mem[prv].end());
					int l = (k = mem[prv].size());
					--k;
					for (int u = 0 ; u < l ; ++u, --k) {
						d[prv] = Max (d[prv], mem[prv][u]+k);
					}
					break;
				}
				++cnt;
				prv = par;
				par = p[par];
			}
			ans = Min (cnt + k, ans);
		}
	}
	sort (d, d+n+1);
	i = 0;
	while (d[i] == -1) ++i;
	k = n-i+1;
	for ( ; i <= n ; ++i) {
		ans = Max (ans, d[i]+k); --k;
	}
	*/
	cout << dfs(1,1) << endl;

	return 0;
}


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

using namespace std;

int main() {
	int i = 0, j = 0, n = 0, a = 0, b = 0, x = 0, y = 0;
	string s;

	cin >> n >> a >> b >> s;


	for (i = 0; i < n; i++) {
		j = 0;
		if (s[i] == 'c') {
			j = 0;
		}
		else if (s[i] == 'a' && x < a + b) {
			j = 1;
			x++;
		}
		else if (s[i] == 'b' && x < a + b && y < b) {
			j = 1;
			x++;
			y++;
		}

		if (j == 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	
	}

	return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

void divisor(ll n) {
  ll ans = 0;
  vector< ll > div;
  ll div1 = 0;
  ll div2 = 0;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      div.push_back(i);

      //重複許すマジ
      if(i * i != n){
          div.push_back(n / i);
      }
    }
  }
  sort(div.begin(), div.end());
  
  string s;
  s = to_string(div[div.size()/2]);

  cout << s.length() << endl;

}

int main(){

    ll N; cin >> N;

    divisor(N);
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,r; cin >> n >> r;
    if(n<10){
        cout << r+100*(10-n) << endl;
    }else{
        cout << r << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

int main(){
	using namespace std;
	int a,b,ans,i;
	cin >> a >> b;
	for (i = 1; i < 4; i++) {
		if (a != i && b != i) {
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>

#define rep(index,max) for(int index=0;index<max;index++)

using namespace std;

int main(){
    string s1,s2;
    int l1,l2;
    cin>>s1>>s2;
    l1=s1.length();
    l2=s2.length();
    int dp[1010][1010];
    
    rep(i,l1+1) dp[i][0]=i;
    rep(j,l2+1) dp[0][j]=j;
    
    rep(i,l1){
        rep(j,l2){
            if(s1[i]==s2[j]){
                dp[i+1][j+1]=dp[i][j];
            }
            else{
                dp[i+1][j+1]=min(min(dp[i+1][j],dp[i][j+1]),dp[i][j])+1;
            }
        }
    }
    
    cout<<dp[l1][l2]<<endl;
    return 0;
}

Measured memory_bytes: 7176
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

LL n;
LL a[500005],ans = 0;

LL solve(LL x){
	LL cn0 = 0,cn1 = 0;
	for(LL i = 1;i <= n;i ++){
		if(a[i] & (1LL << x)) cn1 ++;
		else cn0 ++;
	}
	return (cn0 * cn1) % N;
}

int main(){
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	for(LL i = 0;i <= 62;i ++){
		ans = ans + (1LL << i) % N * solve(i) % N;
		ans %= N;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
fn main(){
	let (mut hh, mut mm, mut ss) = (0, 0, readLine::<i32>());
	while ss >= 3600 {
		hh += 1;
		ss -= 3600;
	}
	while ss >= 60 {
		mm += 1;
		ss -= 60;
	}
	
	println!("{}:{}:{}", hh, mm, ss);
}
 
fn readLine<T: std::str::FromStr>() -> T {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}


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

typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    } 
    sort(a.begin(), a.end());
    ll ans = 0;
    if(n%2 == 0){
        for(int i=0;i<n/2-1;i++){
            ans -= a[i]*2;
        }
        ans += a[n/2] - a[n/2-1];
        for(int i=n/2+1;i<n;i++){
            ans += a[i]*2;
        }
    }
    else{
        for(int i=0;i<n/2-1;i++){
            ans -= a[i]*2;
        }
        ans += a[n/2+1] - a[n/2-1];
        for(int i=n/2+2;i<n;i++){
            ans += a[i]*2;
        }
        ans += max(a[n/2+1]-a[n/2], a[n/2]-a[n/2-1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
 
int main()
{
    long long m;
    scanf("%lld",&m);
    char s[100]={0};
    int i=0;
    m--;
    while(m>=0){
        s[i]=m%26+'a';
        m/=26;
        i++;
        m--;
    }
    for(int j=i-1;j>=0;j--){
        printf("%c",s[j]);
    }
    return 0;
}

Measured memory_bytes: 1648
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  while(getline(cin,s)){
    for(int i=0; i<26; i++){
      string::size_type x,y,z;
      x = s.find("this");
      y = s.find("that");
      z = s.find("the");
      if(x!=string::npos) break;
      if(y!=string::npos) break;
      if(z!=string::npos) break;
      for(int j=0; j<s.size(); j++){
	if(s[j]>='a' && s[j]<'z') s[j]++;
	else if(s[j] == 'z') s[j] = 'a';
      }
    }
    cout <<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 1176
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int n,k;
int ax(int x){
	return x>k?x-n:x;
}
int main(){
	cin>>k;
	if (k==1){
		cout<<"1\n1\n";
		return 0;
	}
	n=(k+3)/4*2;
	cout<<n<<endl;
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			if (i&1)printf("%d ",ax(n+(i+j)%n+1));
			else printf("%d ",(i+j)%n+1);
		}
		printf("\n");
	}
}

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

int main() {

    ll a, b, v, w, t;
    cin>>a>>v>>b>>w>>t;

    ll d = abs( a - b );

    ll x = (w * t);
    ll y = (v * t);

    if(y >= (x+d)) {
        cout<<"YES\n";
    }
    else {
        cout<<"NO\n";
    }
}


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

int main(void){
    int a;
    string s;
    string red = "red";
    cin >> a;
    cin >> s;
    if(a>=3200){
        cout << s;
    }
    else{
        cout << red;
    }
    return 0;
}

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

using namespace std;

long long gcd(long long a, long long b){
	return b?(gcd(b,a%b)):a;
}

long long lcm(long long a, long long b)  {  
    return (a*b)/gcd(a, b);  
}  


int main(){

	long long a,b,c,d;
	cin>>a>>b>>c>>d;

	
	long long sum(0);
	long long p = lcm(c,d);
	sum += (b/c) + (b/d)- ((a-1)/c) -((a-1)/d) - (b/p)+ ( (a-1)/p);


	cout<<b-a-sum+1<<endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

struct Pos{int x, y;}
void main() {
    int size = 8;
    int N = readln.chomp.to!int;
    foreach(i; 0..N) {
        writeln("Data "~(i+1).to!string~":");
        readln;

        int[][] grid = new int[][](size, size);
        foreach(j; 0..size) {
            grid[j] = readln.chomp.map!(a => a=='0' ? 0:1).array;
        }
        Pos s;
        s.x = readln.chomp.to!int-1;
        s.y = readln.chomp.to!int-1;
        grid[s.y][s.x] = 0;

        auto list = DList!Pos(s);
        int[] dx = [1,2,3,-1,-2,-3,0,0,0,0,0,0];
        int[] dy = [0,0,0,0,0,0,1,2,3,-1,-2,-3];
        while (!list.empty) {
            Pos p = list.front;
            list.removeFront;
            foreach(j; 0..dx.length) {
                Pos _p = Pos(p.x+dx[j], p.y+dy[j]);
                if (0<=_p.x && _p.x<size && 0<=_p.y && _p.y<size) {
                    if (grid[_p.y][_p.x] == 1) {
                        grid[_p.y][_p.x] = 0;
                        list.insertBack(_p);
                    }
                }
            }
        }
        grid.map!(a => reduce!((b,c)=>b~c.to!string)("", a)).each!writeln;
    }
}

Measured memory_bytes: 2496
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

bool bo[510][510],pd[510][510],a[510][510],b[510][510];
int i,j,k,l,t,n,m,mi,mx;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline char get()
{
	char ch=getchar();
	for (;ch!='.'&&ch!='#';ch=getchar());
	return ch;
}

int main()
{
	n=rd();m=rd();
	for (int i=1;i<=n;i++) for (int j=1;j<=m;j++)
	{
		if (get()=='#') bo[i][j]=true;
		a[i][j]=b[i][j]=bo[i][j];
	}
	for (int i=1;i<=n;i++) a[i][1]=true,b[i][m]=true;
	for (int i=2;i<n;i++) if (i&1) for (int j=2;j<m;j++) a[i][j]|=1;
	for (int i=2;i<n;i++) if (!(i&1)) for (int j=2;j<m;j++) b[i][j]|=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++) printf("%c",a[i][j]?'#':'.');
		puts("");
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++) printf("%c",b[i][j]?'#':'.');
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1536
import java.util.*;
 
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);          
	
	double a = sc.nextDouble();
        double b = sc.nextDouble();
        double c = sc.nextDouble();
        double d = sc.nextDouble();
        double x = c - a;
        double y = d - b;
        double f = (x * x) + (y * y);
        double g = Math.sqrt(f);
        
	System.out.printf("%.6f\n", g);
 
	}
}


Measured memory_bytes: 28188
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

N = int(input())
zero = 0
d = defaultdict(lambda: [0, 0])
for i in range(N):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zero += 1
        continue
    g = gcd(x, y)
    x //= g
    y //= g
    if y < 0:
        x = -x
        y = -y
    if y == 0 and x < 0:
        x = -x
    rotate = x <= 0
    if rotate:
        x, y = y, -x
        d[(x, y)][0] += 1
    else:
        d[(x, y)][1] += 1

ans = 1
for v in d.values():
    now = 1
    now += (2 ** v[0] - 1) % MOD
    now += (2 ** v[1] - 1) % MOD
    ans *= now
    ans %= MOD
print((ans - 1 + zero) % MOD)


    



Measured memory_bytes: 142292
using System;
using System.Linq;

class F
{
	static void Main()
	{
		var p = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

		var c = Enumerable.Repeat(p - 1, p).ToArray();
		var b = new int[p];
		b[0] = a[0];
		for (var i = p - 1; i > 0; i--)
		{
			b[i] = Enumerable.Range(0, p).Sum(j => c[j] * a[j]) % p;
			for (var j = 0; j < p; j++) c[j] = j * c[j] % p;
		}
		Console.WriteLine(string.Join(" ", b));
	}
}


Measured memory_bytes: 13436
<?php
  
  $input = trim(fgets(STDIN));
	$inputs = str_split($input);

	if($inputs[0] === $inputs[1] ||
      $inputs[1] === $inputs[2] ||
      $inputs[2] === $inputs[3]){
		print "Bad";      
    }else{
      print "Good";
    }

Measured memory_bytes: 4728
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
std::vector<P> tree[100010];
struct edge{int to,cost;};
 
ll i,j,k;
ll a,b,c;
ll ima=0,ans=-INF,num,kazu=0;
ll f[102][12],p[102][12];
ll n,m;
 
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		for(j=1;j<=10;j++){
			cin>>f[i][j];
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=11;j++){
			cin>>p[i][j];
		}
	}
	for(i=1;i<=1023;i++){
		for(j=1;j<=n;j++){
			num=i;
			for(k=1;k<=10;k++){
				if(num%2==1 && f[j][k]==1){
					kazu++;
				}
				num = num/2;
			}
			ima += p[j][kazu+1];
			kazu=0;
		}
		ans = max(ans,ima);
		ima=0;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;


//union find木(グループわけができる)
int par[200010];
int unifind(int n) {
             for (int i = 0; i < n; i++) {
                           par[i] = i;
             }
             return 0;
}
             //木の根を求める
int unifind_root(int x) {
             if (par[x] == x) {
                           return x;
             }
             else {
                           return par[x] = unifind_root(par[x]);
             }
}
             //同じグループか判定
bool unifind_same(int x, int y) {
             return unifind_root(x) == unifind_root(y);
}
             //グループ併合
int unifind_unite(int x, int y) {
             x = unifind_root(x);
             y = unifind_root(y);
             if (x == y) {
                           return 0;
             }
             par[x] = y;
}
 

const long long int mod=1000000007;
int main(){
	cout << fixed << setprecision(18);
	long long int k=-1,i=-1,h=-1,b=-1,r=-1;
	string str;
	char ch;
	cin>>str;
	if(str.length()<5||str.length()>9){cout<<"NO";return 0;}
	for(int p=0;p<str.length();p++)
	{
		if(str[p]=='K'&&k==-1)
		{
			k=p;
		}else if(str[p]=='I'&&i==-1){
			i=p;
		}else if(str[p]=='H'&&h==-1){
			h=p;
		}else if(str[p]=='B'&&b==-1){
			b=p;
		}else if(str[p]=='R'&&r==-1){
			r=p;
		}else if(str[p]=='A'){
			
		}else{
			cout<<"NO";return 0;
		}
	}
	
	if(k<2&&i==k+1&&h==i+1&&b-h<=2&&b-h>=1&&r-b<=2&&r-b>=1)
	{
		cout<<"YES";
	}else{cout<<"NO";}
	
}


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

int main() {
  int a,b,c,d,e;
  cin>>a;
  d=0;
  e=0;
  for(int i=0;i<a;i++){
    cin>>b>>c;
    if(b>d){
      d=b;
      e=c;
    }
  }
  cout<<d+e<<endl;
}

Measured memory_bytes: 256
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define MP make_pair
using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;
const int maxn = 1e5+9;
const int64 M = 1e9+7;
const int64 I = 4e5;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    if (s == "keyence")
        return cout << "YES\n", 0;
    for (int i = 0; i < s.length(); i++) {
        for (int t = i; t < s.length(); t++) {
            string str;
            for (int j = 0; j < i; j++)
                str += s[j];
            for (int j = t + 1; j < s.length(); j++)
                str += s[j];
            if (str == "keyence")
                return cout << "YES\n", 0;
        }
    }
    cout << "NO\n";
}

Measured memory_bytes: 256