akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

namespace abc165_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var M = CIn.ReadInt();
      var Q = CIn.ReadInt();
      var a = new int[Q];
      var b = new int[Q];
      var c = new int[Q];
      var d = new int[Q];

      for (int i = 0; i < Q; i++)
      {
        a[i] = CIn.ReadInt();
        b[i] = CIn.ReadInt();
        c[i] = CIn.ReadInt();
        d[i] = CIn.ReadInt();
      }

      var q = new Queue<List<int>>();
      for (int i = 1; i <= M; i++)
      {
        q.Enqueue(new List<int>() { i });
      }

      var ans = 0L;

      while (q.Count > 0)
      {
        var e = q.Dequeue();

        if (e.Count == N)
        {
          var sum = 0L;
          for (int i = 0; i < Q; i++)
          {
            if (e[b[i] - 1] - e[a[i] - 1] == c[i]) sum += d[i];
          }

          ans = Math.Max(ans, sum);
        }
        else
        {
          for (int i = e[^1]; i <= M; i++)
          {
            q.Enqueue(new List<int>(e){ i });
          }
        }
      }

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 62032
#include"bits/stdc++.h"

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;

vector<int> teleport_pow(const vector<int> & a, const ll & n) {
	if (n == 1)return a;
	
	vector<int> res(a.size());
	rep(i, res.size())res[i] = i;

	rep(hoge, 2)rep(i, res.size()) {
		res[i] = a[res[i]];
	}

	res = teleport_pow(res, n / 2);

	if (n % 2 != 0) {
		rep(i, res.size())res[i] = a[res[i]];
	}

	return res;
}

int main(void) {
	int N; ll K; cin >> N >> K;
	vector<int> A(N); 
	rep(i, N) {
		cin >> A[i];
		A[i]--;
	}

	cout << teleport_pow(A, K)[0]+1 << endl;

	return 0;
}

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

#define fi first
#define se second
#define eb emplace_back

typedef long long ll;

using namespace std;

const int nm = 300010;

int n, k, a[nm];
int tree[4 * nm];

void update(int u, int x, int l, int r, int id) {
	if (l == r) {
		tree[id] = max(tree[id], x);
		return;
	}
	int m = (l + r) >> 1, c1 = id << 1, c2 = c1 ^ 1;
	if (u <= m) {
		update(u, x, l, m, c1);
	} else {
		update(u, x, m + 1, r, c2);
	}
	tree[id] = max(tree[c1], tree[c2]);
}

int get(int u, int v, int l, int r, int id) {
	if (l >= u && r <= v) {
		return tree[id];
	}
	if (l > v || r < u) {
		return -1;
	}
	int m = (l + r) >> 1, c1 = id << 1, c2 = c1 ^ 1;
	int res = max(get(u, v, l, m, c1), get(u, v, m + 1, r, c2));
	return res;
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
    	cin >> a[i];
    	a[i]++;
    }
    int res = 0;
    for (int i = 1; i <= n; ++i) {
    	int f = get(max(1, a[i] - k), min(nm - 1, a[i] + k), 1, nm - 1, 1);
    	res = max(res, f + 1);
    	update(a[i], f + 1, 1, nm - 1, 1);
    }
    cout << res << "\n";
}


Measured memory_bytes: 8924
fun main(args: Array<String>) {
	val (n, m) = (readLine() ?: return).split(" ").map { it.toInt() }.toIntArray()
	val a = (readLine() ?: return).split(" ").map { it.toInt() }.toIntArray()
	a.sortDescending()
	if (a[m-1] >= a.sum()/(4.0*m))
		println("Yes")
	else
		println("No")
}

Measured memory_bytes: 37968
#include "bits/stdc++.h"
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}//continue break
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<pii> vpii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
 
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        ll n;cin>>n;
        ll ans=0;ll d;cin>>d;d=d*d;
        while(n--){
            ll x,y;cin>>x>>y;
            x=x*x+y*y;
            if(x<=d)ans++;
        }
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 3660
from sys import exit
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]

while True:
    flag = False
    n = int(input())
    if not(n):
        exit()
    islands = []
    for i in range(n):
        islands.append(f())
    islands.sort(key=lambda x:x[1])
    
    weight = 0
    for j in range(n):
        weight += islands[j][0]
        if weight > islands[j][1]:
            flag = True
            print("No")
            break
    if not(flag):
        print("Yes")    


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

using LD = long double;
const LD eps = 1e-10;

struct vec2 {
	LD x, y;
	vec2(LD x = 0, LD y = 0) : x(x), y(y) {}
	vec2 operator + (const vec2 &rhs) const {
		return vec2(x + rhs.x, y + rhs.y);
	}
	vec2 operator - (const vec2 &rhs) const {
		return vec2(x - rhs.x, y - rhs.y);
	}
	LD operator * (const vec2 &rhs) const {
		return x * rhs.x + y * rhs.y;
	}
	LD operator ^ (const vec2 &rhs) const {
		return x * rhs.y - y * rhs.x;
	}
	vec2 operator * (const LD rhs) const {
		return vec2(x * rhs, y * rhs);
	}
	friend vec2 operator * (const LD lhs, const vec2 rhs) {
		return vec2(lhs * rhs.x, lhs * rhs.y);
	}
	vec2 operator / (const LD rhs) const {
		return vec2(x / rhs, y / rhs);
	}
	LD norm2() const {
		return x * x + y * y;
	}
	LD norm() const {
		return std::sqrt(norm2());
	}
	friend std::istream& operator >> (std::istream &cin, vec2 &v) {
		return cin >> v.x >> v.y;
	}
	friend std::ostream& operator << (std::ostream &cout, const vec2 v) {
		return cout << std::fixed << std::setprecision(10) << v.x << ' ' << std::fixed << std::setprecision(10) << v.y;
	}
};
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	vec2 p0, p1, p2, p3; int q;
	std::cin >> q;
	for (int i = 1; i <= q; ++i) {
		std::cin >> p0 >> p1 >> p2 >> p3;
		p1 = p1 - p0, p3 = p3 - p2;
		if (std::abs(p1 ^ p3) < eps)
			std::cout << "2" << '\n';
		else if (std::abs(p1 * p3) < eps)
			std::cout << "1" << '\n';
		else
			std::cout << "0" << '\n';
	}
}



Measured memory_bytes: 3288
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
	int a[5], ans = 0;
	for (int i = 1; i <= 3; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + 4);
	for (int i = 2; i <= 3; i++)
		ans += a[i] - a[i - 1];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n; cin>>n;
  ll ans=0;
  rep(i,n){
    int a; cin>>a;
    ans+=a-1;
  }
  cout<<ans<<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);
    
    long N = sc.nextLong();
    long M = sc.nextLong();

    sc.close();

    if (N == 1 && M == 1){
      System.out.println(1);
    } else if (N == 1) {
      System.out.println(M-2);
    } else if (M == 1) {
      System.out.println(N-2);
    } else {
      System.out.println((N-2) * (M-2));
    }
 
  }

}

Measured memory_bytes: 23252
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.lang.Character.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// The Return of FizzBuzz
public class Main{
	Scanner sc=new Scanner(System.in);

	long INF=1L<<62;

	String in;

	void run(){
		for(int n=sc.nextInt(); n>0; n--){
			in=sc.next();
			solve();
		}
	}

	int n;
	long ans;

	void solve(){
		ans=INF;
		n=in.length();

		onlyChara();
		substring();
		partition();
		head();
		tail();
		headtail();

		ans=ans==INF?-1:(ans+1);
		println(ans+"");
	}

	void onlyChara(){
		StringBuilder first20=new StringBuilder();
		for(int i=1; i<=20; i++){
			first20.append(fizzbuzz(i));
		}
		ans=min(ans, indexOf(first20.toString(), in));
	}

	void substring(){
		for(int i=0; i<n; i++){
			for(int j=i; j<n; j++){
				update(toLong(in.substring(i, j+1)));
			}
		}
	}

	void partition(){
		for(int s1=0; s1<n; s1++){
			for(int t1=s1; t1<n; t1++){
				String st1=in.substring(s1, t1+1);
				for(int s2=t1+1; s2<n; s2++){
					for(int t2=s2; t2<n; t2++){
						String st2=in.substring(s2, t2+1);
						update(toLong(st2, st1));
						for(int i=0; i<10; i++){
							update(toLong(st2, ""+i, st1));
						}
					}
				}
			}
		}
	}

	// N [string]
	void head(){
		for(int t=0; t<n; t++){
			String st=in.substring(0, t+1);
			for(int i=0; i<10; i++){
				update(toLong(i+"", st));
			}
		}
	}

	// [string] N
	// [string] NN
	void tail(){
		for(int s=0; s<n; s++){
			String st=in.substring(s);
			for(int i=0; i<10; i++){
				update(toLong(st, ""+i));
				for(int j=0; j<10; j++){
					update(toLong(st, ""+i, ""+j));
				}
			}
		}
	}

	// N [string] N
	void headtail(){
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				update(toLong(""+i, in, ""+j));
			}
		}
	}

	long toLong(String... ss){
		long num=0;
		boolean OK=true;
		for(String s : ss){
			for(int i=0; i<s.length(); i++){
				num=num*10+s.charAt(i)-'0';
				OK&=isDigit(s.charAt(i));
			}
		}
		return OK?num:-1;
	}

	String fizzbuzz(long n){
		if(n%15==0){
			return "FizzBuzz";
		}else if(n%3==0){
			return "Fizz";
		}else if(n%5==0){
			return "Buzz";
		}else{
			return Long.toString(n);
		}
	}

	void update(long n){
		if(n<=0){ // NG
			return;
		}
		StringBuilder sb=new StringBuilder();
		for(long i=n-10; i<=n+10; i++){
			if(i>=1){
				sb.append(fizzbuzz(i));
			}
		}
		long left=max(n-11, 0);
		ans=min(ans, indexOf(sb.toString(), in)+length(left));
	}

	long indexOf(String s, String t){
		int at=s.indexOf(t);
		return at>=0?at:INF;
	}

	// [1,n]
	long length(long n){
		long length=0;
		long b=1;
		for(int i=1; i<=18; i++){
			// (left, right]
			long left=b-1, right=min(b*10-1, n);
			if(left>=right){
				break;
			}
			long nFizz=right/3-left/3;
			long nBuzz=right/5-left/5;
			long nFizzBuzz=right/15-left/15;
			long nString=nFizz+nBuzz-nFizzBuzz;
			length+=(right-left-nString)*i+nFizz*4+nBuzz*4;
			b*=10;
		}
		return length;
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 153284
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int k;
    int num_even, num_odd;
    
    cin >> k;
    num_even = k / 2;
    num_odd = k / 2;
    if(k % 2 == 1) num_odd++;
    
    cout << num_odd * num_even << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>


using namespace std;


struct node {
	node *prnt, *left, *right;
	long long key = -1;
};
int n;
node *nil = NULL, *root = NULL;


void Init() {
	nil = (node *)malloc(sizeof(node));
	nil->left = nil;
	nil->right = nil;
	nil->prnt = nil;

}

void preWark(node *me) {

	if (me == NULL) return;
	printf(" %d", me->key);
	preWark(me->left);
	preWark(me->right);
}


void inWark(node *me) {

	if (me == NULL) return;
	inWark(me->left);
	printf(" %d", me->key);
	inWark(me->right);
}

node* getNextInorder(node *me) {

	if (me == NULL) return NULL;
	node *rtn = NULL;

	rtn = getNextInorder(me->left);
	rtn = rtn == NULL ? me : rtn;
	return rtn;
}



void insert(node *z) {
	node *y = NULL;
	node *x = root;

	while (x != NULL)
	{
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}
	z->prnt = y;

	if (y == NULL) root = z;
	else if (z->key < y->key) y->left = z;
	else y->right = z;

}

bool findKey(node *me, int srch) {

	if (me == NULL) return false;
	else if (me->key == srch) return true;
	else
	{
		bool res;
		if (srch < me->key) res = findKey(me->left, srch);
		else res = findKey(me->right, srch);
		return res;
	}
}

node* findNode(node *me, int srch) {

	if (me == NULL) return NULL;
	else if (me->key == srch) return me;
	else
	{
		node *res = NULL;
		if (srch < me->key) res = findNode(me->left, srch);
		else res = findNode(me->right, srch);
		return res;
	}
}

void deleteOne(node *nd) {

	if (nd == NULL) return;
	node *p = nd->prnt;
	bool isLeft = true;

	if (p->left != NULL && p->left->key == nd->key) {
		if (nd->left != NULL) {
			p->left = nd->left;
			nd->left->prnt = p;

		}
		else if (nd->right != NULL) {
			p->left = nd->right;
			nd->right->prnt = p;
		}
		else {
			p->left = NULL;
		}
	}
	else {
		if (nd->left != NULL) {
			p->right = nd->left;
			nd->left->prnt = p;
		}
		else if (nd->right != NULL) {
			p->right = nd->right;
			nd->right->prnt = p;
		}
		else {
			p->right = NULL;
		}
	}

	nd = NULL;
	delete nd;
}

void deleteNode(int delKey) {

	node *nd = findNode(root, delKey);
	if (nd == NULL) return;

	if (nd->left != NULL && nd->right != NULL) {
		node *nx = getNextInorder(nd->right);
		// if (nx == NULL) nx = nd->right;

		nd->key = nx->key;
		deleteOne(nx);

	}
	else {
		deleteOne(nd);
	}
}

int main() {


	int  key;
	long long	srch;
	string ord;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> ord;

		if (ord[0] == 'i') {
			cin >> key;

			node *nd = new node;
			nd->key = key;
			nd->prnt = nd->left = nd->right = NULL;

			insert(nd);
		}
		else if (ord[0] == 'p') {
			inWark(root);
			printf("\n");
			preWark(root);
			printf("\n");
		}
		else if (ord[0] == 'f') {
			cin >> srch;
			if (findKey(root, srch)) printf("yes\n");
			else printf("no\n");

		}
		else if (ord[0] == 'd') {
			cin >> key;
			deleteNode(key);

		}

	}
	return 0;
}




Measured memory_bytes: 21836
#include<stdio.h>
int main(void)
{
	int a,b,c,d,z,w;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	z=0; w=0;
	while(1){
		a=a-d; 
		w++;
		if(a<=0){
			break;
		}
	}
	while(1){
		c=c-b; 
		z++;
		if(c<=0){
			break;
		}
	}
	if(w<z){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1660
H,W = map(int,input().split())
m = []
k = 0
for _ in range(H):
    a = list(input())
    k += a.count('#')
    m.append(a)
if k == H+W-1:
    sx = sy = 0
    for i in range(H+W-1):
        if   (sx+1<W) and (m[sy][sx+1] == '#'):sx += 1
        elif (sy+1<H) and (m[sy+1][sx] == '#'):sy += 1
        else:
            if (sx==W-1) and (sy==H-1):print('Possible')
            else:print('Impossible',sx,sy)
            exit(0)
else:
    print('Impossible')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void) {
	int n;
	int a;
	int b;
	int ai;
	int bi;
	cin >> n;
	cin >> a;
	cin >> b;

	ai = a;
	bi = b;
	if (a < b) {
		cout << a<<"\n";
		//ai = b;
		//bi = a;
	}
	else {
		cout << b<<"\n";
	}

	if (( ai + bi)-n >= 0)
		cout << (ai + bi)-n;
	else
		cout << 0;

	return 0;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
//const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[100001];

LL ans = -1;

void solve(){
	if(N==0){
		if(A[0]==1) ans = 1;
		return;
	}
	//深さiの、それぞれ考えられるノードの数の
	//最小値と最大値
	vector<LL> min_node(N+1);
	vector<LL> max_node(N+1);
	min_node[N] = A[N];
	max_node[N] = A[N];
	for(int i=N-1;i>=0;i--){
		min_node[i] = max(1LL + A[i],(min_node[i+1]+1LL)/2LL + A[i]);
		max_node[i] = min(max_node[i+1] + A[i],INF);
		if(min_node[i]>max_node[i]) return;
	}

	// for(int i=0;i<=N;i++){
	// 	printf("depth=%d:[%lld,%lld]\n",i,min_node[i],max_node[i]);
	// }

	LL allof_nodes = 1;
	LL prev_nodes = 1;
	for(int i=1;i<=N;i++){
		LL enable_nodes = (prev_nodes-A[i-1])*2LL;
		LL used_nodes = min(max_node[i],enable_nodes);
		//printf("d=%d:%lld\n",i,used_nodes);
		if(used_nodes<min_node[i]) return;
		allof_nodes += used_nodes;
		prev_nodes = used_nodes;
	}
	ans = allof_nodes;
}

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

    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5196
import numpy as np
N = int(input())
a = [int(input()) for i in range(N)]

# a = np.array(a)
max_a = np.max(a)
premax_a = np.sort(a)[::-1][1]

for i in range(N):
    if a[i] == max_a:
        print(premax_a)
    else:
        print(max_a)

Measured memory_bytes: 23064
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a,b,c,d,e;
 	cin >> a>>b>>c>>d>>e;
 	int ans=(a+9)/10+(b+9)/10+(c+9)/10+(d+9)/10+(e+9)/10;
 	int x[5]={(a-1)%10,(b-1)%10,(c-1)%10,(d-1)%10,(e-1)%10};
 	sort(x,x+5);
 	cout << ans*10-(10-x[0]-1) << endl;
 }

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int  a, b, x, z;
    float p;
    scanf("%d %d", &a, &b);
     z = (a + b) %2;
    if(z==0){
      x=(a+b)/2;
     printf("%d\n", x);
     }
    else
    {
     p = 1+a+b;
     x = p/2;
     printf("%d\n", x);
    }
     return 0;
}

Measured memory_bytes: 128
A = input()
count = 0
p = len(A)
min_=200000
max_=0
for i in range(p):
  if (A[i] == 'A'):
    min_ = min(i,min_)
  if (A[i] == 'Z'):
    max_ = max(i,max_)
print(max_-min_+1)

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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int k;
  cin >> k;
  string s;
  cin >> s;
  string add;
  bool z = 0;
  while(s.size() > k)
     {
         s.pop_back();
         z = 1;
     }

     cout << s ;
     if(z)
       cout << "...";
     
    
  
  
}

Measured memory_bytes: 3664
import numpy as np

N, K = map(int, input().split())
hs = np.array(list(map(int, input().split())))

a = np.zeros(N, int)
a[0] = 0
a[1] = abs(hs[1] - hs[0])

if N == 2:
    print(a[-1])
else:
    for i in range(2, N):
        b = a[max(i-K,0):i] + np.abs(hs[i] - hs[max(i-K,0):i])
        a[i] = np.min(b)
    print(a[-1])

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

char a[200004];
int change=0;
int go(int b, int d)
{
	int che=0;
	while(b<=d)
	{
		if (a[b-1]=='.'&&a[b+1]=='.') change=1;
		if (b==d) 
		{
			che=1; break;
		}
		
		if(a[b+1]=='.') b++;
		else if (a[b+1]=='#'&&a[b+2]=='.') b+=2;
		else if (b<d) return 0;
		
	}
	return che;
}
int main()
{
	int n,a0,b0,c,d; cin>>n>>a0>>b0>>c>>d;
	for (int i=1; i<=n; i++) cin>>a[i];
	
	a[n+1]=a[n+2]='#';
	int ans=1;
	
	if (c<d)
	{
		if (!go(a0,c)||!go(b0,d)) ans=0;
	}
	
	if (c>d)
	{
		if (!go(b0,d)) ans=0;
		if (!change) ans=0;
		if (!go(a0,c)) ans=0;
	}
	
    if (ans==0)
    {
    	cout << "No";
    	return 0;
	}
	if (ans)
	{
		cout << "Yes";
		return 0;
	}
 } 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    int a[n][m], b[m];
    REP(i,m) cin >> b[i];
    REP(i,n)REP(j,m) cin >> a[i][j];
    int sum = 0, cnt = 0;
    REP(i,n) {
        sum = 0;
        REP(j,m) sum += a[i][j] * b[j];
        sum += c;
        if (sum > 0) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < d; j++) {
      cin >> x.at(i).at(j);
    }
  }
  int ans = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      int q = 0;
      for(int l = 0; l < d; l++) {
        int t = x.at(i).at(l) - x.at(j).at(l);
        q = q + (t * t);
      }
      int t = sqrt(q)+0.5;
      if(t * t == q) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
H = 0
W = 0
K = 0
m = []
 
try:
  line = input().split(' ')
  H = int(line[0])
  W = int(line[1])
  K = int(line[2])
  for i in range(H):
      m.append(input())      
except:
  pass

nPatterns = 0
for h in range(1 << H):
    for w in range(1 << W):
        nBlacks = 0
        for h2 in range(H) :
            for w2 in range(W):
                if (h & (1 << h2)) == 0 and (w & (1 << w2)) == 0:
                    if m[h2][w2] == '#':
                        nBlacks += 1
        if nBlacks == K:
            nPatterns += 1
            
print(nPatterns)

Measured memory_bytes: 9228
#include <bits/stdc++.h>
template<typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int from, int to, T cost) {
        this->from = from;
        this->to = to;
        this->cost = cost;
    }
};
bool operator == (Edge<int> e1, Edge<int> e2) {
    return e1.from == e2.from &&
            e1.to == e2.to &&
            e1.cost == e2.cost;
}
template<typename T>
using Edges = std::vector<Edge<T>>;
template<typename T>
using Graph = std::vector<Edges<T>>;
template<typename T>
std::vector<int> topological_sort(const Graph<T> &graph) {
    Graph<T> g = graph;
    int n = g.size();
    std::vector<int> res;
    std::queue<int> que;
    std::vector<int> in(n);
    std::vector<bool> used(n, false);
    for(int i=0;i<n;++i) {
        for(int j=0;j<(int)(g[i].size());++j) {
            in[g[i][j].to]++;
        }
    }
    for(int i=0;i<n;++i) {
        if(in[i] == 0) que.push(i);
    }
    if((int)(que.size()) == 0) res.push_back(-1);
    while(!que.empty()) {
        int now = que.front(); que.pop();
        if(used[now]) {
            res.clear();
            res.push_back(-1);
            return res;
        }
        used[now] = true;
        res.push_back(now);
        for(int i=0;i<(int)(g[now].size());++i) {
            int next = g[now][i].to;
            if(in[next] == 1) {
                que.push(next);
        }
            in[next]--;
        }
    }
    return res;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    Graph<int> g(26);
    map<P, bool> sel;
    vector<string> vs(n);
    for(int i=0;i<n;++i) {
      cin >> vs[i];
    }
    if(n == 1) {
      cout << "yes" << endl;
      continue;
    }
    string s1 = vs[0];
    bool ok = true;
    for(int i=1;i<n;++i) {
      string s2 = vs[i];
      bool upd = false;
      for(int j=0;j<min((int)(s1.size()), (int)(s2.size()));++j) {
        if(s1[j] != s2[j]) {
          int a = (int)(s1[j] - 'a'), b = (int)(s2[j] - 'a');
          upd = true;
          if(!sel[{a, b}]) {
            sel[{a, b}] = true;
            g[a].push_back(Edge<int>(a, b, 1));
          }
          break;
        }
      }
      if(!upd && (int)(s1.size()) > (int)(s2.size())) {
        ok = false;
        break;
      }
      s1 = s2;
    }
    if(!ok) {
      cout << "no" << endl;
      continue;
    }
    vector<int> tmp = topological_sort(g);
    if((int)(tmp.size()) < 26) {
      cout << "no" << endl;
    } else {
      cout << "yes" << endl;
    }
  }
}



Measured memory_bytes: 3188
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define int long long
#define double long double
#define mp make_pair
#define pb push_back
#define er erase
#define cl clear
#define sw swap
#define br break
#define ct continue
#define rt return
#define xx exit(0)
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#define x first
#define y second
#define fo(i,a,b) for(int i=a;i<b;i++)
using namespace std;
struct st{
    
};
bool cmp(){
    return 1;
}
int go(){
    return 0;
}
void recur(){
    
}
void solve(){
    int n;
    cin>>n;
    int cur=0,ans=0;
    for (int i=0; i<n; i++){
        int t;
        cin>>t;
        
        if (t<cur){
            ans+=cur-t;
            t=cur;
        }
        cur=t;
    }
    
    cout<<ans;
    
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    fo(i,0,t) solve();
}

Measured memory_bytes: 3648
import java.io.*;
public class Main {
 public static void main(String[] args){
  try{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   char botton[][]={{' '},
                            {'\'' , ',' , '.' , '!' , '?'},
                            {'a' , 'b' , 'c' , 'A' , 'B' , 'C'},
                            {'d' , 'e' , 'f' , 'D' , 'E' , 'F'},
                            {'g' , 'h' , 'i' , 'G' , 'H' , 'I'},
                            {'j' , 'k' , 'l' , 'J' , 'K' , 'L'},
                            {'m' , 'n' , 'o' , 'M' , 'N' , 'O'},
                            {'p' , 'q' , 'r', 's' , 'P' , 'Q' , 'R' , 'S'},
                            {'t' , 'u' , 'v' , 'T' , 'U' , 'V'},
                            {'w' , 'x' , 'y' , 'z' , 'W' , 'X' , 'Y' , 'Z'}};
    int n[]={0,5,6,6,6,6,6,8,6,8};
    while(true){
     String s=br.readLine();
     s+="x";
     int sl=s.length();
     int cnt=1;
     
     for(int i=1;i<sl;i++){
      char x,ch;
      if(s.charAt(i-1)!=s.charAt(i)){
      x=s.charAt(i-1);
      if(x!='0'){
       ch=botton[x-'0'][(cnt-1)%n[x-'0']];
       System.out.print(ch);
      }
      else if(x=='0')for(int j=0;j<cnt-1;j++)System.out.print(" ");
      cnt=1;
     }
     else cnt++;
    }
    System.out.print("\n");
  }
 }
 catch(Exception e){return ;}
}
}



Measured memory_bytes: 25260
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let (s, t) = (s.next().unwrap(), s.next().unwrap());
	for (s, t) in s.chars().zip(t.chars()) {
		print!("{}{}", s, t);
	}
	println!("");
}


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

int main() {
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if (x == 1) {
    ans += 300000;
  }
  else if (x == 2) {
    ans += 200000;
  }
  else if (x == 3) {
    ans += 100000;
  }
  if (y == 1) {
    ans += 300000;
  }
  else if (y == 2) {
    ans += 200000;
  }
  else if (y == 3) {
    ans += 100000;
  }
  if (x == 1 && y == 1) {
    ans += 400000;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def count_fee_station(a, n_list):
    cost = 0
    for i in n_list:
        if i in a:
            cost += 1
    return cost


def main():
    n , m , x  = map(int,input().split())
    a = list(map(int, input().split()))
    if n in a:
        a.remove(n)
    n_list_a = list(range(0,x+1))
    n_list_b = list(range(x,n+1))
    cost_a = count_fee_station(a,n_list_a)
    cost_b = count_fee_station(a,n_list_b)
    print(min(cost_a,cost_b))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
(defparameter *n* (read))
(defparameter *m* (read))
(defparameter *x* (read))
(defparameter *y* (read))
(defparameter *xs* (loop repeat *n*
                         collect (read)))
(defparameter *ys* (loop repeat *m*
                         collect (read)))

(defun andmap (pred lst)
  (every #'identity (mapcar pred lst)))

(defun f (x y xs ys)
  (let* ((sed-xs (sort xs #'<))
         (sed-ys (sort ys #'<))
         (max-x (car (last sed-xs)))
         (min-y (first sed-ys)))
    (if (and
          (< x y)
          (< x max-x min-y y))
        "No War"
        "War")))

(princ (f *x* *y* *xs* *ys*))

Measured memory_bytes: 11368
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)  cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 300005
#define BLOCK 555
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
inline ll myceil(ll a, ll  b) {
    return (ceil(1.0 * a / b * 1.0));
}
ll binexp(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinvfermat(ll a, ll m)
{
    return binexp(a, m - 2, m);
}
void task(bool flag)
{
    if (flag)
        cout << "YES\n";
    else
        cout << "NO\n";
}
ll lcm(ll a, ll b)
{
    return ((1LL * a * b) / (__gcd(a, b)));
}



signed main() {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    fast
    ll n;
    cin >> n;
    ll ans = 0;
    vl x(n), y(n);
    loop(i, n)   cin >> x[i] >> y[i];
    ll pmx = -inf, pmn = inf, mmx = -inf, mmn = inf;
    loop(i, n)
    {
        pmx = max(pmx, x[i] + y[i]);
        pmn = min(pmn, x[i] + y[i]);
        mmx = max(mmx, x[i] - y[i]);
        mmn = min(mmn, x[i] - y[i]);
    }
    ans = max({ans, pmx - pmn, mmx - mmn});
    cout << ans << END;


// #ifndef ONLINE_JUDGE
//     cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
    return 0;
}



Measured memory_bytes: 6324
#include<stdio.h>
int main(){
  int a,b,c,d=0;
  scanf("%d %d",&a,&b);
  for(int i=0; i<a; i++){
    scanf("%d",&c);
    d += c<b-c?2*c:2*(b-c);
  }
  printf("%d",d);
  return 0;}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d;
    cin >> n >> d;
    d = d*2 + 1;
    int ans;
    if(n%d == 0){
        ans = n/d;
    }
    else{
        ans = n/d + 1;
    }

    cout << ans << endl;
    
    return 0;
}

  


Measured memory_bytes: 256
import math
import decimal

a,b,n=map(int,input().split())

if b<=n:
  x=decimal.Decimal(a*(b-1)/b)
  c=math.floor(x)
  print(c)

else:
  x=decimal.Decimal(a*n/b)
  c=math.floor(x)
  print(c)

Measured memory_bytes: 10020
#include<stdio.h>

#define N 500000

void merge(int, int, int);
void mergeSort(int, int);

int c=0;
int A[N];
int L[N];
int R[N];

int main(){
int i, n;
  scanf("%d", &n);
  for(i=0 ; i<n ; i++) scanf("%d", &A[i]);
  mergeSort(0, n);

  for(i=0 ; i<n-1 ; i++) printf("%d ", A[i]);
  printf("%d\n", A[i]);
  printf("%d\n", c);

  return 0;
}

void merge(int left, int mid, int right){
  int n1, n2, i, j, k;

  n1 = mid - left;
  n2 = right - mid;

  for(i=0 ; i<=n1-1 ; i++) L[i] = A[left+i];
  for(i=0 ; i<=n2-1 ; i++) R[i] = A[mid+i];

  L[n1] = 1000000000;
  R[n2] = 1000000000;
  i = 0;
  j = 0;

  for(k=left ; k<right ; k++){
    c++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int left, int right){
  int mid;

  if(left+1 < right){
    mid = (left + right) / 2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}

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

typedef pair<int, int> pii;

int R, C, N;
vector<vector<pii> > Row;
vector<vector<int> > adj;
vector<int> U, V, W;
vector<int> vis;
vector<int> val;
vector<int> ver;
vector<int> low;

void dfs(int u) {
    ver.push_back(u);
    vis[u] = 1;
    for(int i = 0; i < adj[u].size(); i++) {
        int e = adj[u][i];
        int v = V[e];
        int w = W[e];
        if(vis[v]) continue;
        val[v] = val[u] + w;
        dfs(v);
    }
}

int main() {
    scanf("%d %d %d", &R, &C, &N);
    Row.resize(R);
    for(int i = 0; i < N; i++) {
        int r, c, a; scanf("%d %d %d", &r, &c, &a);
        r--; c--;
        Row[r].push_back(pii(c, a));
    }
    adj.resize(C);
    for(int i = 0; i < R; i++) {
        sort(Row[i].begin(), Row[i].end());

        for(int j = 0; j < (int)Row[i].size() - 1; j++) {
            int u = Row[i][j].first;
            int v = Row[i][j + 1].first;
            int w = Row[i][j + 1].second - Row[i][j].second;

            adj[u].push_back(U.size());
            U.push_back(u);
            V.push_back(v);
            W.push_back(w);
            adj[v].push_back(U.size());
            U.push_back(v);
            V.push_back(u);
            W.push_back(-w);
        }
    }

    vis = vector<int>(C, 0);
    val = vector<int>(C, 0);
    low = vector<int>(C, 0);
    for(int i = 0; i < C; i++) if(!vis[i]) {
        ver.clear();
        dfs(i);

        int mn = 1e9;
        for(int j = 0; j < ver.size(); j++) {
            mn = min(mn, val[ver[j]]);
        }
        for(int j = 0; j < ver.size(); j++) {
            low[ver[j]] = val[ver[j]] - mn;
        }
    }
    for(int i = 0; i < U.size(); i++) {
        int u = U[i];
        int v = V[i];
        int w = W[i];

        if(val[u] + w != val[v]) {
            printf("No");
            return 0;
        }
    }
    for(int i = 0; i < R; i++) {
        for(int j = 0; j < Row[i].size(); j++) {
            int c = Row[i][j].first;
            int a = Row[i][j].second;

            if(a < low[c]) {
                printf("No");
                return 0;
            }
        }
    }

    printf("Yes");
}


Measured memory_bytes: 12396
n,q = map(int, input().split())
lis = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    lis[a-1].append(b)
kotae =[0]*n
c_list = [0]*n
for i in range(q):
    p,x = map(int, input().split())
    c_list[p-1] += x

for i in range(len(lis)):
    kotae[i-1] += c_list[i-1]
    for m in lis[i-1]:
        kotae[m-1] += kotae[i-1]

for i in kotae:
    print(i,end=" ")
print()

Measured memory_bytes: 50704
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
mi=float("inf")
ans=0
for i in h:
    if abs(a-(t-0.006*i))<mi:ans,mi=i,abs(a-(t-0.006*i))
print(h.index(ans)+1)

Measured memory_bytes: 3060
s = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0]
min = 10000
for (i=0; i<s.length-2; i++) {
    a = Math.abs(753 - s.slice(i, i+3) * 1)
    if (min > a) {
        min = a
    }
}
console.log(min)

Measured memory_bytes: 7372
def F(N): 
    r = int(N**0.5) # x >= 10^9 のときは注意
    ans = 0
    for d in range(1,N//r+1):
        ans += d*(1+(N//d))*(N//d)//2

    #print(ans)    
    for c in range(1,r):
        a = N//(c+1)
        b = N//c
        """
        (a,b] 上で d の和を求める
        """
        s = b*(b+1)//2-a*(a+1)//2
        ans += s*(c*c+c)//2
        #ans %= MOD
    return ans


# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = map(int,readline().split())
print(F(n))





Measured memory_bytes: 9448
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, X, Y = getNM()

dist = [[] for i in range(N)]
for i in range(N - 1):
    dist[i].append(i + 1)
    dist[i + 1].append(i)

dist[X - 1].append(Y - 1)
dist[Y - 1].append(X - 1)

distance = [0] * N
def counter(sta):
    ignore = [0] * N
    ignore[sta] = 1
    pos = deque([[sta, 0]])

    while len(pos) > 0:
        u, dis = pos.popleft()
        for i in dist[u]:
            if ignore[i] == 0:
                ignore[i] = 1
                distance[dis + 1] += 1
                pos.append([i, dis + 1])
for i in range(N):
    counter(i)
for i in distance[1:]:
    print(i // 2)

Measured memory_bytes: 86508
N, K = map(int, input().split())
D = list(map(int, input().split()))


def f(n, x):
    if n==0:
        if x >= N:
            print(x)
            exit()
        return
    
    for i in range(10):
        if i in D:
            continue
        f(n-1, x*10+i)

f(len(str(N)), 0)
ans = ""
for i in range(1, 10):
    if i not in D:
        ans = str(i)
        break
for i in range(10):
    if i not in D:
        ans += str(i)*len(str(N))
        break
print(ans)

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

int main()
{
  string s;
  cin >> s;
  if(s[0] == 'S')
    cout << "Cloudy" << endl;
  if(s[0] == 'C')
    cout << "Rainy" << endl;
  if(s[0] == 'R')
    cout << "Sunny" << endl;
  
}

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

int main()
{
	string s;
	cin>>s;
	
	int b=-1,e=-1;
	for(int i=0;b==-1||e==-1;i++){
		if(b==-1&&s[i]=='A') b=i;
		if(e==-1&&s[s.length()-i]=='Z') e=s.length()-i;
	}
	cout<<e-b+1<<endl;
	return 0;
}


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

using namespace std;
 
int ans = 1, k, n;

int main()
{
	scanf("%d %d", &n, &k);
	
	for(int i = 0; i < n; i ++)
	{
		ans += min(ans, k);
	}
	
	printf("%d\n", ans);
			
	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();
		
		PriorityQueue<City> pq = new PriorityQueue<>((p1, p2) -> {
			int nc = Integer.compare(p1.p, p2.p);
			if (nc != 0)
				return nc;
			
			return Long.compare(p1.y, p2.y);
		});
		
		List<City> list = new ArrayList<>(N);
		
		for (int i = 0; i < M; i++) {
			int p = sc.nextInt();
			long y = sc.nextLong();
			
			City c = new City(p, y);
			pq.add(c);
			list.add(c);
		}
		
		int cityNum = pq.peek().p;
		int index = 1;
		while (!pq.isEmpty()) {
			City c = pq.poll();
			if (cityNum != c.p) {
				index = 1;
				cityNum = c.p;
			}
			
			c.ans = String.format("%06d%06d", cityNum, index);
			index++;
		}
		
		for (City c : list) {
			System.out.println(c.ans);
		}
	}
	
	static class City {
		int p;
		long y;
		String ans;
		
		City(int p, long y) {
			this.p = p;
			this.y = y;
		}
	}
}


Measured memory_bytes: 152956
#include <bits/stdc++.h>
#define bug(x) cout << #x << " = " << x << endl
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define reset(x) memset(x,0,sizeof(x))
#define up(i,l,r) for(int i=l;i<=r;i++)
#define down(i,r,l) for(int i=r;i>=l;i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
int n,m,level[55]={0},low[55]={0},par[55]={0},u,v,Ti=0;
vector<vi> adj;
bool vis[55]={0};
void dfsLowLink(int x){
    level[x]=level[par[x]]+1;
    low[x]=level[x];
    vis[x]=1;
    for(int i:adj[x]){
        if(!vis[i]){
            par[i]=x;
            dfsLowLink(i);
            low[x]=min(low[x],low[i]);
            if(low[i]>level[x]) Ti++;
        }
        else if(i!=par[x]) low[x]=min(low[x],level[i]);
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    adj.resize(n+1);
    up(i,1,m){
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfsLowLink(1);
    cout<<Ti<<endl;
    return 0;
}


Measured memory_bytes: 256
# coding:utf-8
import sys 
def main():
    input_list = list(map(int, input().split()))
    input_list.sort(reverse=True)
    
    diff = input_list[0] - input_list[1] + input_list[0] - input_list[2]
    ans = diff /2
    if diff % 2 == True:
        ans += 2

    print(int(ans))
    
if __name__ == '__main__' :
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
using namespace std;
using s64 = long long;
const s64 MOD = (s64)1e9 + 7;

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

    s64 a[101] = { 0 };
    for (s64 i = 2; i <= n; i++)
    {
        s64 t = i;
        for (s64 j = 2; t != 1; j++)
        {
            while (t % j == 0)
            {
                t /= j;
                a[j]++;
            }
        }
    }

    s64 sum = 0;
    for (s64 i = 0; i < 101; i++)
    {
        // 75
        if (a[i] >= 74) sum++;
        for (s64 j = 0; j < 101; j++)
        {
            if (i != j)
            {
                // 15*5
                if (a[i] >= 14 && a[j] >= 4) sum++;
                // 25*3
                if (a[i] >= 24 && a[j] >= 2) sum++;
            }
            for (s64 k = j + 1; k < 101; k++)
            {
                if (i != j && i != k)
                {
                    // 3*5*5
                    if (a[i] >= 2 && a[j] >= 4 && a[k] >= 4) sum++;
                }
            }
        }
    }

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int a[] ={0,1,3,1,2,1,2,1,1,2,1,2,1};
int main(){
  int x,y;
  cin>>x>>y;
  if(a[x]==a[y]) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}


Measured memory_bytes: 256