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

int main() {
	int n, x;
	cin >> n >> x;
	int t = 1, b = 0;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		b += a;
		if(b <= x) t++;
		else break;
	}
	cout << t << "\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanNum = new Scanner(System.in);
		int a = scanNum.nextInt();
		int b = scanNum.nextInt();
		if(a<b){
			System.out.println("a < b");
		}
		else if (a>b) {
			System.out.println("a > b");
		}
		else if (a==b) {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 17356
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
using namespace std;

void dfs(vector<vector<int>> &adj_list, vector<int> &colors, int s, int c)
{
    stack<int> st;
    colors[s] = c;
    st.push(s);
    while (!st.empty())
    {
        int u = st.top();
        st.pop();
        for (int i = 0; i < adj_list[u].size(); i++)
        {
            int v = adj_list[u][i];
            // cout << u << ", " << v << endl;
            if (colors[v] == -1)
            {
                // cout << 1 << endl;
                colors[v] = c;
                st.push(v);
            }
        }
    }
}

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

    vector<vector<int>> adj_list(n);
    for (int i = 0; i < m; i++)
    {
        int s, t;
        cin >> s >> t;
        adj_list[s].push_back(t);
        adj_list[t].push_back(s);
    }

    int id = 0;
    vector<int> colors(n, -1);
    for (int i = 0; i < n; i++)
    {
        if (colors[i] == -1)
        {
            dfs(adj_list, colors, i, id++);
        }

        // for (auto a : colors)
        // {
        //     cout << a << ", ";
        // }
        // cout << endl;
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int s, t;
        cin >> s >> t;
        if (colors[s] == colors[t])
        {
            cout << "yes" << endl;
        }
        else
        {
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8628
#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 = 0;
   cin >> n;
   if(n/100 == 7 || (n/10)%10 == 7 || n%10 == 7) {
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
}


Measured memory_bytes: 3592
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for _ in range(D)]
T=[int(input()) for _ in range(D)]

last=[0]*26
score=0
for i in range(D):
    contest=T[i]-1
    score+=S[i][contest]
    last[contest]=i+1
    for j in range(26):
        blank=i+1-last[j]
        score-=blank*C[j]
    print(score)



Measured memory_bytes: 9280
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int r = sc.nextInt();
    static int c = sc.nextInt();
    static int rc[][] = new int[r + 1][c + 1];
    public static void main(String[] args) {
        for (int i = 0; i < r; i++){
            for (int j = 0; j < c; j++){
                rc[i][j] = sc.nextInt();
                rc[i][c] += rc[i][j];
                rc[r][j] += rc[i][j];
            }
        }
        for (int i = 0; i < r; i++) {
            rc[r][c] += rc[i][c];
        }
        for (int i = 0; i <= r; i++) {
            for (int j = 0; j <= c; j++) {
                System.out.print(rc[i][j]);
                if (j != c)
                    System.out.print(" ");
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 42048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	int n,arr[100000];
	long long cnt = 0;
	vector<int>vec;
	cin>>n;
	for(int i=0;i<n;++i)cin>>arr[i];
	sort(arr,arr+n);
	for(int i=0;i<n;++i){
	    for(int j=i+1;j<n;++j){
	        int k = arr[i]+arr[j];
	        int l = upper_bound(arr,arr+n,k-1)-arr;
	        cnt+=l-j-1;
	    }
	}
	cout<<cnt;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-6;
const vi emp;

set<int> st;

int main(){
	int s;
	for(int i=0;i<3;i++){
		cin>>s;
		st.insert(s);
	}
	cout<<st.size()<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	long a, b, c, k;
	scanf("%ld", &a);
	scanf("%ld", &b);
	scanf("%ld", &c);
	scanf("%ld", &k);
	if(k <= a){
		printf("%ld\n", k);
	}
	else if(k <= a+b){
		printf("%ld\n", a);
	}
	else{
		printf("%ld\n", 2*a+b-k);
	}
	return 0;
}

Measured memory_bytes: 1736
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  double W, H, x, y; cin >> W >> H >> x >> y;

  double ans1 = H * W / 2;
  double cx = W / 2, cy = H / 2;
  int ans2;
  if (cx == x && cy == y) ans2 = 1;
  else ans2 = 0;

  cout << setprecision(15) << ans1 << " " << ans2 << '\n';

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
      	int x = sc.nextInt();
        int y = sc.nextInt();
      	int t;
      	int k;
      	boolean coj = false;
      
      	if(y % 2 == 0){
          t = y/2;
          k = y/4;
          if(y % 4 != 0)k++;
          if(t >= x && x >= k) coj = true;
        }
          
      	if(coj) System.out.println("Yes");
      	else System.out.println("No");
      
	}
}

Measured memory_bytes: 35816
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

string upper(string s){
	string t=s;
	for(int i=0;i<t.size();i++){
		t[i]=toupper(s[i]);
	}
	return t;
}

int main(){
	int cou=0;
	string s1,s2;
	cin>>s1;
	s1=upper(s1);
	
	while(cin>>s2){
		if(s2=="END_OF_TEXT")break;
		s2=upper(s2);
		if(s1==s2){
			cou++;
		}
	}
	cout<<cou<<endl;
	return 0;
}

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

void No() {
    cout << 0 << endl;
    exit(0);
}

void Yes(int k) {
    constexpr int64_t kMod = 1e9+7;
    int64_t prod = 1;
    for (int i = 0; i < k; i++) {
        prod *= 2;
        prod %= kMod;
    }
    cout << prod << endl;
    exit(0);
}

int main() {

    int n;
    cin >> n;
    std::vector<int> v(n);

    for (auto& el : v) {
        cin >> el;
    }
    std::sort(v.begin(), v.end());

    std::vector<int> another;
    for (int i = 0; i < n; i++) {
        another.push_back(abs(n - i - 1 - i));
    }
    sort(another.begin(), another.end());

    for (int i = 0; i < n; i++) {
        if (another[i] != v[i]) {
            No();
        }
    }
    Yes(n / 2);

    return 0;
}



Measured memory_bytes: 1276
# -*- coding: utf-8 -*-

dic = {}
bui = [k for k in range(1, 5)]
flo = [k for k in range(1, 4)]
roo = [k for k in range(1, 11)]

for b in bui:
    for f in flo:
        for r in roo:
            dic[(b, f, r)] = 0

n = input()
for i in range(n):
    list = map(int, raw_input().split())
    b = list[0]
    f = list[1]
    r = list[2]
    dic[(b, f, r)] += list[3]

for b in bui:
    for f in flo:
        buf = ""
        for r in roo:
            buf += " "+ str(dic[(b, f, r)])
        print buf
    if b < 4:
        print "#"*20

Measured memory_bytes: 6488
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int  a, b, c, ans=0 ;  
    cin >> a >> b >> c ;  
    while (true){
        if ((a==b) and (b==c) and ((a&1)^1)){
            cout << "-1" << endl;
            return;
        }
        if ((a&1) or (b&1) or (c&1)) break; 
        ans ++;
        int ta=a,tb=b,tc=c;
        b = c = ta/2 ; 
        b += tc/2; a=tb/2; 
        a += tc/2; c += tb/2; 
    }
    //cout << a<< " "<<b<< " "<<c<<endl;
    cout << ans << endl;
    return;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N, M;
    int X[100000];
    int diff[100000];
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> X[i];
    }
    sort(X, X+M);
    int ans = X[M-1] - X[0];
    for(int i = 0; i < M-1; i++){
        diff[i] = X[i+1] - X[i];
    }
    sort(diff, diff+M-1);
    
    if( N >= M){
        cout << 0 << endl;
    }else{
        
        for(int i = 0; i < N-1; i++){
            ans -= diff[M-2-i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void no(){
  cout << -1 << endl;
  exit(0);
}

typedef pair<ll,ll> P;
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(){
  ll N; cin >> N;
  vector<vector<ll>> a(N+1, vector<ll>(N+1,0));
  vector<vector<vector<P>>> edge(N+1, vector<vector<P>>(N+1));
  //map<pair<ll,ll>, vector<pair<ll,ll>> edge;
  //map<P, ll> deg;
  vector<vector<ll>> deg(N,vector<ll>(N+1,0));
  FOR(i,1,N+1) FOR(j,1,N){
    cin >> a[i][j];
  }
  FOR(i,1,N+1) FOR(j,1,N-1){
    ll x = a[i][j], y = a[i][j+1];
    ll k = i, l=i;
    if(i>x) swap(k,x);
    if(i>y) swap(l,y);
    edge[k][x].push_back({l,y});
    deg[l][y]++;
    //DUMP(l);DUMP(y);
  }
  stack<P> st;
  FOR(i,1,N) FOR(j,1,N+1){
    // if(i<j){
    //   DUMP(i); DUMP(j); DUMP(deg[i][j]);
    // }
    if(i<j&&deg[i][j]==0) st.push({i,j});
  }
  vector<vector<ll>> dp(N+1,vector<ll>(N+1,0));
  vector<P> topo;
  while(!st.empty()){
    P p = st.top();
    st.pop();
    topo.push_back(p);
    ll i = p.first, j = p.second;
    //DUMP(i);DUMP(j);
    REP(k, SZ(edge[i][j])){
      P q = edge[i][j][k];
      deg[q.first][q.second]--;
      chmax(dp[q.first][q.second], dp[i][j]+1);
      if(deg[q.first][q.second]==0) st.push(q);
    }
  }
  if(SZ(topo)!=N*(N-1)/2) no();
  ll ans = 0;
  FOR(i,1,N) FOR(j,i+1,N+1) ans = max(ans,dp[i][j]);
  cout << ans+1 << endl;
}

Measured memory_bytes: 82284
#include<stdio.h>
int main()
{
  int n,i,x;
  double r[1000][3];
  scanf("%d",&n);
  for(i=0; i<n; i++)
    {
      scanf("%lf%lf%lf",&r[i][0],&r[i][1],&r[i][2]);
    }
  for(i=0; i<n; i++)
    {
      if(r[i][1]>r[i][0])
	{
	  x=r[i][0];
	  r[i][0]=r[i][1];
	  r[i][1]=x;
	}
      if(r[i][2]>r[i][0])
	{
	  x=r[i][0];
	  r[i][0]=r[i][2];
	  r[i][2]=x;
	}
      if(r[i][0]*r[i][0]==r[i][1]*r[i][1]+r[i][2]*r[i][2]) printf("YES\n");
      else printf("NO\n");
    }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h;
    int a;
    cin >> h >> a;
    int ans = 0;
    while (h > 0) {
        ans++;
        h -= a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
plist = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
    if plist[i] == i + 1:
        plist[i], plist[i + 1] = plist[i + 1], plist[i]
        ans += 1
if plist[-1] == N:
    ans += 1
print(ans)


Measured memory_bytes: 52908
n = int(input())
list_a = []
list_b = []
for i in range(n):
    a,b = (int(x) for x in input().split())
    list_a.append(a)
    list_b.append(b)
list_a.sort()
list_b.sort()

if n%2==0:
    mi = (list_a[int(n/2)]+list_a[int(n/2)-1])/2
    ma = (list_b[int(n/2)]+list_b[int(n/2)-1])/2
    print(int((ma-mi)*2+1))
else:
    mi = list_a[int((n-1)/2)]
    ma = list_b[int((n-1)/2)]
    print(int(ma-mi+1))

Measured memory_bytes: 25556
#include <stdio.h>
#include<vector>
#include<math.h>
#include<string>

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;

unsi gojoho(unsi A, unsi B) {
	unsi R = 1;
	if (A > B) {
		while (R!=0) {
			R = A % B;
			A = B;
			B = R;
		}
		return A;
	} else {
		while (R != 0) {
			R = B % A;
			B = A;
			A = R;
		}
		return B;
	}
}

uni gojoho(uni A, uni B) {
	uni R = 1;
	if (A > B) {
		while (R != 0) {
			R = A % B;
			A = B;
			B = R;
		}
		return A;
	} else {
		while (R != 0) {
			R = B % A;
			B = A;
			A = R;
		}
		return B;
	}
}

unli gojoho(unli A, unli B) {
	unli R = 1;
	if (A > B) {
		while (R != 0) {
			R = A % B;
			A = B;
			B = R;
		}
		return A;
	} else {
		while (R != 0) {
			R = B % A;
			B = A;
			A = R;
		}
		return B;
	}
}

int gojoho(int A, int B) {
	int R = 1;
	if (A > B) {
		while (R != 0) {
			R = A % B;
			A = B;
			B = R;
		}
		return A;
	} else {
		while (R != 0) {
			R = B % A;
			B = A;
			A = R;
		}
		return B;
	}
}



int main(){
	int N;
	int Ans;
	scanf("%d", &N);
	Ans = (N - 2) * 180;
	printf("%d", Ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#define intl long long
#include<vector>
using namespace std;

intl n;
intl data[2000];

int main(void){
	cin>>n;
	for(intl i=0;i<n;i++){
		cin>>data[i];
	}
	sort(data,data+n);
	
	intl ans=0;
	for(intl i=0;i<n;i++){
		for(intl j=i+1;j<n;j++){
			intl a=data[i]+data[j];
			intl id1=lower_bound(data,data+n,a)-data;
			intl cnt=id1-(j+1);
			ans+=cnt;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
judge = True
for n in range(len(S)):
  if n % 2 == 0:
    if S[n] not in ["R","U","D"]:
      judge = False
      break
  else:
    if S[n] not in ["L","U","D"]:
      judge = False
      break
if judge:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9044
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	vector <ll> B(N);
	rep(i, N) {
		cin >> B.at(i);
	}
	ll an = 0,k=0;
	rep(u, N-1) {
		if (B.at(u + 1) <= B.at(u)) {
			k++;
			an = max(an, k);
		}
		else {
			k = 0;
		}
	}
	cout << an << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59
 
bool isprime(ll a){
  if(a==1) return 0;
  for(ll i=2;i*i<=a;i++){
    if(a%i==0) return 0;
  }
  return 1;
}

ll d[101010];

int main(){
  d[0]=0;
  for(ll i=1;i<101010;i++){
    d[i]=d[i-1];
    if(i%2==1&&isprime(i)&&isprime(1+i/2)) d[i]++;
  }
  ll q;
  ll i,j;
  cin>>q;
  ll x,y;
  for(i=0;i<q;i++){
    cin>>x>>y;
    cout<<d[y]-d[x-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int minChange(vector<int> value, int n){
  // dp[i] := i 円を払うお釣りの最小枚数
  vector<int> dp(n + 1, INF); // n + 1 個の inf (十分大きな値) で初期化
  dp[0] = 0;

  for(int i = 0; i <= n; ++i){
  	for(int j = 0; j < value.size(); ++j){
      if(i - value[j] >= 0){                       // 配列の範囲外チェック
        dp[i] = min(dp[i - value[j]] + 1, dp[i]);  // i - value[j] 円払えるなら、それに value[j] 円を 1 枚足して i 円を払える
}
}
}

return dp[n];
}

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> data;
	for(int i =0; i<m;i++){
		int x;
		cin>>x;
		data.push_back(x);
	}
	cout <<minChange(data, n)<<endl;
	return 0;
}

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

#define int long long
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; }

signed main(){
	string a, b, c;
	cin >> a >> b >> c;
	cout << ((a.back() == b.front() && b.back() == c.front()) ? "YES" : "NO" ) << endl;
	return 0;
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long N, std::vector<long long> d){
    sort(ALL(d));
    int res;
        res = d[N / 2] - d[N / 2 - 1];
    cout << res << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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;
}

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

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

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	map<ll, ll> ma;
	rep(i, n) {
		cin >> a[i];
		ma[a[i]]++;
		ma[a[i] - 1]++;
		ma[a[i] + 1]++;
	}
	ll max = 0;
	for (auto itr : ma) {
		if (max < itr.second)max = itr.second;
	}
	cout << max;
	return 0;
}


Measured memory_bytes: 6912
N, Y = [int(str) for str in input().strip().split()]
Y //= 1000

for i in range(N + 1):
    for j in range(N - i + 1):
        k = N - i - j
        if 10 * i + 5 * j + k == Y:
            print(i, j, k)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 40684
def main():
    N, M, X, Y = map(int, input().split())
    xlist = [int(a) for a in input().split()]
    ylist = [int(a) for a in input().split()]
    xlist.sort()
    ylist.sort()
    if X < ylist[0] <= Y and xlist[-1] < ylist[0]:
        print("No War")
    else:
        print("War")
main()

Measured memory_bytes: 3060
import java.io.IOException;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			d = scanner.nextInt();
			n = scanner.nextInt();
			if ((d | n) == 0)
				break;
			aer = new AER[n];
			for (int i = 0; i < n; i++) {
				aer[i] = new AER(scanner.nextInt(), scanner.nextInt(),
						scanner.nextInt());
			}
			dp = new int[d + 1][101];
			for (int[] dpp : dp)
				Arrays.fill(dpp, INF);
			PriorityQueue<AER> pq = new PriorityQueue<AER>();
			pq.offer(new AER(d, 0, 0));
			ans = INF;
			while (!pq.isEmpty()) {
				AER now = pq.poll();
				if (now.a == 0) {
					ans = Math.min(ans, now.r);
					break;
				}
				for (AER a : aer) {
					if (now.e < a.r)
						continue;
					int nhp = Math.max(0, now.a - a.a);
					int nexp = Math.min(100, now.e + a.e);
					if (now.a == nhp && now.e == nexp)
						continue;
					if (dp[nhp][nexp] <= now.r + 1)
						continue;
					dp[nhp][nexp] = now.r + 1;
					pq.offer(new AER(nhp, nexp, now.r + 1));

				}
			}
			System.out.println(ans == INF ? "NA" : ans);
		}
	}

	int d, n;
	int[][] dp;
	int INF = 1 << 30;
	AER[] aer;
	int ans;

	class AER implements Comparable<AER> {
		int a, e, r;

		public AER(int a, int e, int r) {
			super();
			this.a = a;
			this.e = e;
			this.r = r;
		}

		@Override
		public String toString() {
			return "AER [a=" + a + ", e=" + e + ", r=" + r + "]";
		}

		@Override
		public int compareTo(AER o) {
			if (this.r == o.r)
				return this.a - o.a;
			return this.r - o.r;
		}
	}
}

Measured memory_bytes: 49648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

ll n,k;
vector<ll> a;
vector<ll> f;

bool solve(ll mid,ll tmp = k){
  rep(i,n){
    if(a[i]*f[i] > mid){
      ll target = a[i]*f[i] - mid;
      tmp -= (target + f[i] - 1)/f[i];
    }
  }
  return tmp >= 0;
}

int main(){
  cin >> n >> k;
  a.resize(n);
  f.resize(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(a);
  sort(f);
  reverse(f);
  ll ok = (ll)pow(10,18)+1;
  ll ng = -1;
  while(abs(ok - ng) > 1){
    ll tmp = k;
    ll mid = (ok + ng) / 2;
    if (solve(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}


Measured memory_bytes: 3328
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int i=0;int ans=0;
    while(true){
        int hoge;
        if(!(i%2)){
            if(!i){cin>>ans;i++;continue;}
            cin>>hoge;
            i++;
        }else{
            char c; cin>>c;
            if(c=='*'){
                int temp; cin>>temp;
                ans*=temp;
            }else if(c=='+'){
                int hoge; cin>>hoge;
                ans+=hoge;
            }else if(c=='-'){
                int j; cin>>j;
                ans-=j;
            }else if(c!='='){
                int yebi; cin>>yebi;
                ans/=yebi;
            }else break;
            i+=2;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

typedef long long ll;

using namespace std;

ll gcd(ll m, ll n) {
  if (n == 0) return m;
  else return gcd(n, m % n);
}

ll lcm(ll m, ll n) {
  return m * n / gcd(m, n);
}

ll a, b;

ll solve() {
  return lcm(a, b);
}

int main() {
  cin >> a >> b;
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int N  =  2e5 + 5, MOD  =  1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a[N];
pair<int, int> b[N];

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

    int n, m;
    cin>>n>>m;

    for(int i = 1; i <= n; i++) cin>>a[i];

    sort(a + 1, a + n + 1);//, greater<int>());

    for(int i = 1; i <= m; i++){
        cin>>b[i].second>>b[i].first;
    }
    sort(b + 1, b + m + 1, greater< pair< int, int> >());
    int p1 = 1;
    for(int i = 1; i <= n; i++){
        if(b[p1].second == 0)   p1++;
        if(b[p1].first < a[i])  break;
        b[p1].second--;
        a[i] = b[p1].first;
    }
    int sum = 0;
    for(int i = 1; i <= n; i++) sum += a[i];
    cout<<sum;

    return 0;
}


Measured memory_bytes: 3840
N = int(input())
T = []
A = []
for _ in range(N):
    Ti, Ai = map(int, input().split())
    T.append(Ti)
    A.append(Ai)

tmp_t = T[0]
tmp_a = A[0]
ans = tmp_t + tmp_a
for i in range(1, N):
    n_t = tmp_t // T[i] if tmp_t % T[i] == 0 else tmp_t // T[i] + 1
    n_a = tmp_a // A[i] if tmp_a % A[i] == 0 else tmp_a // A[i] + 1
    n = max(n_t, n_a)
    tmp_t = T[i] * n
    tmp_a = A[i] * n
    ans = tmp_t + tmp_a

print(ans)

Measured memory_bytes: 3064
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if X == i*500 + j*100 + k*50:
        count += 1

print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	string S;
	cin >> S;
	bool ret = false;
	for(int i = 0;i < S.size() - 1;i++) {
		if(S.at(i) == S.at(i + 1)) {
			cout << i + 1 << " " << i + 2 << endl;
			ret = true;
			break;
		}
	}
	if(ret == false) {
		for(int i = 0;i < S.size() - 2;i++) {
			if(S.at(i) == S.at(i + 2)) {
				cout << i + 1 << " " << i + 3 << endl;
				ret = true;
				break;
			}
		}
	}
	if(ret == false) {
		cout << "-1 -1" << endl;
	}
}

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

int main(void)
{
	int H, W;

	do{
		cin >> H >> W;
	
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++)
				cout << '#';
			cout << endl;
		}
		if(H || W) cout << endl;
	}while(H || W);

	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,k,l,arr[123];
char c[123][123],d[123];
int main()
{
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s %d",&c[i],&arr[i]);
        l+=arr[i];
    }
    scanf("%s",&d);
    for(i=0;i<n;i++)
    {
        l-=arr[i];
        if(strcmp(c[i],d)==0)
        {
            printf("%d\n",l);
            return 0;
        }
    }
}


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

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

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

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

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

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

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

//memo
// setprecision()

int main() {
  string S,T;
  cin >> S >> T;
  
  if(S[0]==T[2] && S[1]==T[1] && S[2]==T[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, A, B; cin >> N >> A >> B;
    if ((B-A)%2) cout << "Borys" << endl;
    else cout << "Alice" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  bool flag = false;
  string s1 = s.substr(0,n/2);
  string s2 = s.substr(n/2,n/2);
  if(s1 == s2) flag = true;
  if(n % 2 != 0) flag = false;
  YesorNo(flag);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    N = (input().rstrip())

    if(len(N) == 3):
        N= ''.join(list(reversed(N)))
    
    print(N)
if __name__ == '__main__':
    solve()


Measured memory_bytes: 3944
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		// Scannerクラスのインスタンスを作成
		// 引数で標準入力System.inを指定する
		Scanner scanner = new Scanner(System.in);

		//
		List<Integer> output = new ArrayList<Integer>();

		boolean flag = true;
		//数字の場合
		while (flag) {
			int cnt = scanner.nextInt();

			if (cnt == 0) {
				flag = false;
			}
			if (flag == false)
				break;
			int[] score = new int[cnt];

			//点数の入力
			for (int i = 0; i < score.length; i++) {
				int num = scanner.nextInt();
				score[i] = num;
			}

			int max = 0;
			for (int i = 0; i < score.length; i++) {

				if (max < score[i]) {
					max = score[i];
				}
			}

			int min = 10000;
			for (int i = 0; i < score.length; i++) {
				if (min > score[i]) {
					min = score[i];
				}
			}

			//最大値と最小値の初期化
			for (int i = 0; i < score.length; i++) {

				if (score[i] == max) {
					score[i] = 0;
					break;
				}
			}
			for (int i = 0; i < score.length; i++) {
				if (score[i] == min) {
					score[i] = 0;
					break;
				}
			}

			//合計
			int sum = 0;
			for (int num : score) {
				sum = sum + num;
			}
			int cnt2 = cnt - 2;
			int number = sum / cnt2;
			output.add(number);
		}

		// Scannerクラスのインスタンスをクローズ
		scanner.close();

		for (int sum : output) {
			System.out.println(sum);
		}
	}
}


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

namespace ProblemC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Bs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var ret = Bs[0] + Bs[N - 2];
            for (int i = 0; i < Bs.Count() - 1; i++)
            {
                ret += Math.Min(Bs[i], Bs[i + 1]);
            }
            Console.WriteLine(ret);

        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 310
ll n,y,a[N];
ll b[N];
bool e[N][N];
ll solve(ll base){
    ll dp[N][5];
    for(int i=0;i<n;i++)for(int j=0;j<5;j++)dp[i][j]=0;
    dp[0][0]=1;
    for(int i=0;i<n;i++)for(int j=0;j<4;j++){
	for(int t=i+1;t<n;t++){
	    if(e[(i+base)%n][(t+base)%n]){
		dp[t][j+1]+=dp[i][j];
	    }
	}
    }
    ll ans=0;
    for(int i=0;i<n;i++){
	if(e[(i+base)%n][(0+base)%n]){
	    ans+=dp[i][4];
	}
    }
    return ans;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>n>>y;
    ll s=0;
    for(int i=0;i<n;i++){
	cin>>a[i];
	s+=a[i];
    }
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
	ll to=j; if(to<i)to+=n;
	ll sum=0;
	for(int k=i;k<to;k++){
	    sum+=a[k%n];
	}
	e[i][j]=(sum+y>=s/5);
	if(i==j)e[i][j]=0;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
	    b[j]=a[(i+j)%n];
	}
	ans+=solve(n-i);
	assert(ans<1e18);
    }
    cout<<ans/5<<endl;
}





Measured memory_bytes: 3292
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>

int main() {
    long long n, m;

    std::cin >> n >> m;

    std::vector<std::vector<long long> > remaining(m);
    for (size_t i = 0; i < n; i++) {
        long long num;
        std::cin >> num;
        remaining[num % m].push_back(num);
    }

    // あまりがゼロのものはそのものの半分ペアができる
    long long ans = remaining[0].size() / 2;

    for (int i = 1; i <= m / 2; i++) {
        std::vector<long long> a = remaining[i],
            b = remaining[m - i];

        if (a == b) {
            ans += a.size() / 2;
            continue;
        }

        std::sort(a.begin(), a.end());
        std::sort(b.begin(), b.end());

        if (a.size() > b.size()) std::swap(a, b);
        // この時点で b のほうがたくさん要素がある
        if (b.size() == 0) continue;
        for (auto it = b.begin() + 1;a.size() < b.size() && it < b.end(); it++) {
            if (*(it - 1) == *it) {
                it = b.erase(it);
                it = b.erase(it - 1);
                ans++;
            }
        }
        ans += std::min(a.size(), b.size());
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 5760
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
console.log(input.map(function(x) {
  const op = {
    '+': function(a, b) {return a + b;},
    '-': function(a, b) {return a - b;},
    '*': function(a, b) {return a * b;},
    '/': function(a, b) {return ~~(a / b);},
    '?': function(a, b) {return;}
  };
  const arr = x.split(' ');
  return arr.length == 3 ? op[arr[1]](Number(arr[0]), Number(arr[2])) : '';
}).join('\n').trim());

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define VSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

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

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

    if(W*H%2==0){
        cout<<W*H/2;
    }
    else{
        cout<<W*H/2<<".5";
    }
    if(W%2==0 && W/2==x && H%2==0 && H/2==y){
        cout<<" 1";
    }
    else{
        cout<<" 0";
    }

	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
l = []
r = []
for i in range(m):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)
count = 0
ma = max(l)
mi = min(r)
for i in range(1,n+1):
        if ma <= i <= mi: 
            count += 1
print(count)

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

using namespace std;
#define int long long
#define all(a) (a).begin(), (a).end()
#define ms(a,v) memset(a, v, sizeof(a))
#define sz(v) ((int)(v).size())
#define mp make_pair
#define pb push_back
#define prev biiiiirl_sai_de_casa_comi_pra_caralho
#define next trapezio_descendente
#define index eh_ele_que_nos_vai_buscar
#define left aqui_eh_37_anos_porra
#define R32 ({int32_t x; scanf("%d", &x); x;})
#define RL ({long long x; scanf("%lld", &x); x;})
#define RC ({char x; scanf(" %c", &x); x;})
#define RI RL
#define ff first
#define ss second
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;

const int N = 1e6;
vector<int> adj[N];
int color[N][12];

void go(int s, int d, int c){
  if(color[s][d]) return;
  queue<ii> q;
  q.push({s, d});
  color[s][d] = c;

  while(!q.empty()){
    int u, cur;
    tie(u, cur) = q.front();
    q.pop();

    if(cur == 0) continue;
    if(!color[u][cur-1]){
      color[u][cur-1] = c;
      q.push({u, cur-1});
    }

    for(int v : adj[u]){
      if(!color[v][cur-1]){
        q.push({v, cur-1});
        color[v][cur-1] = c;
      }
    }
  }
}

int32_t main(){
  int n = RI;

  int m = RI;
  for(int i = 0; i < m; i++){
    int a = RI;
    int b = RI;
    adj[a].pb(b);
    adj[b].pb(a);
  }

  int Q = RI;
  vector<tuple<int, int, int>> qrs;
  while(Q--){
    int v = RI;
    int d = RI;
    int c = RI;
    qrs.pb(make_tuple(v, d, c));
  }

  reverse(all(qrs));

  for(auto q : qrs){
    int v, d, c;
    tie(v, d, c) = q;
    go(v, d, c);
  }

  for(int i = 1; i <= n; i++){
    cout << color[i][0] << endl;
  }
}


Measured memory_bytes: 45080
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	int N;
	string S;
	cin >> N >> S;
	string::iterator itr = S.begin();
	vector<int> v(N,0);
	int countw = 0;
	for(int i=0;i<N;i++){
		if(*(itr + i) == 'W'){
			countw++;
		}
		v[i] = countw;
	}
	int ans = N - v[N-1] - 1 + v[0];
	for(int i=1;i<N-1;i++){
		ans = min(v[i-1] + N - v[N-1] - (i + 1) + v[i],ans);
	}
	ans = min(v[N-2],ans);
	cout << ans << endl;
}

Measured memory_bytes: 1796
import bisect
N=int(input())
L=sorted(list(map(int,input().split())))
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        ab=L[i]+L[j]
        r=bisect.bisect_left(L,ab)
        l=j+1
        ans+=r-l
print(ans)

Measured memory_bytes: 42972
def code():
    l = []
    while True:
        m,f,r = map(int,input().split())
        if m == f == r == -1:
            break
        else:
            l.append([m,f,r])
    for i in l:
        s = ''
        x = i[0]+i[1]
        if i[0] == -1 or i[1] == -1:
            s = 'F'
        elif x >= 80:
            s = 'A'
        elif x >= 65:
            s = 'B'
        elif x >= 50:
            s = 'C'
        elif x >= 30:
            s = 'D'
            if i[2] >= 50:
                s = 'C'
        else:
            s = 'F'
        print(s)
code()


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

using namespace std;

main(){
    int a , b , ans = 0;
    scanf("%d %d" , &a , &b);

    for(int i = 1 ; i < 10 ; i ++)
        for(int j = 0 ; j < 10 ; j ++)
            for(int k = 0 ; k < 10 ; k ++){
                int tmp = 10001*i + 1010*j + 100*k;
                if(tmp >= a && tmp <= b)ans ++;
    }

    printf("%d\n" , ans);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int w, h, x, y; cin >> w >> h >> x >> y;
	
	printf("%.20f %d\n",
		w / 2.0 * h,
		2 * x == w && 2 * y == h
		? 1 : 0
	);
	
	return 0;
}

Measured memory_bytes: 256