akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int n, q;
	cin >> n;
	vector<int> a(n);
	for (int& i : a) cin >> i;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		int b, e, t;
		cin >> b >> e >> t;
		for (int i = 0; i < e - b; ++i) swap(a[b + i], a[t + i]);
	}
	cout << a[0];
	for (int i = 1; i < n; ++i) cout << ' ' << a[i];
	cout << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    string s;
    cin>>s;
    ll n = s.length();
    ll ans = 1e9;
    
    for(ll i = 0; i<=n-3; i++){
        ll a = s[i] - '0';
        ll b = s[i+1] - '0';
        ll c = s[i+2] - '0';
        ll x = 100*a + 10*b +c;
        ans = min({ans, abs(753-x)});
    }
    cout << ans << endl;
    return 0;
}


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

int n;
LL m,a[maxn],sm[maxn];

LL check(int mid){
	LL c=0;
	for(int i=n,j=1;i>=1;i--){
		for(;j<=n && a[i]+a[j]<mid;j++);
		c+=n-j+1;
	}
	return c;
}

int main(){
	scanf("%d%lld",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=n;i>=1;i--) sm[i] = sm[i+1] + a[i];
	int L=1,R=200000,mid;
	for(;L<R;){
		mid=(L+R+1)>>1;
		LL c = check(mid);
		if(c>=m) L=mid;
		else R=mid-1;
	}
	LL t = check(L);
	LL ans = -1ll * L * (t - m);
	for(int i=n,j=1;i>=1;i--){
		for(;j<=n && a[i]+a[j]<L;j++);
		ans += sm[j] + a[i] * (n-j+1ll); 
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
 
ll t,x;

int main()
{
    
    Fast;
    cin>>x;
    cout<<(x/500)*1000 + ((x%500)/5)*5<<endl;
}

Measured memory_bytes: 256
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll R=2e5+69, INF=2e9+6969;

string s,t;
int n,m;

int main()
{
	cin >> s >> t;
	n = s.size();
	m = t.size();
	int ans = m;
	for(int i=0;i<=n-m;++i)
	{
		int cur = 0;
		for(int j=0;j<m;++j)
		{
			if(t[j]!=s[i+j]) cur++;
		}
		ans = min(ans,cur);
	}
	printf("%d\n", ans);
	return 0;
}


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

signed main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int R = 0;
  int B = 0;
  for( int i = 0; i < N; i++ ){
    if( S.at(i) == 'R' ) R++;
    else B++;
  }
  if( R > B ) cout << "Yes" << endl;
  else cout << "No" << endl;
      
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e6 + 5;
ll a[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int d, n;
    cin >> d >> n;
    if(n == 100) n++;
    cout << n;
    for(int i = 0; i < 2 * d; i++) cout << 0;
return 0;
}


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

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main()
{
	int i,j,k;
	long long solution = 0;
	int K;
	cin >> K;
	for(i=1;i<=K;i++)
	{
		for(j=1;j<=K;j++)
		{
			for(k=1;k<=K;k++)
			{
				solution += gcd(gcd(i,j),k);
			}
		}
	}
	cout << solution;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
	fast;
	ll x=5;
	vector<ll> a(x);
	
	for(int i=0;i<x;i++)
		cin>>a[i];
	ll k;
  	cin>>k;
  	if(a[4]-a[0]>k)
      	cout<<":(";
  	else
      	cout<<"Yay!";
  
	return 0;
}


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

using namespace std;
 
//#define int long long
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=0;i<=n;i++)
#define PI 3.14159265358979323846264338327950L

ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    ios_base::sync_with_stdio(false);
    long double a,b,h,m;
    cin >> a >> b >> h >> m;
    long double rad = 2*PI*((m/60.0)-(h/12.0+m/720.0));
    cout << fixed << setprecision(10) << sqrtl(a*a+b*b-2*a*b*cosl(rad)) << endl;
    return 0;
}


Measured memory_bytes: 4140
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int N;
	cin >> N;

	int A;
	bool jdg = true;

	for (int i = 0; i < N; i++) {
		cin >> A;
		if (A % 2 == 0) {
			if (A % 3 == 0) {
				continue;
			}
			else if (A % 5 == 0) {
				continue;
			}
			else {
				jdg = false;
				break;
			}
		}
		else {
			continue;
		}
	}

	if (jdg == true) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}

	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 N = sc.nextInt();
        int M = sc.nextInt();
        int[] inDegree = new int[N];
        List<Integer>[] edge = new ArrayList[N];
        for(int i = 0; i < N; i++) {
            edge[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < M; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            edge[x-1].add(y-1);
            inDegree[y-1]++;
        }
        //queue for zero indegree nodes
        LinkedList<Integer> queue = new LinkedList();
        for (int i = 0; i < N; i++) {
            if (inDegree[i] == 0) {
                queue.offerLast(i);
            }
        }
        long[] dp = new long[N];
        while (queue.size() > 0) {
            int v = queue.pollFirst();
            for (int w : edge[v]) {
                dp[w] = Math.max(dp[w], dp[v] + 1);
                if(--inDegree[w] == 0) {
                    queue.offerLast(w);
                }
            }
        }

        long ans=0;
        for (int i = 0; i < N; i++) {
            ans = Math.max(ans, dp[i]);
        }
    
        System.out.println(ans);
    }
}

Measured memory_bytes: 99008
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, K = MAP()

mod = 10**9+7

cnt = [0]*K


for i in reversed(range(1, K+1)):
    a = pow(K//i, N, mod)
    cnt[i-1] = a

    b = 2
    while b*i <= K:
        cnt[i-1] -= cnt[b*i-1]
        b += 1

ans = 0
for i in range(K):
    ans += (i+1)*cnt[i] % mod

print(ans % mod)

Measured memory_bytes: 74368
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    int ar[n+4] = {};
    map<ll, int>mm;
    for(int i = 0; i < n; i++)
    {
        ll p;
        cin >> p;
        mm[p]++;
    }
    bool ok = true;
    for(auto it = mm.begin(); it != mm.end(); it++)
    {
        if(it->second > 1)
        {
            ok = false;
            break;
        }
    }
    if(ok)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;


typedef long long lint, ll;
typedef long double ldouble, ld;

#ifdef LOCAL
	#define dbg(expr) cerr << "[" << __LINE__ << "] " << #expr << " = " << (expr) << '\n';
#else
	#define dbg(expr) (void) 0;
#endif


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

    lint r, g;
    cin >> r >> g;
    cout << g + (g - r) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	while(true)
	{
		int n1, n2;
		cin >> n1 >> n2;

		if (n1 > 0 || n2 > 0)
		{
			if (n1 < n2)
				cout << n1 << " " << n2 << endl;
			else
				cout << n2 << " " << n1 << endl;
		}
		else break;
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MOD = 998244353;

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int k, n;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += a[i];
    }
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 3648
def main():
    n = int(input())
    x = [list(map(int,input().split())) for i in range(n)]
    st = sorted([(i[0]-i[1],i[0]+i[1]) for i in x], key=lambda x:(x[1]))
    cnt = 0
    idx = -10**10
    for i in range(n):
        if idx <= st[i][0]:
            cnt += 1
            idx = st[i][1]
    print(cnt)

if __name__ == '__main__':
    main()


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, M;
	cin >> N >> M;
	string S;
	cin >> S;
	vector<ll> G[201010];
	REP(i, M){
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<ll> A(201010, 0), B(201010, 0);
	REP(i, N){
		REP(j, G[i].size()){
			if(S[G[i][j]]=='A') A[i]++;
			else B[i]++;
		}
	}
	queue<ll> bad;
	vector<ll> badis(201010, 0);
	REP(i, N){
		if(A[i]<1||B[i]<1) bad.push(i), badis[i]=1;
	}
	while(!bad.empty()){
		ll now = bad.front();
		bad.pop();
		REP(i, G[now].size()){
			ll next = G[now][i];
			if(S[now]=='A') A[next]--;
			else B[next]--;
			if((A[next]<1||B[next]<1)&&badis[next]==0) bad.push(next), badis[next]=1;
		}
	}
	ll res = 0;
	REP(i, N) if(badis[i]==1) res++;
	cout << (res==N?"No":"Yes") << endl;
    return 0;
}

Measured memory_bytes: 17412
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()

abc = [na() for i in range(n)]
dp = [3 * [0] for i in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(n - 1):
    for j in range(3):
        for k in range(3):
            if k != j:
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + abc[i + 1][j])

ans = max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2])
print(ans)

Measured memory_bytes: 70364
import sys
input = sys.stdin.readline

def main():
    N, M = [int(x) for x in input().split()]

    A = []
    for i in range(M):
        A.append([int(x) for x in input().split()])

    answer = A[0]
    for i in range(1, M):
        if max(answer) < min(A[i]) or max(A[i]) < min(answer):
            print(0)
            exit()

        total = []
        total.extend(answer)
        total.extend(A[i])
        s_total = sorted(total)
        answer = s_total[1:3]

    print(answer[1] - answer[0] + 1)




if __name__ == '__main__':
    main()



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

int main() {
	int A,B,K;
  	cin >> A >> B >> K;
  
  	vector<int> vec(1,1);
  	int min = A;
  	if(min > B) min = B;
  
  	for(int i = 2; i <= min; i++) {
    	if(A % i == 0 && B % i == 0) {
        	vec.push_back(i);
        }
    }
  
  	reverse(vec.begin(),vec.end());
      cout << vec.at(K - 1) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<math.h>
#define N 1000000
typedef struct{
  bool value;
  bool dis;
}prime_t;

prime_t prime[N];

void init()
{
  int i;
  for(i=0;i<N;i++)
    {
      prime[i].dis = false;
    }
}

bool is_prime(int n)
{
  if(n == 0 || n == 1) return false;
  if(n == 2) return true;
  if(prime[n].dis==true) return prime[n].value;
  int i;
  for(i=2;i<=sqrt(n);i++)
    {
      if(n%i==0)
	{
	  prime[n].value=false;
	  prime[n].dis=true;
	  return prime[n].value;
	}
    }
  prime[n].value=true;
  prime[n].dis=true;
  return prime[n].value;
}

int main()
{
  int n;
  init();
  while(scanf("%d",&n)!=EOF)
    {
      int i,count=0;
      for(i=0;i<=n;i++){
	if(is_prime(i)) count++;
      }
      printf("%d\n",count);
    }
  return 0;
}

Measured memory_bytes: 2548
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        var S = ReadLine();
        var T = ReadLine();
        if (S[0] == T[2] && S[1] == T[1] && S[2] == T[0])
        {
            WriteLine("YES");
        }
        else
        {
            WriteLine("NO");
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
ll evaluate(VV& S, ll d, V& prev, V& C, ll j) {
    ll temp = 0;
    temp += S[d][j];
    rep(k, 26) {
        if (j == k) {
            continue;
        }
        temp -= C[k] * (d - prev[k]);
    }
    return temp;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll d;
    cin >> d;
    V C(26);
    rep(i, 26) cin >> C[i];
    VV S(d, V(26));
    rep(i, d) { rep(j, 26) cin >> S[i][j]; }
    ll width = 600;
    vector<tuple<ll, V, V>> vec;
    V temp;
    rep(i, 26) temp.push_back(-1);
    V temp2;
    vec.push_back({0, temp, temp2});
    rep3(i, 0, d) {
        priority_queue<tuple<ll, V, V>> q;
        for (auto j : vec) {
            ll score = get<0>(j);
            V prev = get<1>(j);
            V history = get<2>(j);
            rep(k, 26) {
              bool f=false;
                for(int g=history.size()-1,h=0;h<15&&g>=0;h++,g--){
                    if(!history.empty()&&history[g]==k){
                      f=true;
                      break;
                    }
                }
                if(f)continue;
                ll value = evaluate(S, i, prev, C, k);
                ll prev2 = prev[k];
                
                prev[k] = i;
                history.push_back(k);
                q.push({score + value, prev, history});
                history.pop_back();
                prev[k] = prev2;
            }
        }
        vec = {};
        for (ll j = 0; j < width && !q.empty(); j++) {
            vec.push_back(q.top());
            q.pop();
        }
    }
    for (auto i : get<2>(vec[0])) {
        cout << i + 1 << endl;
    }
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
    int n;
    cin>>n;
    double x[15];
    string u[15];
    double ans=0;
    rep(i,n){
        cin>>x[i]>>u[i];
        if(u[i]=="JPY"){
            ans+=x[i];
        }else{
            ans+=x[i]*380000.0;
            
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define loop1(x,s,e) for(int x=s;x!=e;x+=1-2*(s>e))
#define input_matrix(a,m,n) for(int i=0;i<m;i++)for(int j=0;j<n;j++)cin>>a[i][j];
#define input_array(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define all(x) x.begin(),x.end()
#define newl "\n"
#define tests(t) int t; cin>>t; while(t--)
#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
 {
	int n,k,q,h,score;
	cin>>n>>k>>q;
	map<int,int> m;
	for(int i=0;i<q;i++)
	{
	    cin>>h;
	    h--;
	    m[h]++;
	}
	for(int i=0;i<n;i++)
	{
	    score=(k-q)+m[i];
	    if(score<=0) cout<<"No"<<newl;
	    else cout<<"Yes"<<newl;
	}
	
	return 0;
}

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

using namespace std;

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

const ll mod=1000000007;
const ll inf=1000000000000; 

#define rep(i,m,n) for(ll i=m;i<n;i++)

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

 ll n;
  cin >> n;
  vll q(n);
  rep(i,0,n) {
    ll p;
    cin >> p;
    p--;
    q[p]=i;
  }
  
  ll res=0,num=1;
  rep(i,1,n){
   if(q[i-1]<q[i]) num++;
   else {
     res=max(res,num);
    num=1;
  }
  }
  res=max(res,num);
  
  cout << n-res << endl;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())  # N本のろうそく、K本に火をつけたい
X = list(map(int, input().split()))

ans = 1e+9

for i in range(N-K+1):
    l, r = X[i], X[i+K-1]
    ans = min(ans, min(abs(l), abs(r)) + abs(l-r))

print(ans)


Measured memory_bytes: 14384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string s, t;

int main(void)
{
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if(s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

static const int MAX = 100*100;
int n,l;
int main(void){
    cin >> n >> l;
    int ary[n];
    int diff = MAX;
    for(int i=0;i<n;i++){
        ary[i] = l+(i+1)-1;
    }
    int total;
    total = abs(accumulate(ary,ary+n,0));
    for(int i=0;i<n;i++){
        diff = min(diff,abs(total - (total-abs(ary[i]))));
    }
    int ans;
    total = accumulate(ary,ary+n,0);
    if(total < 0) ans = total+diff;
    else          ans = total-diff;
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, num;
bool table[10][7] = { { 0, 1, 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 1, 1, 0 }, { 1, 0, 1, 1, 0, 1, 1 },
{ 1, 0, 0, 1, 1, 1, 1 }, { 1, 1, 0, 0, 1, 1, 0 }, { 1, 1, 0, 1, 1, 0, 1 }, { 1, 1, 1, 1, 1, 0, 1 },
{ 0, 1, 0, 0, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 0, 1, 1, 1, 1 } };

int main(){
	while (cin >> n&&n != -1){
		bool a[7] = { 0, 0, 0, 0, 0, 0, 0 };
		REP(i, n){
			cin >> num;
			REP(j, 7){
				bool f = a[j] ^ table[num][j];
				cout << f;
				a[j] = table[num][j];
			}
			cout << endl;
			
		}
	}
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	string s; cin>>s;

	int ans=0;
	for(char c:s) ans+=c-'0';
	ans=max<int>(ans,(s[0]-'1')+9*(s.length()-1));
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list([input() for i in range(n)])
q = [''.join(sorted(x)) for x in s]

c = 0
c1 =  0
p = sorted(q)
p.append("a")

for i in range(n):
	if p[i] == p[i+1]:
		c+=1
	else:
		
		if c>0:
			for j in range(c+1):
				c1+=j
				
		c=0
print(c1)

Measured memory_bytes: 18444
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m;i < n;i++)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define fi first
#define se second
const int inf = 1e9;

char str[101][101];
int main(){
	int a, b;
	scanf("%d%d",&a,&b);
	printf("%d %d\n", 100, 100);
	rep(i,50)rep(j,100)str[i][j] = '#';
	REP(i,50,100)rep(j,100)str[i][j] = '.';
	
	for(int i = 1;i < 50;i+=2){
		for(int j = 0;j < 100;j+=2){
			if(a == 1){
				i = 500;
				break;
			}
			str[i][j] = '.';
			a--;
		}
	}
	for(int i = 51;i < 100;i+=2){
		for(int j = 0;j < 100;j+=2){
			if(b == 1){
				i = 500;
				break;
			}
			str[i][j] = '#';
			b--;
		}
	}
	rep(i,100){
		rep(j,100)printf("%c", str[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
const int N = 2e5 + 10 ;
int a[N] , b[N] , c[N] , d[N] ;
int n , m ;
int h[N * 2] , ne[N * 2] , e[N * 2] , w[N * 2] , vis[N * 2] ;
int idx , use[N] ;
int get(int x)
{
  return lower_bound(d + 1 , d + n + 1 , x) - d ;
}
void add(int a , int b , int c)
{
  e[idx] = b , ne[idx] = h[a] , w[idx] = c ,  h[a] = idx ++ ;
}
int dfs(int u)
{
  vis[u] = 1 ;
  int x = c[u] ;
  for(int i = h[u] ; ~i ; i = ne[i])
   {
     int v = e[i] ;
     if(!vis[v] && dfs(v))
      x ^= 1 , use[w[i]] = 1 ;
   }
  return x ;
}
int main()
{
  for(int i = 0 ;i < N ;i ++) h[i] = -1 ;
  ios::sync_with_stdio(false) ;
  cin.tie(0) , cout.tie(0) ;
  cin >> n >> m ;
  for(int i = 1; i <= n ; i ++) cin >> a[i] >> b[i] , d[i] = a[i] ;
  sort(d + 1 , d + n + 1) ;
  for(int i = 1; i <= n ;i ++)
   c[get(a[i])] = b[i] ;
  for(int i = n + 1; i >= 1 ;i --) c[i] ^= c[i - 1] ;
  for(int i = 1; i <= m ;i ++)
   {
     int l , r ;
     cin >> l >> r ;
     l = get(l) , r = lower_bound(d + 1 , d + n + 1 , r + 1 ) - d  ;

  //   cout << r << " rr " ;

     if(l <= r)
     add(l , r  , i) , add(r  , l , i) ;
   }
   // puts("") ;
   for(int i = 1; i <= n + 1 ;i ++)
    if(!vis[i] && dfs(i))
     {
       cout << -1 << endl ;
       return 0 ;
     }
     int ans =  0 ;
     for(int i = 1; i <= m ;i ++)
      if(use[i]) ans ++ ;
    cout << ans << endl ;
    for(int i = 1;i <= m ;i ++)
     if(use[i])
      cout << i << " " ;
}


Measured memory_bytes: 12544
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	char kata[5][5];
	
	for (int a=0;a<3;a++){
		scanf ("%s",kata[a]);
		getchar();
	}	
	
	printf ("%c%c%c\n",kata[0][0],kata[1][1],kata[2][2]);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
 
 
 
int n;
 
 
void solve()
{
    int d_1 = n % 10;
    int d_10 = (n - d_1) % 100 / 10;
    int d_100 = (n - d_1 - d_10) % 1000 / 100;
    if(d_1 == 7 || d_10 == 7 || d_100 == 7) cout << "Yes";
    else cout << "No";
}
 
int main()
{
    cin >> n;
    
    solve();
 
 
    return EXIT_SUCCESS;
}

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

int getSum(int);

int main()
{
	int N;
	cin >> N;
	int ans=getSum(N);
	cout << ans << endl;
	return 0;
}

int getSum(int n)
{
	vector<int> a;
	while (n!=0)
	{
		a.push_back(n % 10);
		n /= 10;
	}
	int sum = 0;
	for (size_t i = 0; i < a.size(); i++)
	{
		sum += a[i];

	}
	return sum;
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	set<string> s;
	int k;
	cin >> k;
	REP(i, k){
		string hoge;
		cin >> hoge;
		s.insert(hoge);
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 19260
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s.back() << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for(int i = 1; i <= n; i++){
    int p = i;
    double a = 1.0 / n;
    while(p < k){
      p *= 2;
      a /= 2;
    }
    ans += a;
  }
  printf("%.12f", ans);
}

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

int main() {
  int n; cin >> n;
  vector<string> blue(n); for(int i = 0; i < n; i++) cin >> blue[i];
  int m; cin >> m;
  vector<string> red(m); for(int i = 0; i < m; i++) cin >> red[i];
  int ans = 0, cntn=0, cntm=0;
  auto calc = [&](string s) {
    int buf = 0;
    for(string t: blue) {
      if( t == s ) buf++;
    }
    for(string t: red) {
      if( t == s ) buf--;
    }
    return buf;
  };

  for(string t: blue) {
    ans = max(ans, calc(t));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);


int main(void) {
	ll a, b, c;
	cin >> a >> b >> c;
	ll left = 4 * a * b;
	ll right = (c - a - b) * (c - a - b);
	string ret = "No";
	if (left < right)
		ret = "Yes";
	if (max(a, b) >= c)
		ret = "No";
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		ArrayList<Integer> u = new ArrayList<Integer>();
		for(int i = 0; i < 3; i++) {
			int p = sc.nextInt();
			if(!u.contains(p)) {
				u.add(p);
			}
		}
		System.out.println(u.size());
	}

}


Measured memory_bytes: 21972
#refer https://onlinejudge.u-aizu.ac.jp/solutions/problem/NTL_1_A/review/2821138/vjudge2/Python3
def prime_factorize(n):
    res = []
    a = 2
    while a*a <= n:
        if n % a == 0:
            while n % a == 0:
                n //= a
                res.append(str(a))
        a += 1
    
    if n != 1:
        res.append(str(n))

    return res

n = int(input())
ans = prime_factorize(n)

print(str(n) + ": " + " ".join(ans))




Measured memory_bytes: 5596
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	int C[510], S[510], F[510];
	cin >> N;
	for (int i = 0; i < N-1; ++i) {
		cin >> C[i] >> S[i] >> F[i];
	}
	for (int i = 0; i < N; ++i) {
		int t = 0;
		for (int j = i; j < N - 1; ++j) {
			if (t < S[j]) {
				t = S[j];
			}
			else if ((t-S[j])%F[j]==0);
			else {
				t = t + F[j] - (t-S[j])% F[j];
			}
			t += C[j];
		}
		cout << t << endl;
	}
	return 0;
}

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

using namespace std;

int m1, d1, m2, d2;

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

    cin >> m1 >> d1 >> m2 >> d2;

    if(m1 != m2)
        cout << "1";
    else
        cout << "0";

    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,M,ans,r,a;

pair<LL, LL>bc;
vector<pair<LL, LL>>BC;
int main() {

	LL num;
	ans = 100000000;
	cin >> N;
	for (LL i = 1; i <= sqrt(N); i++) {
		if (N%i == 0) {
			a = max(i, N/i);
			num = 0;
			while (a!=0) {
				a = a / 10;
				num++;
			}
			ans = min(ans, num);
		}
	}
	
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 384
def parse(line):
    params = line.split(' ')
    node = params[0]
    n_node = params[1]
    nodes = [int(p) for p in params[2:]]
    return node, n_node, nodes


def main():
    n = int(input().strip())

    for _ in range(n):
        line = input().strip()
        _, _, nodes = parse(line)
        out = ''
        for i in range(n):
            if i + 1 in nodes:
                out += '1'
            else:
                out += '0'

            if i < n - 1:
                out += ' '
        print(out)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5604
#include <vector>
#include <string>
#include <iostream>
#include <stdlib.h> // @atoi
using namespace std;

int ConvStrToInt(std::string checkStr)
{
	return atoi(checkStr.c_str());
}
int ConvStrToInt(char c)
{
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
std::string ConvIntToStr(int checkNum)
{
	return std::to_string(checkNum);
}

int GetDigitSum(int aaa)
{
	string str = ConvIntToStr(aaa);
	int tmp = 0;
	for (int i = 0; i < str.size(); ++i)
	{
		tmp += ConvStrToInt(str[i]);
	}
	return tmp;
}

int main(void)
{
	int value, first, last;

	cin >> value >> first >> last;

	int totalSum = 0;
	for (int i = 0; i <= value; ++i)
	{
		int result = GetDigitSum(i);
		if (first <= result && result <= last)
		{
			totalSum += i;
		}
	}

	cout << totalSum << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


A, B =  map(int, sys.stdin.readline().split())
S =  sys.stdin.readline().rstrip()

if S[A] != '-':
    print("No")
    exit()

X = map(int, S[:A:])
try:
    X = list(map(int, S[:A:]))
    Y = list(map(int, S[A + 1::]))
except:
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 64364
#include<cstdio>
using namespace std;
int main(void)
{
	unsigned int i,j,k,c[3]={4,2,1},x;
	int a[10001][8],s,d,f,g,h;
	char z[10001];
	
	
	scanf("%d",&f);
	scanf("%s",z);
	if(z[0]=='J')	x=4;
	else if(z[0]=='O')	x=2;
	else if(z[0]=='I')	x=1;
	for(i=0;i<f;i++){
		for(j=0;j<8;j++)
			a[i][j]=0;
	}
	for(i=1;i<8;i++){
		d=i&4;
		s=i&x;
		if(s==x&&d==4)
			a[0][i]=1;
	}
	for(i=1;i<f;i++){
		if(z[i]=='J')	x=4;
		else if(z[i]=='O')	x=2;
		else if(z[i]=='I')	x=1;
		for(j=1;j<8;j++){
			for(k=1;k<8;k++){
				s=j&x;
				d=j&k;
				if(s!=0&&d!=0)
					a[i][j]+=a[i-1][k];
			}
			a[i][j]%=10007;
		}
	}
	h=0;
	for(i=0;i<8;i++)
		h+=a[f-1][i];
	h%=10007;
	printf("%d\n",h);
	return 0;
}

Measured memory_bytes: 2744
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int n,m;vvi g(mxn+1),t(mxn+1);vi d(mxn+1),u(mxn+1);
void dfs(int i,int p){
	d[i]=1;
	for(auto j:g[i]){
		if(j-p){
			t[i].pb(j);
			dfs(j,i);
			d[i]=(d[i]*(d[j]+1))%m;
		}
	}
}void dfs1(int i,int p){
	u[i]=(u[i]*u[p]+1)%m;
	for(auto j:g[i]) if(j-p) dfs1(j,i);
}
int main(){
	int a,v,i;cin>>n>>m;for(i=1;i<n;i++) cin>>a>>v,g[a].pb(v),g[v].pb(a);
	dfs(1,0);for(i=1;i<=n;i++){
		vi p(t[i].size()+1,1),s(t[i].size()+1,1);
		for(int j=0;j<t[i].size();j++) p[j+1]=(p[j]*(d[t[i][j]]+1))%m;
		for(int j=t[i].size()-1;~j;j--) s[j]=(s[j+1]*(d[t[i][j]]+1))%m;
		for(int j=0;j<t[i].size();j++) u[t[i][j]]=(p[j]*s[j+1])%m;
	}dfs1(1,0);
//	for(i=1;i<=n;i++) cout<<u[i]<<" ";cout<<endl;
	for(i=1;i<=n;i++) cout<<(d[i]*u[i])%m<<endl;
}


Measured memory_bytes: 23104
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cout << #x << " = " << x << endl;
 
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
 
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}
 
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}
 
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();    
    return 0;
}
 
const int MOD = 998244353, MAXN = 2e5 + 10, INF = 1e18 + 10, BASE = 37; 

void solve() {
	int a, v;
	int b, w;
	int T;
	cin >> a >> v >> b >> w >> T;

	if (v <= w) {
	    cout << "NO" << endl;
	    return;
	}	

	if (a < b) {
	 	a += T * v, b += T * w;
	 	if (a >= b) {
	 	 	cout << "YES" << endl;
	 	}
	 	else {
	 	    cout << "NO" << endl;
	 	}	
	}
	else {
	 	a -= T * v, b -= T * w;
	 	if (a <= b) {
	 	 	cout << "YES" << endl;
	 	}                         
	 	else {
	 	 	cout << "NO" << endl;
	 	}
	}
}	

Measured memory_bytes: 3644
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;

class DCaracalVsMonster {
public:
	void solve(std::istream& cin, std::ostream& cout) {
		ll h;cin >> h;
		int i;
		ll ans = 0;
		while(h > 0){
			ans += (1LL << i);
			h /= (ll)2;i++;
		}
		cout << ans << endl;
	}
};


int main() {
	DCaracalVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
vi G[27];
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    int a, b, x;
    cin >> a >> b >> x;
    if(a > x)
        cout << "NO\n";
    else{
        if(a + b >= x)
            cout << "YES\n";
        else
        cout << "NO\n";
    }
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}   

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
#define MOD 1000000007
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	vector <int> A(3);
	cin >> A[0] >> A[1] >> A[2];
	sort(all(A));
	if (A[0] == 5 && A[1] == 5 && A[2] == 7)
		cout << "YES";
	else
		cout << "NO";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j;
    cin>>n;
    map<ll, ll>mp;
    for(i=0;i<n-1;i++)
    {
        cin>>j;
        mp[j]++;
    }
    for(i=1;i<=n;i++)
        cout<<mp[i]<<endl;
    return 0;
}


Measured memory_bytes: 16048
N=int(input())
A=list(map(int,input().split()))
A.sort()
if N%2==1:
    l=[0]
    for i in range(2,N,2):
        l.append(i)
        l.append(i)
else:
    l=[1,1]
    for i in range(3,N,2):
        l.append(i)
        l.append(i)
if A==l:
    print(pow(2,N//2,10**9+7))
else:
    print(0)

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

int main(){
  int N;
  cin >> N;
  int* A = new int[N];
  
  for(int i = 0; i < N; i++)cin >> A[i]; 
  int max = A[0];
  for(int i = 1; i < N; i++){
    if(max < 10){
      cout << "no" << endl;
      return 0;
    }  
    max -= 10;
    if(max < A[i]){
      max = A[i];
    
    }
  }
    max = A[N-1];
 
    for(int i = N-2; i>=0; i--){
    
      if(max < 10){
        cout << "no" << endl;
        return 0;
      }  
      max -= 10;
      if(max < A[i]){
        max = A[i];
      }
    }
    cout << "yes" << endl;
  }



Measured memory_bytes: 4284
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();

		int r = 0;
		int b = 0;
		for (int i = 0; i < n; i++) {
			if (s.charAt(i) == 'R') {
				r++;
			} else {
				b++;
			}
		}
		if (b < r) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll h,w,n;
  cin >> h >> w >> n;
  h=max(h,w);
  ll ans=0,s=0;
  while(s<n) {
    s+=h;
    ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int n;
vector<int> a, b;
vector< vector<int> > c;
vector< vector<ll> > dp;

ll q(int l, int bit) { //return sum
    if (l == 0 && (bit != ((1<<n)-1))) return 1000000005;
    else if (l == 0) dp[l][bit] = 0;
    if (dp[l][bit] != -1) return dp[l][bit];
    bool candi = false;
    rep(i, b[l-1]) {
        int flag = c[l-1][i];
        if (!(bit & (1<<flag))) {
            candi = true;
            break;
        }
    }
    if (candi) {
        int bitp = bit;
        rep(i, b[l-1]) {
            int flag = c[l-1][i];
            bitp |= (1<<flag);
        }
        dp[l][bit] = min(q(l-1,bit), q(l-1,bitp)+a[l-1]);
    }
    else dp[l][bit] = q(l-1, bit);
    return dp[l][bit];
}

int main() {
    int m;
    cin >> n >> m;
    a.resize(m);
    b.resize(m);
    c.resize(m, vector<int>(m));
    rep(i,m) {
        cin >> a[i] >> b[i];
        rep(j,b[i]) {
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    dp.resize(m+5, vector<ll>((1<<n)+5, -1));
    ll res = q(m, 0);
    if (dp[0][(1<<n)-1] == -1) cout << -1 << endl;
    else cout << res << endl;
    return 0;
}

Measured memory_bytes: 36480
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

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

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N;
const ll MAX_N = 100000;
ll d[MAX_N];

int main(){
  cin >> N;
  REP(i, N) cin >> d[i];

  sort(d, d + N);

  cout << d[N / 2] - d[N / 2 - 1] << endl;


  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        System.out.println(problem178a(x));
    }

    private static int problem178a(int x) {
        return 1 - x;
    }
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	llong N;
	vector<vector<lpair>> xy;

	cin >> N;
	xy.resize(N);
	llong A;
	for (auto &in: xy) {
		cin >> A;
		in.resize(A);
		for (auto &i: in) {
			cin >> i.first >> i.second;
			--i.first;
		}
	}

	llong ans = 0;
	for (int i = 0; i < (1<<N); ++i) {
		llong cnt = 0;
		bool check = true;
		for (int j = 0; j < N; ++j) {
			if ((i>>j)&1) {
				++cnt;
				for (auto &t: xy[j]) {
					if (((i>>t.first)&1) != t.second) {
						check = false;
					}
				}
			}
		}

		if (check)
			ans = max(ans, cnt);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static long total = 0;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		calc(1, 0, arr[0] - '0', arr);
		System.out.println(total);
	}
	
	static void calc(int idx, long sum, long add, char[] arr) {
	    if (idx == arr.length) {
	        total += sum + add;
	        return;
	    }
	    int x = arr[idx] - '0';
	    calc(idx + 1, sum + add, x, arr);
	    calc(idx + 1, sum, add * 10 + x, arr);
	}
}


Measured memory_bytes: 21844