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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

template<class T> inline bool chmin(T& a, const T b) { if (a>b) { a=b; return true; } return false; }
template<class T> inline bool chmax(T& a, const T b) { if (a<b) { a=b; return true; } return false; }



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

    map<string,int> mp;

    REP(i,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout << "AC x "<< mp["AC"] << endl;
    cout << "WA x "<< mp["WA"] << endl;
    cout << "TLE x "<< mp["TLE"] << endl;
    cout << "RE x "<< mp["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <string.h>
int main(void)
{
	int n,i,c=0,d;
	char a[10];
	char b[1000];
	scanf("%s",a);
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",b);
		strncat(b,b,10);
		if((strstr(b,a))!=NULL){
			c=c+1;
		}
	}
	printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep2(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
//const ll mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

ll N, M, K, H, W, L, R;
string S, T;

int main(){
  cin >> N;
  vll A(N), B(N);
  rep(i,N) cin >> A[i] >> B[i];
  reverse(all(A)); reverse(all(B));
  ll ans = 0;
  rep(i,N){
    if( (A[i]+ans)%B[i] == 0) continue;
    ans += B[i] - (A[i]+ans)%B[i];
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4768
import heapq
N = int(input())
*A, = map(int,input().split())
q = []
for a in A[:N]:
    heapq.heappush(q,a)
S1 = [sum(q)]
for a in A[N:N*2]:
    if a>q[0]:
        S1.append(S1[-1] + a - q[0])
        heapq.heapreplace(q,a)
    else:
        S1.append(S1[-1])
q = []
for a in A[2*N:]:
    heapq.heappush(q,-a)
S2 = [sum(q)]
for a in A[N:N*2][::-1]:
    if a<-q[0]:
        S2.append(S2[-1] - a - q[0])
        heapq.heapreplace(q,-a)
    else:
        S2.append(S2[-1])
S2 = S2[::-1]
print(max(map(sum,zip(S1,S2))))

Measured memory_bytes: 38292
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};

int main() {
    queue<tuple<int,int,int>> q;
    tuple<int,int,int> v,u;
    int h,w,ans=0;
    cin >> h >> w ;
    char a[h][w];
    int x[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
    rep(i,h) rep(j,w) cin >> a[i][j];
    rep(i,h){
        rep(j,w){
            if (a[i][j]=='#'){
                rep(k,4){
                    if (0<=i+x[k][0] && i+x[k][0]<h && 0<=j+x[k][1] && j+x[k][1]<w and a[i+x[k][0]][j+x[k][1]]=='.'){
                        a[i+x[k][0]][j+x[k][1]]='0';
                        v = make_tuple(i+x[k][0],j+x[k][1],1);
                        q.push(v);
                    }
                }
            }
        }
    }
    while (q.size()){
        v=q.front(); q.pop();
        rep(k,4){
            if (0<=get<0>(v)+x[k][0] && get<0>(v)+x[k][0]<h && 0<=get<1>(v)+x[k][1] && get<1>(v)+x[k][1]<w and a[get<0>(v)+x[k][0]][get<1>(v)+x[k][1]]=='.'){
                a[get<0>(v)+x[k][0]][get<1>(v)+x[k][1]]='0';
                ans=get<2>(v)+1;
                u = make_tuple(get<0>(v)+x[k][0],get<1>(v)+x[k][1],get<2>(v)+1);
                q.push(u);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 1e6 + 50;
int A[MAXN];

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int H, W, h, w; cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

int D1[100005];
int D2[100005];

void dfs1(vector<vector<int>>& g, int cur, int pre, int d) {
  D1[cur] = d;
  rep(i, g[cur].size()) {
    if(g[cur][i] != pre) {
      dfs1(g, g[cur][i], cur, d + 1);
    }
  }
}

void dfs2(vector<vector<int>>& g, int cur, int pre, int d) {
  D2[cur] = d;
  rep(i, g[cur].size()) {
    if(g[cur][i] != pre) {
      dfs2(g, g[cur][i], cur, d + 1);
    }
  }
}

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

  int N;
  cin >> N;
  vector<vector<int>> G(N);
  rep(i, N-1) {
    int a,b; cin >> a >> b;
    --a;
    --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs1(G, 0, 0, 0);
  dfs2(G, N-1, N-1, 0);

  int fen = 0;
  int snu = 0;
  rep(i, N) {
    if(D1[i] <= D2[i]) {
      ++fen;
    } else {
      ++snu;
    }
  }
  string ans = fen > snu ? "Fennec" : "Snuke";

  cout << ans << endl;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
typedef long long ll;
ll MOD=(ll)1e9+7;
ll dp[1005][1005];//dp[i][j]:i个球分成j组的方案数
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    dp[0][0]=1;
    rep(i,1,n)rep(j,1,i){
        dp[i][j]+=dp[i-1][j]*j%MOD;//加入别的组
        dp[i][j]+=dp[i-1][j-1];//自己一组
        dp[i][j]%=MOD;
    }
    ll ans=0;
    rep(i,1,k){
        ans+=dp[n][i];
        ans%=MOD;
    }
    cout<<ans<<endl;

}
/* 

 */


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

namespace Volume11_1147
{
    class Program
    {
        static void Main(string[] args)
        {
            Referee refe = new Referee();
            int referee;
            while ((referee = int.Parse(Console.ReadLine())) != 0)
            {
                List<int> score = new List<int>();
                for (int i = 0; i < referee; ++i)
                {
                    score.Add(int.Parse(Console.ReadLine()));
                }
                Console.WriteLine(refe.Score(score));
            }
        }
    }
    class Referee
    {
        internal int Score(List<int> score)
        {
            score.Remove(score.Max());
            score.Remove(score.Min());
            return (int)score.Average();
        }
    }
}



Measured memory_bytes: 16052
A,B,C = map(int, input().split())

def even(a):
	if a % 2 == 0:
		return True
	else:
		return False

cnt = 0

while even(A) and even(B) and even(C):
	if A == B and B == C:
		cnt = -1
		break
	else:
		tmp1, tmp2, tmp3 = A,B,C
		A = (tmp2+tmp3) // 2
		B = (tmp3+tmp1) // 2
		C = (tmp1+tmp2) // 2
		cnt += 1

print(cnt)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int A;
int B;

int main() {
  cin >> A >> B;
  int num = 0;
  while(A<=B){
    int topA = A/10000;
    int secA = A/1000;
    if( (A - topA - 10*secA)%100 ==0 ){
      num += 1;
    }
    A++;
  }
  cout << num;
}



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

using namespace std;
using ll = long long;

int main(void) {
  int n;
  cin >> n;
  set<string> s;
  for (int i = 0; i < n; i++) {
    string c;
    cin >> c;
    s.insert(c);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 19208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int n;
string s;
int read() {
	char ch = getchar();
	int x = 0, f = 1;
	while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
	while (ch >= '0' && ch <= '9') x = x*10 + ch - 48, ch = getchar();
	return x * f;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n;
	cin>>s;
	if(n>=s.size()) cout<<s;
	else{
		for(int i=0;i<n;i++)
		cout<<s[i];
		cout<<"...";
	}
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	int sum=0;
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<k;i++)
	{
		sum+=a[i];
	}

	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3636
n, m = map(int, input().split())

li = [list(map(int, input().split())) for _ in range(m)]

ans = [0] * n

check = [0] * n

if m == 0 and n > 1:
    ans[0] = 1
    s = list(map(str, ans))
    print("".join(s))
    exit()

for i in range(m):
    if check[-li[i][0]] == 0:
        ans[-li[i][0]] = li[i][1]
        check[-li[i][0]] = 1
    else:
        if ans[-li[i][0]] == li[i][1]:
            continue
        else:
            print(-1)
            exit()

if ans[-1] == 0 and n != 1:
    if check[-1] == 0:
        ans[-1] = 1
    else:
        print(-1)
        exit()

res = []
for i in range(n):
    res.append(str(ans[-i-1]))
    
print("".join(res))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
template <class T>
bool chmax(T &a, const T &b){if (a < b){a = b;return 1;}return 0;}
template <class T>bool chmin(T &a, const T &b){if (b < a){a = b;return 1;}return 0;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


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

    int n,k;
    cin >> n>>k;
    double a[n];
    rep(i, n){
        cin >> a[i];
    }
    double tmp = 0;
    rep(i, k)
    {
        tmp+=a[i];
    }
    ll max = tmp;
    rep2(j,k,n)
    {
        tmp += a[j];
        tmp -= a[j - k];
        if (max < tmp)
            max = tmp;
    }
    //cout << (double)max/2 << endl;
    printf("%.10f", (double)max/2 + k * 0.5);

    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
//change null_type here for map/set
typedef tree<int,null_type,less<int>,rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;
typedef long long int  ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define F first
#define S second

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    x*=sgn; return ~c;
}
///START HERE
///indexed_set pbd;
//pbd.insert()
//auto x = pbd.find_by_order(2);
//int od=pbd.order_of_key(7)
///rope<int> rp;
//rp.push_back()
//RandomAccess like vector
//mutable_begin, mutable_end()

int main(){
    ///read()+printf
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //fast;
    int n;
    cin>>n;
    int k=n/1000;
    if(n%1000!=0){
        k++;
    }
    cout<<k*1000-n;


    return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
// inline void CIN() {}
// template <class Head, class... Tail>
// inline void CIN(Head &&head, Tail &&... tail) {
//     cin >> head;
//     CIN(move(tail)...);
// }
// CIN(__VA_ARGS__)
// CIN(__VA_ARGS__)
// CIN(__VA_ARGS__)
// #define Yes(a) cout << (a ? "Yes" : "No") << "\n"
// #define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
// typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int n;
vector<P> A;

int main() {
    cin >> n;
    A.resize(n);
    REP(i, n) {
        int x, y;
        cin >> x >> y;
        A[i] = {x, y};
    }
    sort(All(A));
    REP(i, n) {
        cout << A[i].first << " ";
        cout << A[i].second << "\n";
    }
    return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <cmath>
constexpr auto RAD2DEG = 57.295779513082320876798154814105;
int main(){
  double a,b,x;
  std::cin >>a >>b >>x;
  double v = a*a*b;
  double theta;
  if (x <= v/2){
    theta = std::atan2(2*x, a*b*b);
  }else{
    double y = v-x;
    theta = std::atan2(a*a*a, 2*y);
  }
  std::cout << std::setprecision(20) <<  (90 - theta * RAD2DEG);
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
 
int main(void){
  struct{
    int start;
    int goal;
    int flg;
  }prof[100];
  int sum=0;
  int n,m,a,b;
  int i,j,k,who,whol;
 
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    prof[i].start=a-1;
    prof[i].goal=b-1;
    prof[i].flg=0;
  }
  
  for(i=0;i<n;i=whol+1){
    who=-1;
    whol=-1;
    for(j=0;j<m;j++){
      if(i<prof[j].start || i>prof[j].goal) continue;
      if(whol<prof[j].goal){
	who=j;
	whol=prof[j].goal;
      }
    }
    if(who==-1){
      puts("Impossible");
      return 0;
    }
    prof[who].flg=1;
  }
    
  for(i=0;i<m;i++) sum+=prof[i].flg;
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
using namespace std;
int main(void)
{
  int a[10],n1=0,n2=0,n3=0;
  
  for(int i=0;i<10;i++){
    cin>>a[i];
      if(a[i]>=n1){
        n3=n2;
        n2=n1;
        n1=a[i];
      }
      else if(a[i]>=n2){
        n3=n2;
        n2=a[i];
      }
      else if(a[i]>=n3){
        n3=a[i];
      }
  }
  cout<<n1<<'\n'<<n2<<'\n'<<n3<<'\n';
}

Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  int n,i;
  long long t,res=0;
  vector<int> a,b,c;
  vector<int>::iterator ia,ic,ba,bc;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> t;
    a.push_back(t);
  }
  for(i=0;i<n;i++){
    cin >> t;
    b.push_back(t);
  }
  for(i=0;i<n;i++){
    cin >> t;
    c.push_back(t);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  ba=a.begin();
  bc=c.begin();
  for(i=0;i<n;i++){
    ia=lower_bound(ba,a.end(),b[i]);
    ic=upper_bound(bc,c.end(),b[i]);
    t=(long long)distance(a.begin(),ia)*(long long)distance(ic,c.end());
    res+=t;
    ba=ia; bc=ic;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1784
import numpy as np

n = int(input())
arr = np.array([int(i) for i in input().split()])
mod = 10 ** 9 + 7
s = 0

for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    s += 2 ** i * c1 * (n - c1)
    arr = arr >> 1

print(s % mod)

Measured memory_bytes: 48856
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef  long long ll;
int gcd(int f , int s){if(s==0)return f;else return gcd(s,f%s);}
int const N = 1000006;
ll const M = 998244353;
long double const ep = .000000000000000001;
ll a , k , arr[N] , cul[N];
ll test(ll y){
	ll re = y * k;
	int p = a;
	re += 5 * (cul[p] - cul[p-y]);
	p -= y;
	for(int i = 5 ; i < 10000000 ; i+=2){
		if(y >= p){
			re += i * cul[p];
			if(re < 0)return 1e18;
			return re;
		}else{
			re += i * (cul[p] - cul[p-y]);
			p -= y;
		}
	}
}
int main() {
	
	scanf("%d%d",&a , &k);
	for(int i = 1 ; i <= a ; i++)scanf("%lld" , arr+i);
	for(int i = 1 ; i <= a ; i++)cul[i] = cul[i-1] + arr[i];
	ll ans = 1e18;
	for(int i = 1 ; i <= a ; i++){
		ans = min(ans , test(i));
	}
	printf("%lld\n", ans + a * k);
	return 0;	
}

Measured memory_bytes: 5888
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int arr[] = new int[101];
        for(int i = 1; i <= 100; i++) {
            if((a % i == 0) && (b % i == 0)) {
                arr[i] = i;
            }
        }
        int count = 0;
        for(int i = 100; i >= 0; i--) {
            if(arr[i] > 0) {
                count++;
            }
            if(count == k) {
                System.out.println(i);
                break;
            }
        }
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int S,W;
    cin >> S >> W;
    if(S <= W) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 3576
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
    long[][] c = new long[51][51];

    void solve(Scanner sc, PrintWriter pw) {
        int N = sc.nextInt();
        int K = sc.nextInt();
        long S = sc.nextLong();
        long T = sc.nextLong();
        long[] data = new long[N];
        for (int i = 0; i < N; i++) {
            data[i] = sc.nextLong();
        }
        for (int i = 0; i <= N; i++) {
            c[i][0] = 1;
            for (int j = 1; j <= i; j++) {
                c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
            }
        }
        long[] sum = new long[(N + 1)];
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= Math.min(i, K); j++) {
                sum[i] += c[i][j];
            }
        }
        long result = 0;
        List<Long> nums = new ArrayList<>();
        for (long mask = 0; mask < (1L << 18); mask++) {
            if (((T ^ S) & mask) != mask) {
                continue;
            }
            boolean isAdd = (countBit(mask) % 2) == 0;
            nums.clear();
            for (int i = 0; i < N; i++) {
                if ((data[i] & S) != S) {
                    continue;
                }
                if ((data[i] | T) != T) {
                    continue;
                }
                nums.add(data[i] & mask);
            }
            Collections.sort(nums);
            int begin = 0;
            int nextBegin;
            while (begin < nums.size()) {
                nextBegin = begin + 1;
                while (nextBegin< nums.size() && nums.get(nextBegin).equals(nums.get(nextBegin - 1))) {
                    nextBegin++;
                }
                result += (isAdd ? 1L : -1L) * (sum[nextBegin - begin]);
                begin = nextBegin;
            }
        }
        pw.println(String.format("%d", result));
    }

    private int countBit(long mask) {
        int result = 0;
        while (mask > 0) {
            result ++;
            mask ^= ((mask) &(-mask));
        }
        return result;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 63828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<double>A(n);
    double P= 0;
    
    REP(i,n){
        cin >> A[i];
        P+= 1.0/A[i];
    }
    cout << fixed << setprecision(10) << (double)1/P << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,s[4803],x,ans,sum;
int main()
{
  scanf("%d",&n);
  for (int a=1;a<=n;a++)
  {
    scanf("%d",&x);
    s[x]++;
  }
  for (int a=0;a<=7;a++)
    for (int b=0;b<=399;b++)
    {
      if (s[a*400+b]!=0)
      {
        ans++;
        break;
      }
    }
  for (int a=3200;a<=4800;a++)
  {
    sum+=s[a];
  }
  printf("%d ",max(1,ans));
  ans=ans+sum;
  printf("%d\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
	int i;
	cin>>a>>b;
	for(i=0;i<max(a.size(),b.size());i++)
	{
		cout<<a[i];
		if(b[i]!=0)
			cout<<b[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
w, h, n = (int(x) for x in input().split())
x = []
s = [[1 for _ in range(w)] for _ in range(h)]
for _ in range(n): x.append([int(i) for i in input().split()])
for x_i in x:
    a = x_i[2]
    if a == 1:
        for h_ in range(h):
            for w_ in range(x_i[0]):
                s[h_][w_] = 0
    elif a == 2:
        for h_ in range(h):
            for w_ in range(x_i[0], w):
                s[h_][w_] = 0
    elif a == 3:
        for h_ in range(x_i[1]):
            for w_ in range(w):
                s[h_][w_] = 0
    else:
        for h_ in range(x_i[1], h):
            for w_ in range(w):
                s[h_][w_] = 0
print(sum([s[i][j] for j in range(w) for i in range(h)]))

Measured memory_bytes: 3188
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Walk on Multiplication Table
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const long long LINF = 1LL << 62;

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll n;
  scanf("%lld", &n);

  ll mind = LINF;
  for (ll p = 1; p * p <= n; p++)
    if (n % p == 0) {
      ll q = n / p;
      ll d = p + q - 2;
      if (mind > d) mind = d;
    }

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


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

ll comb(ll n, ll r) {
    ll res = 1;
    for(ll i=1; i<=r; i++) {
        res = res * (n - i + 1) / i;
    }
    return res;
}

int main() {
    int n, p; cin >> n >> p;
    int a[51]; INITA(a, 0, 50, 0);
    int num_odd = 0;
    int num_even = 0;
    REP(i, n) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            num_even++;
        } else {
            num_odd++;
        }
    }
    ll res = 0;
    if (p == 1) {
        for (int i=1; i<=num_odd; i+=2) {
            res += comb(num_odd, i);
        }
        res *= pow(2, num_even);
    } else {
        for (int i=0; i<=num_odd; i+=2) {
            res += comb(num_odd, i);
        }
        res *= pow(2, num_even);
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;
void Swap(int &x,int &y){
	int tmp;
	tmp=x;
	x=y;
	y=tmp;
}
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	int i;
	vector<int> p(N+1,0);
	for (i=1;i<=N;i++){
		cin>>p[i];
	}
	int aw=0;
	for (i=1;i<=N;i++){
		if (p[i]==i){
			if (i<N){
				Swap(p[i],p[i+1]);
			}else{
				Swap(p[i-1],p[i]);
			}
			aw++;
		}
	}

	cout<<aw<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>
#include <vector>
using namespace std;
int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (0 == i % k) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;

int main() {
	int n, i, k = 0;
	long long int j = 0, ans = 0;
	cin >> n;
	vector<int>a(n), b(n), c(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (i = 0; i < n; i++) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());
	for (i = 0; i < n; i++) {
		cin >> c[i];
	}
	sort(c.begin(), c.end());
	for (i = 0; i < n; i++) {
		while (a[j] < b[i] && j < n)j++;
		while (c[k] <= b[i] && k < n)k++;
		ans += j * (n - k);
	}
	cout << ans << endl;
	return 0;

}



Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int a,b;
    cin >> a >> b;
    for(int i = 1;i <= 1000;i++)
    {
        if((int)(i * 0.08) == a && (int)(i * 0.1) == b)
        {
            cout << i << "\n";
            return 0;
        }
    }
    cout << "-1\n";

    return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int l[100];
    int sum = 0, m = -1;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
        sum += l[i];
        if (l[i] > m) {
            m = l[i];
        }
    }
    if (sum - 2 * m > 0) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
K = int(input())

result = 0
count = 0
tmp = K
m = tmp % 10

able = 0

for i in range(1, 10):
    if (m * i) % 10 == 7:
        tmp = K * i
        count += 1
        able = 1
        break

if able == 0:
    result = -1
    tmp = 0

while tmp > 7:
    able = 0
    tmp = tmp // 10
    n = tmp % 10
    for i in range(10):
        if (n + (m * i)) % 10 == 7:
            tmp += K * i
            count += 1
            able = 1
            break
    if able == 0:
        result = -1
        break
if result == -1:
    print(-1)
else:
    print(count)

Measured memory_bytes: 67612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

ll a[100];
int n;

vector<pp> op;

int main()
{
	read(n);
	int mabs = 0, mabsi = 0;
	for(int i=1; i<=n; ++i) read(a[i]);
	mabs = abs(a[1]); mabsi = 1;
	for(int i=2; i<=n; ++i){
		if(abs(a[i]) > mabs){
			mabs = abs(a[i]);
			mabsi = i;
		}
	}
	for(int i=1; i<=n; ++i) if(i != mabsi){
		a[i] += a[mabsi];
		op.eb(mabsi, i);
	}
	int sign = 1;
	for(int i=1; i<=n; ++i){
		if(a[i]<0){
			sign = -1; break;
		}
	}
	if(sign == 1){
		for(int i=2; i<=n; ++i){
			op.eb(i-1, i);
			a[i] += a[i-1];
		}
	} else {
		for(int i=n-1; 1<=i; --i){
			op.eb(i+1, i);
			a[i] += a[i+1];
		}
	}
	printf("%d\n", int(op.size()));
	for(auto a:op) printf("%d %d\n", a.x, a.y);
	return 0;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val V = readLine()!!.split(" ").map { it.toInt() }
    val C = readLine()!!.split(" ").map { it.toInt() }

    val diff = mutableListOf<Int>()
    (1..N).forEach {
        diff.add(V[it - 1] - C[it -1])
    }


    val ans = diff.filter {
        it > 0
    }.sum()

    println(ans)
}

Measured memory_bytes: 37880
#include <stdio.h>

int main(){
  int n, e, j, m, i;

  while(scanf("%d", &n) && n){
    for(i = 0; i < n; i++){
      scanf("%d%d%d", &m, &e, &j);
      if((m == 100 || e == 100 || j == 100) || (m + e) / 2 >= 90 || (m + e + j)\
 / 3 >= 80) puts("A");
      else if((m + e + j) / 3 >= 70 || ((m + e + j) / 3 >= 50 && (m >= 80 || e \
>= 80))) puts("B");
      else puts("C");
    }
  }
  return 0;
}

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

int main()
{
	long long H;

	cin >> H;
	
	int count = 0;
	while ( H > 1 ) {

		H = H / 2;
		count++;

		if (H == 1) {
			break;			
		}

	}
	
	long long answer = 1LL;
	
	for (int i = 1; i <= count; i++) {
	
		long long tmp = 1LL;

		for (int j = 1; j <= i; j++) {
			tmp *= 2;
		}		
		answer += tmp;
	}
	
	cout << answer << endl;

	return 0;

}

Measured memory_bytes: 256
n, q = gets.split.map(&:to_i)
names, times = [], []
pt = 0
n.times do
  name, time = gets.split(' ')
  names.push(name)
  times.push(time.to_i)
end
while !names.empty?
  pt += [times[0], q].min
  times[0] = times[0] - q
  if times[0] <= 0
    puts "#{names[0]} #{pt}"
  else
    names.push(names[0])
    times.push(times[0])
  end
  names.delete_at(0)
  times.delete_at(0)
end



Measured memory_bytes: 9952
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#define int long 
using namespace std;

signed main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	int A = (vec.at(0) ^ vec.at(1));
	for(int i = 2;i < N;i++) {
		A = (A ^ vec.at(i));
	}
	if((A ^ A) == A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main () {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
	
    int ans = 0;

    for (int r = 0; r <= N / R; r++) {
        if (R * r > N) {
            break;
        }

        for (int g = 0; g <= N / G; g++) {
            if (R * r + G * g > N) {
                break;
            }

            if ((N - (R * r + G * g)) % B == 0) {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (int)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	string s;
	int n;
	cin >> n >> s;
	int cnt = 0;
	for(char &x : s)
		cnt += (x=='R');
	int ans = cnt;
	for(int i = 0; i < cnt; i++)
		ans -= (s[i]=='R');
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3792
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

typedef struct coo {
    int x;
    int y;
};

int main() {
    coo p1, p2;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;
    int q;
    cin >> q;
    coo* p = new coo[q];
    for (int i = 0; i < q; i++) {
        cin >> p[i].x >> p[i].y;
        int naiseki = (p[i].x - p1.x) * (p2.x - p1.x) + (p[i].y - p1.y) * (p2.y - p1.y);
        double leng = (double)naiseki / (double)((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));
        printf("%6.10f %6.10f\n", 2*(p1.x + (p2.x - p1.x) * leng)-p[i].x, 2*(p1.y + (p2.y - p1.y) * leng)-p[i].y);
    }
    delete[] p;
    return 0;
}


Measured memory_bytes: 3236
n = int(input())

ans = [0 for i in range(n)]

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            su = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if(su <= n):
                ans[su-1] += 1

for i in range(n):
    print(ans[i])

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

void yes(){
	cout << "Yes" << endl;
	return;
}

void Main()
{
	int n, m;
  	cin >> n >> m;
  	vi s(m), c(m);
  	rep(i,m) {
      	cin >> s[i] >> c[i];
      	if(n != 1 && s[i] == 1 && c[i] == 0){
        	cout << -1 << endl;
          	return;
        }
    }
  	vector<pii> data(m);
  	rep(i,m) data[i] = mp(s[i],c[i]);
  	stable_sort(all(data));
  	
  	// rep(i,m) cout << data[i].first << " " << data[i].second << endl;
  	rep(i,m-1) {
      	if( data[i].first == data[i+1].first && data[i].second != data[i+1].second){
    		cout << -1 << endl;
          	return;
        }
    }
  	vi ans(n,0);
  	rep(i,m){
    	ans[s[i]-1] = c[i];
    }
  	if(n!=1 && ans[0] == 0) ans[0] = 1;
  	
  	rep(i,n) cout << ans[i];
  	cout << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int H,W,h,w; cin >> H >> W >> h >> w;
    VVI ans(H,VI(W,0));

    int t = 1000;
    REP(i,H)REP(j,W){
        if(i%h==h-1 && j%w==w-1) ans[i][j] = -1-t*(h*w-1);
        else ans[i][j] = t;
    }

    ll sum = 0; REP(i,H)REP(j,W) sum += ans[i][j];
    if(sum<=0) cout << "No" << en;
    else{
        cout << "Yes" << en;
        REP(i,H){
            REP(j,W) cout << ans[i][j] << " ";
            cout << en;
        }
    }
    return;
}

int main(void){
    cin.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t){
        Main();
    }
    return 0;
}

Measured memory_bytes: 2560
a, b, c, d = map(int, input().split())

if b <= c or d <= a:
    print(0)
elif (d >= b and c <= a) or (b >= d and a <= c):
    print(min(d - c, b - a))
elif b >= d:
    print(d - a)
else:
    print(b - c)



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

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

	cout << ans << endl;
}

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

const long long int INF = 1000000001;

int main(){
  int n,weight;

  cin >> n >> weight;

  int v[n],w[n];

  for(int i=0; i<n; i++){
    cin >> v[i] >> w[i];
  }

  int maxv = v[0];

  for(int i=0; i<n; i++){
    if(maxv < v[i]){
      maxv = v[i];
    }
  }

  long long int dp[n+1][n*maxv+1];


  fill(dp[0],dp[0] + n*maxv+1,INF);

  dp[0][0] = 0;

  for(int i=0; i<n; i++){
    for(int j=0; j<=n*maxv; j++){

      if(j<v[i]){
        dp[i+1][j] = dp[i][j];
      }

      else{
        dp[i+1][j] = min(dp[i][j] , dp[i][j-v[i]] + w[i]);
      }
    }
  }

  /*for(int i=0; i<n; i++){
    for(int j=0; j<=n*maxv+1; j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/

  int ans=0;

  for(int i=0;i<=n*maxv;i++){
    if(dp[n][i] <= weight){
      ans = i;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 10992
#include <bits/stdc++.h>
using namespace std;
long long l[2000005];
long long dp[2000005];
long long h[2000005];
long long a[2000005];
long long b;
void u(long long x, long long y)
{
	for(;x <= b; x += x&-x)
	{
		l[x] = max(l[x], y);
	}
}
long long q(long long x)
{
	long long z = 0;
	for(;x > 0; x -= x&-x)
	{
		z = max(z, l[x]);
	}
	return z;
}
int main()
{
	long long r = 0;
	cin >> b;
	for(long long i = 0; i < b; i++)
	{
		cin >> h[i];
	}
	for(long long i = 0; i < b; i++)
	{
		cin >> a[i];
	}
	for(long long i = 0; i < b; i++)
	{
		dp[i] = a[i] + q(h[i]-1);
		u(h[i], dp[i]);
		r = max(r, dp[i]);
	}
	cout << r << endl;
}


Measured memory_bytes: 14080
#include <iostream>
#include <cstdio>

using namespace std;

int w, h, n;
int xmx, ymx, xmn, ymn;

int main()
{
    scanf("%d%d%d", &w, &h, &n);
    xmn = w;
    ymn = h;
    for(int i = 0; i < n; i++)
    {
        int t1, t2, t3;
        scanf("%d%d%d", &t1, &t2, &t3);
        if(t3 == 1)
        {
            xmx = max(t1, xmx);
        }
        else if(t3 == 2)
        {
            xmn = min(t1, xmn);
        }
        else if(t3 == 3)
        {
            ymx = max(t2, ymx);
        }
        else if(t3 == 4)
        {
            ymn = min(t2, ymn);
        }
    }
    printf("%d", max(ymn - ymx, 0) * max(xmn - xmx, 0));
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() {

	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	ll n,m;
	cin>>n>>m;
	ll one=0;
	ll two=0;
	if(n>1){
		one=((n)*(n-1))/2;
	}
	if(m>1){
		two=((m)*(m-1))/2;
	}
	cout<<one+two;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        String[] ymd = S.split("/");
        int year = Integer.parseInt(ymd[0]);
        int month = Integer.parseInt(ymd[1]);

        if(year < 2019){
            System.out.println("Heisei");
        } else if(year == 2019){
            if(month < 5){
                System.out.println("Heisei");
            } else {
                System.out.println("TBD");
            }
        } else {
            System.out.println("TBD");
        }


    }
}


Measured memory_bytes: 23636
A, B, K = map(int, input().split())

for n in range(K):
    if n % 2 ==0:
        if A % 2 != 0:
            A -= 1
        C = A // 2
        A -= C
        B += C
    else:
        if B % 2 != 0:
            B -= 1
        C = B // 2
        A += C
        B -= C
print('{} {}'.format(A, B))


Measured memory_bytes: 3060
from collections import defaultdict

n = int(input())
a = [int(i) for i in input().split()]

i_ai = defaultdict(list)
j_aj = defaultdict(list)
for i, h in enumerate(a):
  i_ai[i+h].append(i)
  j_aj[i-h].append(i)

cand = set(i_ai.keys()) & set(j_aj.keys())
ans = 0
for item in cand:
  ans += len(i_ai[item]) * len(j_aj[item])
print(ans)

Measured memory_bytes: 115852
import scala.io.StdIn._

object Main {
  def main(args: Array[String]) = {
    val values = readLine.split(" ").map(_.toInt)
    val a = values(0)
    val b = values(1)
    val t = values(2)
    println(((t + 0.5) / a).toInt * b)
  }
}


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

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

#define NMAX 200000

char str[NMAX];
int n, a;
int str_num[26];

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

	scanf("%s", str);

	n = strlen(str);
	a = n * (n - 1) / 2 + 1;

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < n; j++) {
			if (str[j] == 'a' + i) {
				str_num[i]++;
			}
		}
	}

	for (int i = 0; i < 26; i++) {
		a -= str_num[i] * (str_num[i] - 1) / 2;
	}

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 512