akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

/**
 * Created by Ayushi on 03 May 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(br.readLine());
        int[] h = new int[n];
        HashMap<Integer, ArrayList<Integer>> hmap = new HashMap<>();
        int i = 0;
        while (st.hasMoreTokens()) {
            hmap.put(i, new ArrayList<>());
            h[i] = Integer.parseInt(st.nextToken());
            i++;
        }

        int a, b;
        for (int j = 0; j < m; j++) {
            st = new StringTokenizer(br.readLine());
            a = Integer.parseInt(st.nextToken())-1;
            b = Integer.parseInt(st.nextToken())-1;

            //if (!hmap.containsKey(a)) hmap.put(a, new ArrayList<>());
            //if (!hmap.containsKey(b)) hmap.put(b, new ArrayList<>());

            hmap.get(a).add(b);
            hmap.get(b).add(a);
        }
        br.close();

        int ans = 0;
        main:
        for (int j : hmap.keySet()) {
            for (int k : hmap.get(j)) {
                if (h[j] <= h[k]) continue main;
            }
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 73596
#include<bits/stdc++.h>
#define ll long long
const int N = 1010;

struct edge{
	int next, to;
	double w;
};

edge e[2 * N * N];
int first[N], x[N], y[N], r[N], n, cnt = 0;
double dist[N];
bool vis[N];

ll sqr(int _x){
	return 1ll * _x * _x;
}

double dis(int x1, int y1, int x2, int y2){
	return sqrt(sqr(x1 - x2) + sqr(y1 - y2));
}

void addedge(int u, int v, double w){
	e[++ cnt] = {first[u], v, w};
	first[u] = cnt;
	e[++ cnt] = {first[v], u, w};
	first[v] = cnt;
}

std::priority_queue<std::pair<int, int> > pq;  
void dijkstra(int s){
	dist[s] = 0;
	pq.push({- dist[s], s});
	while(!pq.empty()){
		int u = pq.top().second; pq.pop();
		if(vis[u]) continue;
		vis[u] = true;
		for(int j = first[u]; j; j = e[j].next){
			int v = e[j].to;
			double w = e[j].w;
			if(!vis[v] && dist[v] > dist[u] + w){
			    dist[v] = dist[u] + w;
				pq.push({- dist[v], v});
			}
		}
	}
}

int main(){
	int x_s, y_s, x_t, y_t;
	scanf("%d%d%d%d", &x_s, &y_s, &x_t, &y_t);
	scanf("%d", &n);
	for (int i = 0; i < N; ++ i)
		dist[i] = 1e100;
	int s = n, t = n + 1;
	for (int i = 0; i < n; ++ i){
		scanf("%d%d%d", &x[i], &y[i], &r[i]);
	}
	addedge(s, t, dis(x_s, y_s, x_t, y_t));
	for (int i = 0; i < n; ++ i){
		addedge(s, i, std::max(0.0, dis(x_s, y_s, x[i], y[i]) - r[i]));
		addedge(t, i, std::max(0.0, dis(x_t, y_t, x[i], y[i]) - r[i]));
		for (int j = 0; j < n; ++ j){
			if (j == i)
				continue;
			addedge(i, j, std::max(0.0, dis(x[j], y[j], x[i], y[i]) - r[i] - r[j]));
		}
	}
	dijkstra(s);
	printf("%.10lf", dist[t]);
	return 0;
}


Measured memory_bytes: 33780
#![allow(non_snake_case, unused_imports)]

// Input macros
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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $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, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){

    input!{
        C1: chars,
        C2: chars,
        C3: chars,
    }

    println!("{}{}{}", C1[0],C2[1],C3[2]);
}


Measured memory_bytes: 4352
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int q;
    cin >> q;
    while (q--) {
        int k;
        cin >> k;
        int l = lower_bound(all(a), k) - a.begin();
        int r = upper_bound(all(a), k) - a.begin();
        cout << l << " " << r << endl;
    }
}



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

int main()
{
    int code,code1,code2,code3;
    cin >> code1 >> code2 >> code3;
    code = code1 * 100 + code2 * 10 + code3;
    if (code == 110 || code == 001) cout << "Open" << endl;
    else cout << "Close" << endl;
    
    return 0;
}

Measured memory_bytes: 1156
// by The_One_Solver
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int n;
string str,str1,str2;
int main(){
  cin>>str;
  n=str.size();
  str1=str.substr(0,(n-1)/2);
  str2=str.substr((n+1)/2,(n-1)/2);
  if(str1!=str2)	 {cout<<"No";return 0;} 
	  
  for(int i=0;i<(n-1)/2;i++)
{
	if(str[i]!=str[(n-3)/2-i])
	 {cout<<"No";return 0;
	  } 
}
cout<<"Yes";
return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int H, W; string s[1009], t[3], x = "JOI";
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> s[i];
	cin >> t[0] >> t[1];
	int sum = 0;
	for (int i = 0; i < H - 1; i++) {
		for (int j = 0; j < W - 1; j++) {
			bool flag = true;
			for (int k = 0; k < 2; k++) {
				for (int l = 0; l < 2; l++) {
					if (s[i + k][j + l] != t[k][l]) flag = false;
				}
			}
			if (flag) sum++;
		}
	}
	int ret = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char e = s[i][j];
			int a[3] = { 0 }, z = -1;
			for (int c = 0; c < 3; c++) {
				if (x[c] == e) z = c;
				s[i][j] = x[c];
				for (int k = -1; k < 1 && i + k + 1 < H; k++) {
					if (i + k < 0) continue;
					for (int l = -1; l < 1 && j + l + 1 < W; l++) {
						if (j + l < 0) continue;
						bool flag = true;
						for (int m = 0; m < 2; m++) {
							for (int n = 0; n < 2; n++) {
								if (s[i + k + m][j + l + n] != t[m][n]) flag = false;
							}
						}
						if (flag) a[c]++;
					}
				}
			}
			for (int c = 0; c < 3; c++) ret = max(ret, sum + a[c] - a[z]);
			s[i][j] = e;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4152
n=1<<18;N,m;L[1<<18],p;first[1<<18],next[1<<18];i;
long dat[1<<20],lazy[1<<20],A[1<<18],x;
eval(i){
	dat[i]+=lazy[i];
	lazy[2*i+1]+=lazy[i];
	lazy[2*i+2]+=lazy[i];
	lazy[i]=0;
}
long f(a,b,k,l,r){
	eval(k);
	return a<=l&r<=b?dat[k]+(lazy[k]+=x):l<b&a<r?dat[k]=fmax(
		f(a,b,2*k+1,l,(l+r)/2),
		f(a,b,2*k+2,(l+r)/2,r)
	):dat[k];
}
main(j){
	for(scanf("%d%d",&N,&m);~scanf("%d%d%ld",L+j,&p,A+j);first[p]=j++)next[j]=first[p];
	for(;i++<N;){
		x=f(x=0,i,0,0,n);
		f(i,i+1,0,0,n);
		for(p=first[i];p!=0;p=next[p])x=A[p],f(L[p],i+1,0,0,n);
	}
	printf("%ld",f(x=0,i,0,0,n));
}

/*
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
*/

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

int main()
{
  int result[3][3] = {
      {0, 0, 0},
      {0, 0, 0},
      {0, 0, 0},
  };

  int A[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }

  int N;
  cin >> N;

  int b[N];
  for (int i = 0; i < N; i++) {
    cin >> b[i];
  }

  // ビンゴ穴あけ
  for (int bn = 0; bn < N; bn++) {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (b[bn] == A[i][j]) {
          result[i][j] = 1;
        }
      }
    }
  }

  // 横一列ビンゴ判定
  for (int i = 0; i < 3; i++) {
    if (result[i][0] == 1 &&
        result[i][1] == 1 &&
        result[i][2] == 1) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  // 縦一列ビンゴ判定
  for (int j = 0; j < 3; j++) {
    if (result[0][j] == 1 &&
        result[1][j] == 1 &&
        result[2][j] == 1) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  // 斜めビンゴ判定1（えいやあ法）
  if (result[0][0] == 1 &&
      result[1][1] == 1 &&
      result[2][2] == 1) {
    cout << "Yes" << endl;
    return 0;
  }

  // 斜めビンゴ判定2（えいやあ法）
  if (result[0][2] == 1 &&
      result[1][1] == 1 &&
      result[2][0] == 1) {
    cout << "Yes" << endl;
    return 0;
  }

  // ビンゴなし
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    char[][] map = new char[H][W];
    for (int i = 0; i < H; i++) map[i] = scanner.next().toCharArray();
    boolean[][] visited = new boolean[H][W];
    int[][] min = new int[H][W];
    for (int i = 0; i < H; i++) Arrays.fill(min[i], 100000);
    min[0][0] = map[0][0] == '.' ? 0 : 1;
    Queue<Cell> queue = new LinkedList<>();
    queue.add(new Cell(0, 0));
    visited[0][0] = true;
    while (!queue.isEmpty()) {
      Cell c = queue.remove();
      if (c.y < W - 1) {
        Cell next = new Cell(c.x, c.y + 1);
        add(map, visited, min, queue, c, next);
      }
      if (c.x < H - 1) {
        Cell next = new Cell(c.x + 1, c.y);
        add(map, visited, min, queue, c, next);
      }
    }
    System.out.println(min[H - 1][W - 1]);
  }

  private static void add(char[][] map, boolean[][] visited, int[][] min, Queue<Cell> queue, Cell current, Cell next) {
    int cost = 0;
    if (map[current.x][current.y] == '.' && map[next.x][next.y] == '#') cost = 1;
    min[next.x][next.y] = Math.min(min[next.x][next.y], min[current.x][current.y] + cost);
    if (!visited[next.x][next.y]) {
      visited[next.x][next.y] = true;
      queue.add(next);
    }
  }

  private static class Cell {
    final int x;
    final int y;

    private Cell(int x, int y) {
      this.x = x;
      this.y = y;
    }
  }
}


Measured memory_bytes: 27120
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,ans,dp[1000],a,b,ch[1000],A[10000],ok;
vector<ll>v[1000];
vector<ll>v1,v2;
queue<ll>que;
set<ll> se1,se2;
P s[10000];
bool f(ll n,ll m){
    se1={0};
    v2={};
    ll tot=0,tot2=0;
    for(ll x:v[n]){
        //cout<<s[x].F<<s[x].S<<" "<<x+1<<n+1<<endl;
        tot+=s[x].F;
        tot2+=s[x].S;
        v2.push_back(s[x].F-s[x].S);
    }
    for(int i=0;i<v2.size();i++){
        for(ll x:se1){
            se2.insert(x);
            se2.insert(x+v2[i]);
        }
        se1=se2;
        se2={};
    }
    ll M=max(0LL,tot-m);
    auto itr=se1.lower_bound(M);
    if(itr==se1.end())return true;
    a=max(m,tot-*itr);
    b=tot2+*itr;
    //cout<<a<<" "<<b<<" "<<n+1<<*itr<<endl;
    if(a<b)swap(a,b);
    s[n]={a,b};
    //cout<<a<<" "<<b<<" "<<n+1<<endl;
    return false;
}
int main(void){
    cin>>n;
      for(int i=1;i<n;i++){
        cin>>a;
        a--;
        v[a].push_back(i);
        dp[i]=a;
    }
    for(int i=0;i<n;i++)cin>>A[i];
    que.push(0);
    v1={0};
    ch[0]=1;
    while(!que.empty()){
        ll q=que.front();
        que.pop();
        for(ll x:v[q]){
            if(!ch[x]){
                que.push(x);
                v1.push_back(x);
                ch[x]=1;
            }
        }
    }
    reverse(v1.begin(),v1.end());
    //for(ll x:v1)cout<<x+1<<endl;
    for(int i=0;i<n;i++){
        if(v[v1[i]].size()==0)s[v1[i]]=P(A[v1[i]],0);
        else {
            if(f(v1[i],A[v1[i]])){
                cout<<"IMPOSSIBLE"<<endl;
                return 0;
            }
        }
    }
    cout<<"POSSIBLE"<<endl;
}


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

static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

int prim(){
  int u, minv;
  int d[MAX],p[MAX],color[MAX];

  for(int i = 0; i < n; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for(int i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if( u == -1)break;
    color[u] = BLACK;
    for(int v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
        if(d[v] > M[u][v]){
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  int sum = 0;
  for(int i = 0;i < n;i++){
    if(p[i] != -1) sum += M[i][p[i]];
  }

  return sum;
}

int main(){
  cin >> n;

  for(int i = 0; i < n; i++){
    for(int j = 0;j < n; j++){
      int e;
      cin >> e;
      M[i][j] = (e == -1) ? INFTY : e;
    }
  }

  cout << prim() << endl;

  return 0;
}



Measured memory_bytes: 3100
# -*- coding: utf-8 -*-
s = input()

import sys

N = 26

ary = [False for i in range(N)]

for a in s:
    ary[ord(a) - ord('a')] = True
for i, a in enumerate(ary):
    if not a:
        print(chr(i + ord('a')))
        sys.exit()

print("None")


Measured memory_bytes: 3188
N = int(input())
A = sorted([int(x) for x in input().split()])
#queue = deque(A)
while len(A) != 1:
  a = A.pop(A.index(min(A)))
  b = A.pop(A.index(min(A)))
  A.append((a+b)/2)
print(A[0])

Measured memory_bytes: 3060
#include<stdio.h>
int a[105][105],b[10000+50];
int main ()
{
	int h,w;
	while(scanf("%d %d",&h,&w)!=EOF)
	{
		int i,j,t,k=0;
		scanf("%d",&t);
		for(i=0;i<t;i++)
			scanf("%d",&b[i]);
		for(i=0;i<h;i++)
		{
			if(i%2==0)
				for(j=0;j<w;j++)
				{
					a[i][j]=k+1;
					b[k]--;
					if(b[k]==0)
						k++;
				}
			if(i%2==1)
				for(j=w-1;j>=0;j--)
				{
					a[i][j]=k+1;
					b[k]--;
					if(b[k]==0)
						k++;
				}
		}
		for(i=0;i<h;i++)
		{
			for(j=0;j<w-1;j++)
				printf("%d ",a[i][j]);
			printf("%d\n",a[i][w-1]);
		}
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define each(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vd vector<double>
#define vvd vector<vd>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
const int MAXN = 2e5 + 9;
const ll LINF = 1LL << 60;
const int INF = 1 << 29;
//////////////////////////////////////////////////////////////
int n, q, A[20], m;
bool res[2000];

void DP() {
  res[0] = true;
  for (int i = 0; i < n; i++) {
    for (int j = 2000 - A[i]; j >= 0; j--) {
      if (res[j]) {
        res[j + A[i]] = true;
      }
    }
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> A[i];
  DP();
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> m;
    cout << (res[m] ? "yes" : "no") << endl;
  }
  return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

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


ll dp[1005][(1<<12)+5];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  if(k==0){
    cout<<n*n<<endl;
    return 0;
  }
  ll ans=0;
  reps(i,n){
    ans+=max(0LL,i-k)*(n/i)+max(n%i-k+1,0LL);
  }
  cout<<ans<<endl;
}

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

if 400 <= N <= 599:
    print(8)
elif 600 <= N <= 799:
    print(7)
elif 800 <= N <= 999:
    print(6)
elif 1000 <= N <= 1199:
    print(5)
elif 1200 <= N <= 1399:
    print(4)
elif 1400 <= N <= 1599:
    print(3)
elif 1600 <= N <= 1799:
    print(2)
else:
    print(1)










Measured memory_bytes: 9176
import numpy as np
import itertools


def main():
    N, M, X = (int(x) for x in input().split())
    A = [[int(x) for x in input().split()] for i in range(N)]
    A.sort()
    a = np.array(A)
    t = []
    ans = []
    for i in range(1, N + 1):
        C = list(itertools.combinations(A, i))
        for c in C:
            k = np.array(c)
            k = k.sum(axis=0)
            ans.append(is_ok(X, k))
    for i in ans:
        if i != -1:
            t.append(i)
    
    if t:
        print(min(t))
    else:
        print(-1)


def is_ok(X, k):
    M = len(k)
    f = list(map(lambda x: x >= X, k[1:M]))
    if False not in f:
        return k[0]
    else:
        return -1


if __name__ == "__main__":
    main()


Measured memory_bytes: 27740
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, a, b;
  cin >> N >> b;
  for(int i=1; i<N; i++){
    cin >> a;
    int c=a%b;
    while(c!=0){
      a=b;
      b=c;
      c=a%b;
    }
  if(b==1) break;
  }
  cout << b << endl;
}


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

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  vector<string> a(n);
  unordered_map<string, int> b;
  string s;
  rep(i,n) {
    cin >> s;
    sort(s.begin(), s.end());
    a[i] = s;
    if (b.find(s) != b.end()) {
      b.at(s)++;
      ans += b.at(s) - 1;
    } else {
      b[s] = 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 16036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll L,st,ed,b,pw[19];
int m,ans;
struct mat{
	int a[3][3];
	mat(){memset(a,0,sizeof a);}
	void init(int i)
	{
		memset(a,0,sizeof a);
		a[0][0]=pw[i]%m,a[1][0]=a[1][1]=a[2][1]=a[2][2]=1;
	}
}A,ret;
mat operator*(mat a,mat b)
{
	mat c;
	for(int i=0;i<3;i++)
	for(int j=0;j<3;j++)
	for(int k=0;k<3;k++)
	c.a[i][j]=(c.a[i][j]+1ll*a.a[i][k]*b.a[k][j])%m;
	return c;
}
int solve(ll L,ll R,int id)
{
	ll n=(R-L)/b+1;
	for(int i=0;i<3;i++)for(int j=0;j<3;j++)ret.a[i][j]=i==j;
	A.init(id);
	while(n)
	{
		if(n&1)ret=ret*A;
		A=A*A,n>>=1;
	}
	ans=(1ll*ans*ret.a[0][0]+L%m*ret.a[1][0]+b%m*ret.a[2][0])%m;
}
int main()
{
	pw[0]=1;for(int i=1;i<=18;i++)pw[i]=pw[i-1]*10;
	cin>>L>>st>>b>>m;
	ed=st+b*(L-1);
	for(int i=1;i<=18;i++)
	if(st<pw[i])
	{
		ll R=(pw[i]-1-st)/b*b+st;
		if(R>ed)R=ed;
		solve(st,R,i);
		if(R==ed)break;
		st=R+b;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

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

  int A, B, C;
  cin >> A >> B >> C;
  if(A < C && B > C) cout << "Yes" << endl;
  else if(A > C && B < C) cout << "Yes" << endl;  
  else cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import Counter
from itertools import product

N = int(input())

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

# 素因数分解で約数を計算する
primes = prime_decomposition(N)

# 素因数の種類と個数を数え上げる
counter = Counter(primes)
values = [[k**i for i in range(v+1)] for k, v in counter.items()]
p = product(*values)

# 全ての種類の素数×個数を計算して、約数の組み合わせを格納する
divisors = []
for v in p:
    div = 1
    for w in v:
        div *= w
    divisors.append(div)

# 条件にあう約数を選別してmを求め、答えに加算する
ans = 0
for i in divisors:
    j = N / i
    if (i > j + 1) & (i >= 1) & (j >= 1):
        ans += i - 1
print(ans)

Measured memory_bytes: 3564
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint32_t W, a, b;
  cin >> W >> a >> b;

  if ((a + W) < b) {
    cout << b - (a + W) << endl;
  } else if ((b + W) < a) {
    cout << a - (b + W) << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


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

  int main() {
    int n;
    string s;

    cin >> n >> s;

    int total = 1;

    for(int i=1;i<n;i++) {
      if(s[i] != s[i-1]) {
        total++;
      }
    }

    cout << total << endl;
    return 0;
  }

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

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

const ll INF=1LL << 60;


int main() {
  int a,b;cin >> a >> b;
  if((a%2) && (b%2))cout << "Yes";
  else cout << "No";
}

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

int main() {
  int N ,M;
  cin >> N >> M;
  vector<int> H(N);
  vector<int> A(M);
  vector<int> B(M);
  for(int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  for(int i = 0; i < M; i++) {
    cin >> A.at(i) >> B.at(i);
  }
  vector<bool> S(N);
  for(int i = 0; i < N; i++) {
    S.at(i) = true;
  }
  for(int i = 0; i < M; i++) {
    if(H.at(A.at(i)-1) > H.at(B.at(i)-1)) {
      S.at(B.at(i)-1) = false;
    }
    else if(H.at(A.at(i)-1) < H.at(B.at(i)-1)) {
      S.at(A.at(i)-1) = false;
    }
    else {
      S.at(B.at(i)-1) = false;
      S.at(A.at(i)-1) = false;
    }
  }
  int cnt = 0;
  for(int i = 0; i < N; i++) {
    if(S.at(i)==true) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

#define pb push_back
using ll = long long;

const int N = 1e5L + 11;

ll h[N], f[N];
vector <pair <int, int>> e[N];

int main() {
	ios :: sync_with_stdio(false);
	int n, m, s; cin >> n >> m >> s;
	for(int i = 1; i <= n; i ++) cin >> h[i];
	while(m --) {
		int u, v, w; cin >> u >> v >> w;
		e[u].pb({v, w});
		e[v].pb({u, w});
	}
	set <pair <ll, int>> st;
	fill(f, f + n + 1, 1e18L); f[1] = 0;
	for(int i = 1; i <= n; i ++)
		st.insert({f[i], i});
	while(!st.empty()) {
		auto p = *st.begin(); st.erase(p);
		ll t = p.first; int x = p.second;
		for(auto i : e[x]) {
			int v = i.first, w = i.second;
			if(h[x] < w) continue;
			ll c = t + w;
			if(s - c > h[v])
				c = s - h[v];
			if(c < f[v]) {
				st.erase({f[v], v});
				f[v] = c;
				st.insert({f[v], v});
			}
		}
	}
	if(f[n] == 1e18L) cout << "-1\n";
	else cout << f[n] + h[n] - (s - f[n]) << '\n';
}

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

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


    for (int i = 0; i < 100; i++) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }

        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }


}

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    ll n,d;
    cin >> n >> d;
    ll x,y;
    int count = 0;
    REP(i,n){
        cin >> x >> y;
        if(d*d>=x*x+y*y)count++;
    }
    COUT(count);
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
long long n, a[(1<<20)], preSum[(1<<20)];

long long getS ( long long l, long long r ) {
    return preSum[r] - preSum[l];
}

long long getMid ( long long l, long long r ) {
    long long m = (l+r)/2;

    int sL= l, sR = r;

    for ( ; l+1 < r ; m = (l+r)/2 ){
        if ( getS( sL, m ) < getS( m, sR ) ) {
            l = m;
        }else {
            r = m;
        }
    }
    return l;
}

int main () {
    cin >> n;
    for ( long long i = 0 ; i < n ; i ++ ){
        cin >> a[i];
    }
    preSum[0] = 0;
    for ( long long i = 1 ; i <= n ;i ++ ) { preSum[i] = preSum[i-1] + a[i-1]; }

    long long ans = preSum[n];

    for ( long long i = 0 ; i < n ; i ++ ) {
        long long m1 = getMid( 0, i+1 ), m2 = getMid( i+1, n );
        for ( long long k1 = max( m1-1, 0LL ) ; k1 <= min( m1+1, n-1 ) ; k1 ++ ) {
            for ( long long k2 = max( m2-1, 0LL ) ; k2 <= min( m2+1, n-1 ) ; k2 ++ ) {

                if ( 0 >= k1 || k1 >= i+1 || i+1 >= k2 || k2 >= n ) { continue; }

                long long s1 = getS( 0, k1 ), s2 = getS( k1, i+1 ), s3 = getS( i+1, k2 ), s4 = getS( k2, n );

                long long maxx = max( max( s1, s2 ), max( s3, s4 ) );
                long long minn = min( min( s1, s2 ), min( s3, s4 ) );
                ans = min( ans, maxx-minn);
            }
        }

    }

    cout << ans << "\n";
    return 0;
}


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

int main() {
  int n, t, a;
  cin >> n >> t >> a;

  vector<int> h(n);
  vector<double> temp(n);
  int ans = 0;
  double min_t = 1000;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    temp[i] = t - h[i] * 0.006;
    min_t = min(min_t, abs(temp[i]-a));
    if (abs(temp[i] - a)  == min_t) {
      ans = i + 1;
    }
  }

  cout << ans << endl;
}


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

int a,b,c;
int ok5,ok7;

int main()
{
	cin>>a>>b>>c;
	if(a==5) ok5++;
	else if(a==7) ok7++;
	if(b==5) ok5++;
	else if(b==7) ok7++;
	if(c==5) ok5++;
	else if(c==7) ok7++;
	if(ok5==2&&ok7) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>
#include<tuple>
#include<set>

using namespace std;

using ull = unsigned long long;

vector<ull> A;
vector<ull> B;
vector<ull> C;

struct Hoge {
    int x, y, z;

    ull eval() const {
        return A[x] + B[y] + C[z];
    }
    bool operator< (const Hoge& other) const {
        return eval() < other.eval();
    }
};


int main(int argc, char const *argv[])
{
    int X,Y,Z,K;
    cin>>X>>Y>>Z>>K;

    A.resize(X);
    B.resize(Y);
    C.resize(Z);

    for(int i=0;i<X;i++) {
        cin>>A[i];
    }
    for(int i=0;i<Y;i++) {
        cin>>B[i];
    }
    for(int i=0;i<Z;i++) {
        cin>>C[i];
    }

    sort(A.begin(), A.end(), greater<ull>());
    sort(B.begin(), B.end(), greater<ull>());
    sort(C.begin(), C.end(), greater<ull>());

    // solve
    using T = tuple<ull,int,int,int>;
    priority_queue<T> q;

    auto calc = [&](int i, int j, int k) {
        return A[i] + B[j] + C[k];
    };
    q.emplace(calc(0,0,0), 0,0,0);

    set<T> seen;

    int cnt = 0;
    while(cnt < K) {
        auto e = q.top(); q.pop();
        if(seen.find(e) != seen.end())
            continue;
        cnt++;
        seen.insert(e);

        cout << get<0>(e) << endl;

        const auto i = get<1>(e);
        const auto j = get<2>(e);
        const auto k = get<3>(e);
        if(i+1 < A.size())
            q.emplace(calc(i+1,j,k),i+1,j,k);
        if(j+1 < B.size())
            q.emplace(calc(i,j+1,k),i,j+1,k);
        if(k+1 < A.size())
            q.emplace(calc(i,j,k+1),i,j,k+1);
    }

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
	int x,i;
	long long y,c,sum=0,min,max;
	scanf("%ld",&x);
	scanf("%ld",&y);
	max=y;
	min=y;
	sum += y;
	for(i=1;i<x;i++){
		scanf("%ld",&y);
		sum += y;
		if(y > max)
			max = y;
		if(y < min)
			min = y;}
	printf("%lld %lld %lld\n",min,max,sum);
	return 0;
}
			
		
	

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    int ans = INF;
    for (int i = 0; i < N; i++) {
        int n = 0;
        while (A[i] % 2 == 0) {
            A[i] /= 2;
            n++;
        }
        chmin(ans, n);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        d: f64,
        pos: [(isize, isize); n]
    }
    let mut c = 0;
    for p in pos {
        let dist = ((p.0.pow(2) + p.1.pow(2)) as f64).sqrt();
        if dist <= d  {
            c += 1
        }
    }
    println!("{}", c)
}


Measured memory_bytes: 7844
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int k;
string s;
int main(){
	ios::sync_with_stdio(0);
	cin>>k>>s;
	if(sz(s)<=k){
		cout<<s;
		re 0;
	}
	s=s.substr(0,k);
	s+="...";
	cout<<s;
	re 0;
}

Measured memory_bytes: 3644
st=list(input())
st.append("E")
uselistR=[]
cnt=0
for i in range(len(st)):
    if st[i]=="R" :
        cnt+=1
    if st[i]!="R" and cnt>=1:
        uselistR.append(cnt)
        cnt=0
    else:
        continue
uselistL=[]        
for i in range(len(st)):
    if st[i]=="L" :
        cnt+=1
    if st[i]!="L" and cnt>=1:
        uselistL.append(cnt)
        cnt=0
    else:
        continue
           

wanted=[]
for i in range(len(uselistR)):
    number1=uselistR[i]-1
    number2=uselistL[i]-1
    wanted.extend([0 for j in range(number1)])
    
    if number1%2==0 and number2%2==0:
        wanted.append(int((number1+number2)/2)+1)
        wanted.append(int((number1+number2)/2)+1)
        wanted.extend([0 for j in range(number2)])
        
    if number1%2!=0 and number2%2==0:
        wanted.append(int((number1+number2-1)/2)+1)
        wanted.append(int((number1+number2+1)/2)+1)
        wanted.extend([0 for j in range(number2)])
        
    if number1%2==0 and number2%2!=0:
        wanted.append(int((number1+1+number2)/2)+1)
        wanted.append(int((number1-1+number2)/2)+1)
        wanted.extend([0 for j in range(number2)])
        
    if number1%2!=0 and number2%2!=0:
        wanted.append(int((number1+number2)/2)+1)
        wanted.append(int((number1+number2)/2)+1)
        wanted.extend([0 for j in range(number2)])

print(*wanted)

Measured memory_bytes: 7884
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> E(N);
  for (int i = 0; i < M; i++){
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    E[A].push_back(B);
    E[B].push_back(A);
  }
  vector<bool> used(N, false);
  vector<int> path1;
  path1.push_back(0);
  vector<int> path2;
  path2.push_back(E[0][0]);
  used[0] = true;
  used[E[0][0]] = true;
  while (1){
    int v = path1.back();
    int next = -1;
    for (int w : E[v]){
      if (!used[w]){
        next = w;
      }
    }
    if (next == -1){
      break;
    }
    used[next] = true;
    path1.push_back(next);
  }
  while (1){
    int v = path2.back();
    int next = -1;
    for (int w : E[v]){
      if (!used[w]){
        next = w;
      }
    }
    if (next == -1){
      break;
    }
    used[next] = true;
    path2.push_back(next);
  }
  reverse(path1.begin(), path1 .end());
  vector<int> path;
  for (int v : path1){
    path.push_back(v);
  }
  for (int v : path2){
    path.push_back(v);
  }
  int sz = path.size();
  cout << sz << endl;
  for (int i = 0; i < sz; i++){
    cout << path[i] + 1;
    if (i < sz - 1){
      cout << ' ';
    }
  }
  cout << endl;
}

Measured memory_bytes: 9828
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (Math.abs(b - a) <= W) {
            System.out.println(0);
        } else {
            System.out.println(Math.min(Math.abs(b - a - W), Math.abs(a - b - W)));
        }
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll H,W,A[88][88],B[88][88],AB[88][88];
bitset<20000> dp[88][88];
ll i, j, k,ans;


ll idx(ll a){
    return (a + 20000) % 20000;
}

int main(){
    scanf("%lld%lld", &H,&W);
    fornum(i,0,H){
        fornum(j,0,W){
            scanf("%lld", &A[i][j]);
        }
    }
    fornum(i,0,H){
        fornum(j,0,W){
            scanf("%lld", &B[i][j]);
        }
    }
    fornum(i,0,H){
        fornum(j,0,W){
            AB[i][j] = abs(A[i][j] - B[i][j]);
        }
    }
    dp[0][0][10000] = true;
    fornum(i,0,H){
        fornum(j,0,W){
            dp[i + 1][j] |= dp[i][j] << AB[i][j];
            dp[i + 1][j] |= dp[i][j] >> AB[i][j];
            dp[i][j + 1] |= dp[i][j] << AB[i][j];
            dp[i][j + 1] |= dp[i][j] >> AB[i][j];
        }
    }
    fornum(i,0,10000){
        if(dp[H-1][W][i+10000])
            break;
    }
    printf("%lld", i);

    return 0;
}

Measured memory_bytes: 18688
#include <stdio.h>
#include <string.h>
#define TRUE 1
#define FALSE 0

int main(void){
	int n;/*cards you have*/
	int rank;
	int i,j;
	char mark[256];
	int cards[4][13];

	/*insert FALSE*/
	for(i = 0;i < 4;i++){
		for(j = 0;j < 13;j++){
			cards[i][j] = FALSE;
		}
	}

	scanf("%d", &n);

	if(n > 52){
		return 0;
	}

	/*check cards you have*/
	for(i = 0;i < n;i++){
		scanf("%s %d", mark, &rank);
		if(rank >= 1 && rank <= 13){
			if(strcmp(mark,"S") == 0){
				cards[0][rank - 1] = TRUE;
			}else if(strcmp(mark,"H") == 0){
				cards[1][rank - 1] = TRUE;
			}else if(strcmp(mark,"C") == 0){
				cards[2][rank - 1] = TRUE;
			}else if(strcmp(mark,"D") == 0){
				cards[3][rank - 1] = TRUE;
			}else{
				return 0;
			}
		}else{
			return 0;
		}
	}

	/*output cards you dont have*/
	for(i = 0;i < 4;i++){
		for(j = 0;j < 13;j++){
			if(cards[i][j] == FALSE){
				switch(i){
					case 0:
						printf("S");
						break;
					case 1:
						printf("H");
						break;
					case 2:
						printf("C");
						break;
					case 3:
						printf("D");
						break;
					default:
						break;
				}
				printf(" %d\n", j + 1);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
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 (a>b) { a=b; return 1; } return 0; }
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int h,w,n;
cin>>h>>w>>n;
int nx,ny;
cin>>nx>>ny;
nx--;ny--;
string s,t;
cin>>s>>t;
bool stay=true;
int l=0,r=w-1;
if(s[n-1]=='L')l++;
if(s[n-1]=='R')r--;
//左右
for(int i=n-2;i>=0;i--){
    if(t[i]=='L'&&r!=w-1)r++;
    if(t[i]=='R'&&l!=0)l--;
    if(s[i]=='L')l++;
    if(s[i]=='R')r--;
    if(l>r)stay=false;
}
 if(ny<l||ny>r)stay=false;
int u=0,d=h-1;
if(s[n-1]=='U')u++;
if(s[n-1]=='D')d--;
//上下
for(int i=n-2;i>=0;i--){
    if(t[i]=='U'&&d!=h-1)d++;
    if(t[i]=='D'&&u!=0)u--;
    if(s[i]=='U')u++;
    if(s[i]=='D')d--;
    if(u>d)stay=false;
}
if(nx<u||nx>d)stay=false;
if(stay)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}

Measured memory_bytes: 920
N = int(input())
a = [0]+list(map(int,input().split()))

b = []
c = [0]*len(a)
for i in range(N,0,-1):
  total = 0
  for m in range(i+i,N+1,i):
    total += c[m]
  if total%2!=a[i]:
    c[i] = 1
    b.append(i)

print(len(b))
for bm in b:
  print('{} '.format(bm))


Measured memory_bytes: 67804
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));
		StringBuilder sb = new StringBuilder();
		String num = br.readLine();
		String[] set = num.split(" ");

		int a = Integer.parseInt(set[0]);
		int b = Integer.parseInt(set[1]);

		int c = a/b;
		int d = a%b;
		String f = String.format("%.5f", ((double)a/(double)b));

		System.out.println(sb.append(c).append(" ").append(d).append(" ").append(f));

	}

}

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

int main(void) {
    
    int n, Y;
    cin >> n >> Y;
    int x = -1 ,y = -1,z = -1;
    for(int i = 0; i <= n; i++){
        for(int j = 0; i+j <= n; j++){
            int k = n - i - j;
            int tmp = 10000*i + 5000*j + 1000*k;
            if(tmp == Y){
                cout << i << ' ' <<  j << ' ' << k << endl;
                return 0;
            }
        }
    }
    cout << x << ' ' << y << ' ' << z << endl;

    return 0;
    
}

Measured memory_bytes: 256
n = int(input())
def cal(a,b,count):
    tmp = 0
    while count > 1:
        count -= 1
        su = a+b
        a = b
        b = su
        tmp = su
    return tmp
if n == 1:
    print(1)
else:
    print(cal(2, 1, n))

Measured memory_bytes: 3060
import itertools
N = int(input())
XY = tuple(tuple(map(int, input().split())) for _ in range(N))
kumi = tuple(itertools.permutations(XY, N))
ans = 0
def f(xi, yi, xj, yj):
    return ((xi - xj) ** 2 + (yi - yj) ** 2) ** 0.5

for i in kumi:
    for j in range(N-1):
        xi, yi = i[j]
        xj, yj = i[j+1]
        ans += f(xi, yi, xj, yj)
print(ans/len(kumi))

Measured memory_bytes: 7992
#!/usr/bin/env python3
import sys
INF = float("inf")


def main():
    H, W = map(int, input().split())
    a = []
    for h in range(H):
        a.append(input())
    print("#"*(W+2))
    for h in a:
        print("#"+h+"#")
    print("#"*(W+2))

    pass


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
def read_input():
    n = int(input())
    s = input()
    ox = [c for c in s]

    return n, ox


def check_order(sw, ox):
    pre = -1
    post = 1

    for a, c in zip(sw, ox):
        if a == 'S':
            if c == 'o':
                if sw[pre] != sw[post]:
                    return False
            if c == 'x':
                if sw[pre] == sw[post]:
                    return False
        elif a == 'W':
            if c == 'o':
                if sw[pre] == sw[post]:
                    return False
            if c == 'x':
                if sw[pre] != sw[post]:
                    return False

        pre += 1
        post += 1

        if post == len(sw):
            post = 0

    return True


def get_animal(a, flip):
    if flip:
        if a == 'S':
            return 'W'
        else:
            return 'S'

    return a


def submit():
    n, ox = read_input()

    # test1
    sw = ['S', 'S']
    for i in range(1, n - 1):
        if sw[i] == 'S':
            if ox[i] == 'o':
                sw.append(get_animal(sw[i - 1], flip = False))
            else:
                sw.append(get_animal(sw[i - 1], flip = True))
        elif sw[i] == 'W':
            if ox[i] == 'o':
                sw.append(get_animal(sw[i - 1], flip = True))
            else:
                sw.append(get_animal(sw[i - 1], flip = False))

    if check_order(sw, ox):
        print(''.join(sw))
        return

    # test2
    sw = ['S', 'W']
    for i in range(1, n - 1):
        if sw[i] == 'S':
            if ox[i] == 'o':
                sw.append(get_animal(sw[i - 1], flip = False))
            else:
                sw.append(get_animal(sw[i - 1], flip = True))
        elif sw[i] == 'W':
            if ox[i] == 'o':
                sw.append(get_animal(sw[i - 1], flip = True))
            else:
                sw.append(get_animal(sw[i - 1], flip = False))

    if check_order(sw, ox):
        print(''.join(sw))
        return

    # test3
    sw = ['W', 'S']
    for i in range(1, n - 1):
        if sw[i] == 'S':
            if ox[i] == 'o':
                sw.append(get_animal(sw[i - 1], flip = False))
            else:
                sw.append(get_animal(sw[i - 1], flip = True))
        elif sw[i] == 'W':
            if ox[i] == 'o':
                sw.append(get_animal(sw[i - 1], flip = True))
            else:
                sw.append(get_animal(sw[i - 1], flip = False))

    if check_order(sw, ox):
        print(''.join(sw))
        return

    # test4
    sw = ['W', 'W']
    for i in range(1, n - 1):
        if sw[i] == 'S':
            if ox[i] == 'o':
                sw.append(get_animal(sw[i - 1], flip = False))
            else:
                sw.append(get_animal(sw[i - 1], flip = True))
        elif sw[i] == 'W':
            if ox[i] == 'o':
                sw.append(get_animal(sw[i - 1], flip = True))
            else:
                sw.append(get_animal(sw[i - 1], flip = False))

    if check_order(sw, ox):
        print(''.join(sw))
        return

    print(-1)


if __name__ == '__main__':
    submit()


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

int main(){
  long long n; cin >> n;
  vector<pair<long long, long long>> ba(n);
  for(int i = 0; i < n; i++){
    long long a, b; cin >> a >> b;
    ba.at(i).first = b;
    ba.at(i).second = a;
  }
  sort(ba.begin(), ba.end());
  long long sum = 0;
  for(int i = 0; i < n; i++){
    sum += ba.at(i).second;
    if(ba.at(i).first < sum){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <algorithm>

using namespace std;

int main() {
	string S;
	cin >> S;
	int cnt = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == '1')cnt++;
	}
	cout << cnt << endl;

}


Measured memory_bytes: 256