akhauriyash/Code-Regression huggingface dataset:
def two_switches(A: int, B: int, C: int, D: int) -> int:
    if B <= C or D <= A:
        # 交わらない。
        return 0
    if A <= C and D <= B:
        # Alice が Bob を完全に含む
        return D - C
    if C <= A and B <= D:
        # Bob が Alice を完全に含む
        return B - A
    if A <= C:
        # A-----B
        #   C----D
        # こんな感じ
        return B - C
    # 残りは C <= A
    #    A-------B
    # C----D
    # こんな感じ
    return D - A


if __name__ == "__main__":
    A, B, C, D = map(int, input().split())
    ans = two_switches(A, B, C, D)
    print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=100005;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 


ll int power(ll int a,ll int b)
{
    ll int ans=1,f=a;
    while(b)
    {
        if(b&1ll) ans=(ans*f)%mod;
        b=b>>1ll;
        f=(f*f)%mod;
    }
    return ans;
}


int main()
{
  
     int  d,t,s;
     cin>>d>>t>>s;
     if(d<=t*s) cout<<"Yes"<<endl;
     else cout<<"No"<<endl;

    

}

Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  int a, b, res;
  char op;
  cin >> a >> op >> b;
  if (op == '+') {
    res = a + b;
  } else {
    res = a - b;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
q = int(input())
a = Counter(a)
sum_a = 0
for k,v in a.items():
    sum_a += k*v
for i in range(q):
    b,c = map(int,input().split())
    a[c] += a[b]
    sum_a += (c-b)*a[b]
    a[b] = 0
    print(sum_a)

Measured memory_bytes: 23240
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
m=a[-1]
b=[1]*(m+1)
b[0]=0
p=0
q=1
r=0
for c in range(m+n):
    if p>=n or q>m:
        break
    if a[p]>q:
        if r!=q:
            b[q]=0
        q+=1
        continue
    elif a[p]<q:
        p+=1
        continue
    else:
        p+=1
        if r==q:
            b[q]=0
            continue
        for d in range(2,m//q+1):
            b[d*q]=0
        r=q
print(sum(b))

Measured memory_bytes: 31572
S = input()
l = len(S)
ans = l
"""
if len(set(list(S))) == 1 and S[0] == "0":
    print(0)
    exit()
"""
for i in range(l-1):
    if S[i] != S[i+1]:
        ans = min(ans,max(l-i-1,i+1))
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll a(ll n) { return (9 * pow(5, n - 1) - 1) * pow(2, n) / 16; }

int main() {
  string s;
  cin >> s;
  reverse(all(s));
  ll ans = 0;
  rep(i, s.size()) {
    int x = s[i] - '0';
    ans += pow(2, s.size() - i - 1) * a(i + 1) * x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static boolean isCelemonyHeld(int age) {
    return (age == 3 || age == 5 || age == 7) ? true : false;
  }
  
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int age = Integer.parseInt(scanner.nextLine());
    String result = isCelemonyHeld(age) ? "YES" : "NO";
    
    System.out.println(result);
  }
}

Measured memory_bytes: 22996
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let s = iterator.next().unwrap();
    let t = iterator.next().unwrap();

    let mut d = 0;
    for i in 1..(n + 1) {
        if s[n-i..] == t[..i] {
            d = i;
        }
    }

    let ans = 2 * n - d;

    return ans.to_string();
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        // programming
        int n = getInputInteger(sc);
        int y = getInputInteger(sc);
        int n1 = 0;
        int n2 = 0;
        int n3 = 0;
        int temp = 0;
        
        l1: for (int i = 0; i <= n; i++) {
            n1 = i;
            n2 = 0;
            n3 = 0;
            temp = total(n1,n2,n3);
            if (temp > y) {
                continue l1;
            }
            if (temp == y && n1 + n2 + n3 == n) {
                output(String.valueOf(n1), String.valueOf(n2), String.valueOf(n3));
                return;
            }
            l2: for (int j = 0; j <= n - n1; j++) {
                n2 = j;
                n3 = 0;
                temp = total(n1,n2,n3);
                if (temp > y) {
                    continue l1;
                }
                if (temp == y && n1 + n2 + n3 == n) {
                    output(String.valueOf(n1), String.valueOf(n2), String.valueOf(n3));
                    return;
                }
                l3: for (int k = 0; k <= n - n1 - n2; k++) {
                    n3 = k;
                    temp = total(n1,n2,n3);
                    if (temp > y) {
                        continue l2;
                    }
                    if (temp == y && n1 + n2 + n3 == n) {
                        output(String.valueOf(n1), String.valueOf(n2), String.valueOf(n3));
                        return;
                    }
                }
            }
        }
        output("-1", "-1", "-1");
	}

    private static int total(int n1, int n2, int n3) {
        return 10000*n1+5000*n2+1000*n3;
    }

	public static String getInputString(Scanner sc) {
		return sc.next();
	}

	public static int getInputInteger(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	public static void output(String... params) {
		boolean isInit = true;
		String str = "";
		for (String s : params) {
			if (!isInit) {
				str += " ";
			}
			str += s;
			isInit = false;
		}
		System.out.println(str);
	}

    public static int[] toIntegerList(String s) {
        int[] ret = new int[s.length()];
        for (int i = 0; i < s.length(); i++) {
            ret[i] = Integer.parseInt(String.valueOf(s.charAt(i)));
        }
        return ret;
    }

    public static int sum(int[] vals) {
        int sum = 0;
        for (int val : vals) {
            sum += val;
        }
        return sum;
    }

    public static int[] sort(int[] vals, boolean isAsc) {
        Arrays.sort(vals);
		if (isAsc) {
			return vals;
		}
        int[] ret = new int[vals.length];
        for (int i = 0; i < vals.length; i++) {
            ret[vals.length - i - 1] = vals[i];
        }
		return ret;
	}
}

Measured memory_bytes: 23380
object Main extends App {
  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val prefer = Array.tabulate(n){_ ⇒
    readLine.trim.split(' ').map(_.toInt).tail
  }
  println((1 to m).count(i ⇒ prefer.count(_.contains(i)) == n))
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }

}

Measured memory_bytes: 27316
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,l,r,mid,ans1,ans2,num[100005];
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",num+i);
	}
	ans1=ans2=2;
	for (i=n;i;i--)
	{
		if (ans1%num[i]!=0)
		{
			ans1-=ans1%num[i];
		}
		if (ans2%num[i]!=0)
		{
			ans2+=num[i]-ans2%num[i];
		}
		if (ans2>ans1) {cout<<-1;return 0;}
		ans1+=num[i]-1;
	}
	cout<<ans2<<' '<<ans1;
	return 0;
}

Measured memory_bytes: 1024
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

ll N, K;
vector<ll> P;
vector<ll> M;

ll f(ll x) {
  ll cnt = 0;
  ll N = P.size();
  ll mi = M.size() - 1;

  for (ll pi = 0; pi < N; ++pi) {
    while (mi > 0 && P[pi] * M[mi] > x - 1) {
      mi--;
    }

    if (P[pi] * M[mi] > x - 1) break;

    cnt += (mi + 1);
  }

  return cnt;
}

ll g(ll x, vector<ll> &nums) {
  ll cnt = 0;
  ll N = nums.size();
  ll j = N - 1;

  for (ll i = 0; i < N; ++i) {
    while (j > 0 && nums[i] * nums[j] > x - 1) {
      j--;
    }

    if (nums[i] * nums[j] > x - 1) break;

    if (i <= j) {
      cnt += j;
    } else {
      cnt += (j + 1);
    }
  }

  return cnt / 2;
}

ll calc_minus() {
  reverse(P.begin(), P.end());
  ll ok = -1 * pow(10, 18) - 1;
  ll ng = 0;

  while (abs(ok - ng) > 1) {
    ll x = (ok + ng) / 2;

    // fprintf(stderr, "x = %lld, %lld\n", x, f(x));

    if (f(x) < K) {
      ok = x;
    } else {
      ng = x;
    }
  }

  return ok;
}

ll calc_plus(ll L) {
  ll ng = pow(10, 18) + 1;
  ll ok = 0;

  reverse(M.begin(), M.end());

  while (abs(ok - ng) > 1) {
    ll x = (ok + ng) / 2;

    ll cnt = g(x, P) + g(x, M);

    if (cnt < L) {
      ok = x;
    } else {
      ng = x;
    }
  }

  return ok;
}

int main() {
  cin >> N >> K;
  ll ZS = 0;

  ll a;
  for (ll i = 0; i < N; ++i) {
    cin >> a;

    if (a == 0) {
      ++ZS;
    } else if (a > 0) {
      P.push_back(a);
    } else {
      M.push_back(a);
    }
  }

  ll PS = P.size();
  ll MS = M.size();
  ll ZC = ZS * (PS + MS);

  for (ll i = 1; i < ZS; ++i) {
    ZC += i;
  }

  sort(P.begin(), P.end());
  sort(M.begin(), M.end());

  ll MC = M.size() * P.size();

  fprintf(stderr, "MC = %lld, ZC = %lld\n", MC, ZC);

  if (K <= MC) {
    cout << calc_minus() << endl;
  } else if (K <= MC + ZC) {
    cout << 0 << endl;
  } else {
    ll L = K - (MC + ZC);
    cout << calc_plus(L) << endl;
  }

  return 0;
}


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


int main(){
    int A[100], start , mini, b ,c = 0, n;
    cin >> n;
    for(int i = 0; i < n; i++)cin >> A[i];
    for(int i = 0; i < n - 1; i++){
        int d = i + 1;
        mini = A[i + 1];
        for(int j = i + 1; j < n - 1; j++){
            if (mini > A[j + 1]){
                mini = A[j + 1];
                d = j + 1;
            }
        }
        if(A[i] > mini){
            b = mini;
            A[d] = A[i];
            A[i] = b;
            c++;
        } 

    }
    



    for(int i = 0; i < n - 1; i++)cout << A[i] << " ";
    cout << A[n - 1] << endl;
    cout << c << endl;


}


Measured memory_bytes: 3084
//abc168_e.cpp
//Sun May 17 20:36:54 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

//最大公倍数、最大公約数（ユークリッド互除法）
ll gcd (ll a, ll b){ //最大公約数
	if (b == 0){
		return a;
	}
	return gcd(b, a%b);
}

ll mod_pow(ll x, ll n){
	ll res = 1;
	while (n>0){
		if (n&1){
			res = res * x % MOD;
		}
		x = x*x%MOD;
		n >>= 1;
	}
	return res;
}


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

	vector<P> num;
	map<P, ll> mp;
	for (int i=0;i<n;i++){
		ll a,b;
		cin >> a >> b;
		ll kouyaku = gcd(a,b);
		if (kouyaku!=0){
			a = a/abs(kouyaku);
			b = b/abs(kouyaku);
		}
		auto itr = mp.find(P(a,b));
		if (itr != mp.end()){
			mp[P(a,b)]++;
		}else {
			mp[P(a,b)] = 1;
		}
	}

	ll ans = 1;
	ll am = 0;
	ll abzero = 0;
	ll agazero = 0;
	ll bgazero = 0;
	for (auto itr = mp.begin();itr!=mp.end();itr++){
		ll aite = 0;
		P tmp = itr->first;
		if (mp[tmp] == 0){
			continue;
		}
		ll count = mp[tmp];
		ll aa = tmp.first;
		ll bb = tmp.second;
		if (aa==0 && bb==0){
			abzero = count;
			continue;
		}else if (aa==0){
			agazero += count;
			continue;
		}else if (bb==0){
			bgazero += count;
			continue;
		}
		int flag = 1;
//		cout << aa << " " << bb  << " " << count << endl;
		auto itrtmp = mp.find(P(aa*(-1),bb*(-1)));
		if (itrtmp != mp.end()){
			count += mp[P(aa*(-1),bb*(-1))];
			mp[P(aa*(-1),bb*(-1))] = 0;
		}

		itrtmp = mp.find(P(bb,aa*(-1)));
		if (itrtmp != mp.end()){
			aite += mp[P(bb,aa*(-1))];
			mp[P(bb,aa*(-1))] = 0;
			flag = 0;
		}

		itrtmp = mp.find(P(bb*(-1),aa));
		if (itr != mp.end()){
			aite += mp[P(bb*(-1),aa)];
			mp[P(bb*(-1),aa)] = 0;
			flag = 0;
		}

		if (flag){
			am += count;
		}else {
			ll tmptmp = (mod_pow(2,count)+mod_pow(2,aite)+MOD-1)%MOD;
			ans = ans * tmptmp%MOD;
		}
	}

	if (agazero && bgazero){
		ll tmptmp = (mod_pow(2,agazero)+mod_pow(2,bgazero)+MOD-1)%MOD;
		ans = ans * tmptmp%MOD;
	}else {
		am += agazero+bgazero;
	}

	ans = ans * mod_pow(2,am)%MOD;

	ans = (ans+abzero+MOD-1)%MOD;

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 28428
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const int MAX = 100;
int grid[MAX][MAX] = {};

int main(){
   
    for (int i=0;i<50;i++){
        for (int j=0;j<100;j++) {
            grid[i][j] = 0; // black
        }
    }
    for (int i=50;i<100;i++){
        for (int j=0;j<100;j++) {
            grid[i][j] = 1; // white
        }
    }
    int a,b;
    cin  >> a >> b;
    a--;
    b--;
    int i=0;
    int j=0;
    while(a > 0){
        grid[i][j] = 1;
        a--;
        j += 2;
        if(j >= 100){
            j -= 100;
            if(j==0){
                j=1;
            }else{
                j=0;
            }
            i += 2;
        }
    }
    j=0;
    i=99;
    while(b>0){
        grid[i][j] = 0;
        b--;
        j += 2;
        if(j >= 100){
            j -= 100;
            if(j==0){
                j=1;
            }else{
                j=0;
            }
            i -= 2;
        }
    }
    cout << 100 << " " << 100 << endl;
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            if(grid[i][j] == 0){
                cout << "#";
            }else{
                cout << ".";
            }
        }
        cout << endl;
    }

}

Measured memory_bytes: 256
#include<cstdio>
int main(){int n,i,j,s,m,a[5000];while(scanf("%d",&n)&&n){for(i=0;i<n;i++)scanf("%d",&a[i]);m=-2147483647;for(i=0;i<n;i++,s=0)for(j=i;j<n;)if((s+=a[j++])>m)m=s;printf("%d\n",m);}}

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

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (1000006)
#define INF (1LL << 60)
const int MOD = (int)1e9+7;


signed main(){
    string X;
    cin >> X;
    int n = X.length();

    int a = (X[n-1]-'0')+(X[n-2]-'0')*10;
    //DEBUG(a);

    int cnt=0, d=5;
    while(a!=0){
        int c = a/d;
        cnt += c;
        a -= c*d;
        //DEBUG3(a,d,cnt);
        d--;
    }

    int cnt100 = atoi(X.c_str())/100;
    if(cnt100 == 0){
        cout << 0 << endl;
        return 0;
    }
    //DEBUG2(cnt,cnt100);
    if(cnt <= cnt100) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N; cin >> N;
    vector<P> pv;
    rep(i, N){
        int a; cin >> a;
        pv.push_back(make_pair(a, i+1));
    }
    sort(all(pv));

    rep(i, N){
        cout << pv[i].second;
        if(i != N-1) cout << " ";
        else cout << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5876
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define init(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, a, b) for (int i = a; i < b; i++)
#define loopr(i, a, b) for (int i = a; i >= b; i--)
#define loops(i, a, b, step) for (int i = a; i < b; i += step)
#define looprs(i, a, b, step) for (int i = a; i >= b; i -= step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie();                        \
    cout.tie();
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

void solve()
{
    ll n;
    cin >> n;
    int h[4] = {0};
    loop(i, 0, n)
    {
        string s;
        cin >> s;
        if (s == "AC")
        {
            h[0]++;
        }
        else if (s == "WA")
        {
            h[1]++;
        }
        else if (s == "TLE")
        {
            h[2]++;
        }
        else
        {
            h[3]++;
        }
    }

    cout << "AC x " << h[0] << "\n";
    cout << "WA x " << h[1] << "\n";
    cout << "TLE x " << h[2] << "\n";
    cout << "RE x " << h[3] << "\n";
}

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

Measured memory_bytes: 3624
s = gets.chomp
check_all = []
for i in 0..s.length-1
  if s[i] != s[-1-i]
    check_all.push("NO")
  end
end
 
for i in 0..((s.length-1) / 2) - 1
  if s[i] != s[((s.length-1) / 2) - 1 - i]
    check_all.push("NO")
  end
end
 
for i in 0..((s.length-1) / 2) - 1
  if s[i + ((s.length-1) / 2) + 1] != s[-1-i]
    check_all.push("NO")
  end
end
 
if check_all.length > 0 || s.length % 2 == 0
  puts "No"
else
  puts "Yes"
end

Measured memory_bytes: 1788
#include <cstdio>


using namespace std;

int main(int argc, char const *argv[])
{
	int  n=0,s=0 ,e=0,w=0;
	int c ='.';
	while(1){
		c = getchar();
		switch(c){
			case 'N': n=1;break;
			case 'S': s=1;break;
			case 'E': e=1;break;
			case 'W': w=1;break;
		}
		if(c=='\n' || c==EOF){
			break;
		}
	}

	if(n-s==0 && e-w == 0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import sys
from collections import deque

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

A,B = LI()

print(A*B)



Measured memory_bytes: 64692
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int n = ni();
		int m = ni();
		long count = 0;
		for (int i = 0; i < m; i++) {
			count += ni();
		}
		if (count <= n) {
			out(n - count);
		} else {
			out(-1);
		}
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

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

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

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}


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

#define pb push_back

using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;

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

    int a, b;
    cin >> a >> b;
    int sum = a+b;
    if (sum%2)
        cout << "IMPOSSIBLE\n";
    else
        cout << sum/2 << "\n";
}


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

int main(){

    int x,y;
    cin >> x >> y;

    vector<int> a={1,3,5,7,8,10,12};
    vector<int> b={4,6,9,11};
    bool f=false;

    if(find(a.begin(),a.end(),x)!=a.end()){
        if(find(a.begin(),a.end(),y)!=a.end()){
            f=true;
        }
    }else if(find(b.begin(),b.end(),x)!=b.end()){
        if(find(b.begin(),b.end(),y)!=b.end()){
            f=true;
        }
    }

    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct ll{
	int u,v;
};
vector<ll>Ans;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	if(m>(n-1)*(n-2)/2){
		puts("-1");
		return 0;
	}
	for(int i=2;i<=n;i++)Ans.push_back({1,i});
	int k=(n-1)*(n-2)/2-m,i=1;
	while(k){
		i++;
		for(int j=i+1;j<=n;j++){
			if(!k)break;
			Ans.push_back({i,j});
			k--;
		}
	}
	printf("%d\n",Ans.size());
	for(int i=0;i<Ans.size();i++)printf("%d %d\n",Ans[i].u,Ans[i].v);
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

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

    int n;
    cin >> n;
    vi v(1e7 + 1, 0);

    for (int i = 1; i <= 1e7; ++i)
        for (int j = i; j <= 1e7; j += i)
            v[j]++;
    ll ans = 0;
    for (ll i = 1; i <= n; ++i)
        ans += i * v[i];
    cout << ans;
}

Measured memory_bytes: 42248
#![allow(non_snake_case, unused_mut)]
use petgraph::unionfind::UnionFind;
use proconio::marker::Usize1;
use std::collections::HashMap;
use std::collections::HashSet;

fn main() {
    proconio::input! {
        N:usize, M:usize,K:usize,
        AB:[(Usize1,Usize1);M],
        CD:[(Usize1,Usize1);K]
    }
    let mut tree: UnionFind<usize> = UnionFind::new(N);
    let mut friends = vec![HashSet::new(); N];
    let mut blocks = vec![HashSet::new(); N];
    for &(a, b) in AB.iter() {
        tree.union(a, b);
        friends[a].insert(b);
        friends[b].insert(a);
    }
    for &(c, d) in CD.iter() {
        if tree.find(c) == tree.find(d) {
            blocks[c].insert(d);
            blocks[d].insert(c);
        }
    }
    let mut sizes = HashMap::new();
    for i in 0..N {
        *sizes.entry(tree.find(i)).or_insert(0) += 1usize;
    }
    for i in 0..N {
        let ans = sizes.get(&tree.find(i)).unwrap() - 1 - friends[i].len() - blocks[i].len();
        print!("{} ", ans);
    }
}


Measured memory_bytes: 30844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	string s; cin>>s;
	string t=s;
	ll n=s.size();
	vl a(n+1),b(n+1);
	ll cnt=0;
	rep(i,0,n){
		if(s[i]=='<')cnt++;
		else cnt=0;
		a[i+1]=cnt;
	}
	cnt=0;
	for(int i=n-1;i>=0;--i){
		if(s[i]=='>')cnt++;
		else cnt=0;
		b[i]=cnt;
	}
	ll ans=0;
	rep(i,0,n+1)ans+=max(a[i],b[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12168
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> h(N);
  range(i, N) std::cin >> h[i];
  std::vector<int> DP(N);
  DP[0] = 0;
  ranges(i, 1, N){
    DP[i] = 1e9;
    ranges(j,0, min(K, i)){
      DP[i] = min(DP[i], DP[i - j - 1] + abs(h[i] - h[i - j - 1]));
    }
  }
  std::cout << DP[N - 1] << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll t = 0;
  REP(i, 101){
    if(a <= i && i <= b && c <= i && i <= d) t++;
  }
  if(t == 0) cout << 0 << endl;
  else cout << t - 1 << endl;
  return 0;
}


Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
C = []; 10.times{C << gets.split.map(&:to_i)}
A = readlines.map{|l| l.split.map(&:to_i)}
INF = 1e10.to_i

ps = Array.new(10, INF)
ps[1] = 0
q = [[1, 0]]
while d = q.pop
  n = d[0]
  (0 .. 9).each do |m|
    next if m == n
    p1 = C[m][n] + ps[n]
    if p1 < ps[m]
      ps[m] = p1
      q << [m, p1]
      q.sort_by!{|n, p| -p}
    end
  end
end
puts A.flatten.group_by(&:itself).map{|k, v| [k, v.size]}.inject(0){|s, (n, m)| n == -1 ? s : s + ps[n] * m}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
map<int,int>a;
int main(){
	int n,m,x;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&x),++a[x];
	scanf("%d",&m);bool pl=true;
	for(int i=1;i<=m;++i){
		scanf("%d",&x);
		if(a[x]==0){
			pl=false;
			break;
		}
		--a[x];
	}
	if(pl)printf("YES");
	else printf("NO");
	return 0;
} 

Measured memory_bytes: 9600
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

use std::cmp::max;
macro_rules !max {($a :expr $(,) *) =>{{$a } } ;($a :expr ,$b :expr $(,) *) =>{{std ::cmp ::max ($a ,$b ) } } ;($a :expr ,$($rest :expr ) ,+$(,) *) =>{{std ::cmp ::max ($a ,max !($($rest ) ,+) ) } } ;}

fn main() {
   input! {
      n: usize,
      abc: [(usize, usize, usize); n]
   }
   let mut dp = vec![vec![0; n+1]; 3];
   for (i, &(a, b, c)) in abc.iter().enumerate() {
      dp[0][i + 1] = a + max(dp[1][i], dp[2][i]);
      dp[1][i + 1] = b + max(dp[0][i], dp[2][i]);
      dp[2][i + 1] = c + max(dp[0][i], dp[1][i]);
   }
   let ans = max! {dp[0][n], dp[1][n], dp[2][n]};
   println!("{}", ans);
}


Measured memory_bytes: 10492
import sys
input=sys.stdin.readline
s=' '+input().rstrip()
t=' '+input().rstrip()
m=len(s)-1
n=len(t)-1
dp=[[0]*(n+1) for i in range(m+1)]
for i in range(1,m+1):
    for j in range(1,n+1):
        if s[i]==t[j]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
ans=''
while m>0 and n>0:
    if dp[m][n]==dp[m][n-1]:
        n-=1
    elif dp[m][n]==dp[m-1][n]:
        m-=1
    elif dp[m][n]==dp[m-1][n-1]+1:
        ans=s[m]+ans
        m-=1
        n-=1
print(ans)

Measured memory_bytes: 113116
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	ll L;
	int N;
	cin>>L>>N;
	V<ll> q(N+1);
	rep1(i,N) cin>>q[i];
	q.pb(L);
	N++;
	V<ll> x(N);
	rep(i,N) x[i] = q[i+1]-q[i];
	ll ans = 0;
	rep(_,2){
		V<ll> ax(N+1);
		rep(i,N) ax[i+1] = ax[i] + x[i];
		ll sum = ax[N-1];
		auto range = [&](int l,int r){
			return ax[r]-ax[l];
		};
		chmax(ans,sum);
		for(int i=1;i<N-1;i++){
			int A = N-1-i;
			int C = (i+1)/2;
			int B = N-A-C;
			if(i%2==1){
				sum += range(0,A) - range(A,A+B) + range(A+B,N);
			}else{
				sum += range(0,A) - range(A,A+B-1) + range(A+B,N);
			}
			chmax(ans,sum);
		}
		reverse(all(x));
	}
	cout<<ans<<endl;
}

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

int main() {
	int N,a;
  	cin >> N;
  
  	for (int i=0; i < N; i++) {
    	int l, r;
      	cin >> l >> r;
      	a += r - l + 1;
    }
  	cout << a << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		if (arr[1] == 'R') {
		    arr[1] = 'B';
		} else {
		    arr[1] = 'R';
		}
		System.out.println(arr);
	}
}


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

int main() {
	set<string> s;
	char c;
	int N;
	string r = "Yes";
	cin >> N;
	for (int i = 0; i < N; i++) {
		string input;
		cin >> input;
		if (!i) {
			s.insert(input);
			int len = input.length();
			c = input[len-1];
		} else if (r == "Yes") {
			if (s.find(input) != s.end()) {
				r = "No";
			} else if (c != input[0]) {
				r = "No";
			} else {
				s.insert(input);
				int len = input.length();
				c = input[len-1];
			}
		}
	}
	cout << r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ll  long long
#define mod 1000000007
#define ve vector
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define all(v) v.begin(),v.end()
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int inf=1e9+5;


ll power(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b/=2;
	}
	return res;
}





void solve()
{
ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    if(k<a){cout<<k<<endl;return ;}
    if(k>=a)
    {
     ans+=a;
        k-=a;
    }
    if(k<b)
    {
     cout<<ans<<endl;
        return ;
    }
    if(k>=b)
        k-=b;
    if(k>0)
        ans-=k;
    
    cout<<ans<<endl;
   
    
   
}

signed main()
{
//#ifndef ONLINE_JUDGE
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
//#endif
    FAST;

     int t=1;
    // cin>>t;
     while(t--)
    	solve();
    return 0;
}



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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

ll bin_pow(ll x, ll n, ll mod){
	ll res = 1LL;
	for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
	return res;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; string x;
	cin >>n >>x;
	const int mx =  2002000;
	VI san(mx+5);
	rep2(i, 1, mx+1){
		int p=0;
		for(int w=i; w>0; ){
			w = w % __builtin_popcount(w);
			p++;
		}
		san[i] = p;
	}
	int pcct=0;
	rep(i, n) pcct += x[i] =='1';
	int pctp=pcct+1, pctm=pcct-1;
	ll smp=0, smm=0;
	rep(i, n){
		if(pctm !=0) smm = (smm * 2 + (x[i]=='1')) % pctm;
		smp = (smp * 2 + (x[i]=='1')) % pctp;
	}
	//dbg("sm",smp, smm,"ct",pcct,pctp, pctm);
	rep(i, n){
		ll cnd =0;
		if(x[i]=='1'){
			if(pctm==0){
				cout << 0 <<"\n";
			}
			else{
				cnd =( smm + pctm - bin_pow(2, n-1-i,pctm))%pctm;
				cout << san[cnd] +1 <<"\n";
			}
		}else{
				cnd =( smp + pctp + bin_pow(2, n-1-i,pctp))%pctp;
				cout <<san[cnd] +1 <<"\n";
		}
	}
	
	return 0;
}


Measured memory_bytes: 11320
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    if b[i] <= a[i]:
        ans += b[i]
    elif b[i] <= a[i] + a[i+1]:
        a[i+1] = a[i+1] + a[i] - b[i]
        ans += b[i]
    else:
        ans += a[i] + a[i+1]
        a[i+1] = 0
print(ans)

Measured memory_bytes: 18624
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
#define N 100009
#define LL long long
#define INF 0x7fffffff
#define mymin(x,y) (x>=y?y:x)
#define mymax(x,y) (x>=y?x:y)
int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	LL s;
	cin >> s;
	LL n = sqrt(s);
	if (n * n == s) {
		cout << 0 << " " 
			<< 0 << " " 
			<< n << " " 
			<< 0 << " " 
			<< 0 << " " 
			<< n;
	}
	else {
		n++;
		LL cha = n * n - s;
		if (cha > n) {
			cout << 0 << " " << 0 << " " << 1 << " " << n - 1 << " " << n << " " << cha - n;
		}
		else {
			cout << 0 << " " << 0 << " " << 1 << " " << n << " " << n << " " << cha;
		}
	}
	return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main()
{
    int n; cin >> n;
    int k; cin >> k;
    string s; cin >> s;
    int offset = 'a' - 'A';

    s[k - 1] = s[k - 1] + offset; 

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    int N,M;
    cin >> N >> M;
    if(N == M) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main
{
    static class Len
    {	
	int a[]; //= new int[2000010];
	int b[]; //= new int[2000010];
	
	Len(int n)
	{
	    a = new int[n+1];
	    b = new int[n+1];
	}
	

    }

    public static void main(String args[])
    {
	int n;
	int i, j, k;

	String line = new String();
	BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));

	//Read ----------------
	//Read n
	try{
	    line=line=bin.readLine();
	}	
	catch(IOException e){
	    System.out.println("Error");
	}

	n=Integer.parseInt(line);
	Len len = new Len(n);
	j=0;
	//Read A[]
	try{
	    line=bin.readLine();
	    //System.out.println(line);
	    StringTokenizer str = new StringTokenizer(line);   
	    for(i=0; i<n; i++)
		{
		    len.a[i]=Integer.parseInt(str.nextToken());
		    if(j<len.a[i])j=len.a[i];
		}
	}
	catch(IOException e){
	    System.out.println("Error");
	}

	//bin=null;

	//Read end------------


	//sort
	countingSort(len, j, n);

	//print
	StringBuffer s = new StringBuffer(80000);
	for(i=1; i<=n; i++)
	    {
		s.append(len.b[i]);
		if(i!=n)s.append(" ");
	    }
	System.out.println(s);

    }

    static void countingSort(Len len, int max, int n)
    {
	int i, j, k;
	int[] c = new int[max+1];

	for(i=0; i<n; i++)c[len.a[i]]++;

	for(i=0; i<=max; i++)
	    {
		if(i!=0)c[i]+=c[i-1];
	    }

	for(i=n-1; i>=0; i--)
	    {
		len.b[c[len.a[i]]]=len.a[i];
		c[len.a[i]]--;
	    }
    }
}

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
	int n, k;
	cin >> n >> k;
	int z = n/2 + n%2;
	if(k <= z)
		cout << "YES\n";
	else cout << "NO\n";
	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++)

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    int answer_num = 0;
    int count = 1;
    rep(i, n)
    {
        if (a.at(i) == count)
        {
            count++;
        }
        else
        {
            answer_num++;
        }
    }

    if (count == 1)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << answer_num << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

using Pint = pair<ll, int>;
vector<vector<Pint>> g (100005);
int n;
ll seen[100005];
void dijkstra (int k) {
    priority_queue<Pint, vector<Pint>, greater<Pint>> pq;
    rep (i, 0, n) seen[i] = INF;
    seen[k] = 0;
    pq.push ({0, k});
    while (!pq.empty()) {
        Pint p = pq.top();
        pq.pop();
        int v = p.second;
        if (seen[v] < p.first) continue;

        rep (i, 0, g[v].size()) {
            Pint q = g[v][i];
            if (seen[q.second] > seen[v] + q.first) {
                seen[q.second] = seen[v] + q.first;
                pq.push ({seen[q.second], q.second});
            }
        }
    }
}

int main() {
    cin >> n;
    rep (i, 0, n - 1) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        g[--a].push_back ({c, --b});
        g[b].push_back ({c, a});
    }
    int q, k;
    cin >> q >> k;
    dijkstra (--k);
    while (q--) {
        int a, b;
        cin >> a >> b;
        cout << seen[--a] + seen[--b] << "\n";
    }
    // rep (i, 0, n) cout << seen[i] << "\n";
}

Measured memory_bytes: 11120
int main(int argc, const char * argv[]) {
    int A,B,C,D;
    int s, n;
    
    scanf("%d\n",&A);
    scanf("%d\n",&B);
    scanf("%d\n",&C);
    scanf("%d\n",&D);
    
    s = A*B;
    n = C*D;
    
    if(s>n){
        printf("%d\n",s);
    }
    
    else if(n>s){
        printf("%d\n", n);
    }
    
    else{
        printf("%d\n",A*B);
    }
    return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
typedef long long int ll;
using namespace std;

ll abso(ll n)
{
	if (n<0)
	return (-1*n);
	else
	return n;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll h[n+5];
    ll a[n+5]={0};
    for (ll i=1;i<=n;i++)
    {
    	cin>>h[i];
	}
    
    a[2]=(abso(h[1]-h[2]));
    
    
	 for (ll i=3;i<=n;i++)
   {
   	ll x=min(a[i-2]+abso(h[i]-h[i-2]),a[i-1]+abso(h[i]-h[i-1]));
   	a[i]=x;
	   }
	   cout<<a[n]<<endl;	

}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N           100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;
void self_max(ll  &a, ll b) {
        a = max(a, b);
}
int main() {
        int n, w;
        cin>>n>>w; 
        vector<ll> dp(w + 1); 
        for(int i = 0; i < n; ++i) {
                int weight, value;
                cin>>weight>> value;
                for(int wt = w - weight;   wt >= 0; wt--) {
                        self_max(dp[wt + weight], dp[wt] + value);
                }
        }
        cout<<dp[w]<<endl;
} 

Measured memory_bytes: 1024
#include <iostream>

using namespace std;



int main(){
    int N, A, B; 
    int train, taxi;

    //入力
    cin >> N >> A >> B;

    taxi=B;
    train=A*N;

    if(taxi<train){
        cout << taxi << endl;
    } else {
    cout << train << endl;
    }
    

    
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  set<int> se;
  while (n--) {
    int a;
    cin >> a;
    if (se.count(a)) {
      cout << "NO\n";
      exit(0);
    }
    se.insert(a);
  }
  cout << "YES\n";
}


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

using namespace std;

int main() {

	string S;
	cin >> S;

	
	int a = S.size();
	for (int i = 0; i < 2; i++){
      int cou=0;

		for (int j = 0; j < S.size(); j++)
		{
			if (j % 2 == 0 && S[j] != (char)(i + '0')) cou++;
			if (j % 2 == 1 && S[j] == (char)(i + '0')) cou++;
		}

		a = min(a, cou);
	}

	cout << a << endl;
}



Measured memory_bytes: 3704
N,M = map(int,input().split())
list_list = [list(map(int,input().split())) for i in range(N)]

count = 0

for i in range(1,M+1):
  flg = True
  for list in list_list:
    if i in list[1:]:
      continue
    else:
      flg = False
      break
  if flg == True:
  	count += 1
print(count)
      


Measured memory_bytes: 3060