akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
bool d[12][12];
int main() {
	int N;
	scanf("%d", &N);
	vector<int> x(N), y(N);
	double l = 0;
	rep(i, 0, N)scanf("%d%d", &x[i], &y[i]);
	rep(i, 0, 1 << N) {
		rep(i2, i + 1, N) {
			int dx = x[i] - x[i2], dy = y[i] - y[i2];
			l += pow(dx*dx + dy*dy, 0.5);
		}
	}
	printf("%f\n", l * 2 / N);
	return 0;
}

Measured memory_bytes: 256
import itertools
n = int(input())
dis = []
for i in range(n):
    x,y = map(int,input().split())
    dis.append([x,y])

li = [i+1 for i in range(n)]

ans = 0
for elm in itertools.permutations(li):
    #print(elm)
    for j in range(len(elm)-1):
        ans += ((dis[elm[j]-1][0] - dis[elm[j+1]-1][0])**2 + (dis[elm[j]-1][1] - dis[elm[j+1]-1][1])**2) **0.5

mm = 1
for i in range(1,n+1):
    mm *= i

print(ans/mm)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var m = consoleReader.Int;
            return Enumerable.Range(1, consoleReader.Int)
                .Where(i => i >= 20)
                .Where(i => i % 10 >= 2)
                .Select(i => (i / 10) * (i % 10))
                .Where(d => d <= m)
                .Count();
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }
#pragma warning disable
    public class ConsoleReader
    {
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = textReader.ReadLine().Split();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.textReader.ReadLine().Split(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}

Measured memory_bytes: 11348
#include <stdio.h>

int length(int *A) {
	return *A;
}

void swap(int *a, int *b) {
	int t = *a;
	*a = *b;
	*b = t;
}

int BubbleSort(int *A) {
	int i, j, n = 0;
	for (i = 1; i <= length(A); i++) {
		for (j = length(A); j >= i + 1; j--) {
			if (A[j] < A[j - 1]) {
				swap(&A[j], &A[j - 1]);
				n++;
			}
		}
	}
	return n;
}

int main(void) {
	int A[101] = {0};
	int N, c;
	int i;
	
	scanf("%d", &N);
	A[0] = N;
	for (i = 1; i <= N; i++) {
		scanf("%d", &A[i]);
	}
	
	c = BubbleSort(A);
	
	for (i = 1; i <= N; i++) {
		if (i > 1) {
			putchar(' ');
		}
		printf("%d", A[i]);
	}
	
	printf("\n%d\n", c);
	
	return 0;
}

Measured memory_bytes: 604
#!/usr/bin/env python
import sys
from math import sqrt, factorial
from itertools import permutations

def _i(): return int(sys.stdin.readline().strip())
def _ia(): return [int(x) for x in sys.stdin.readline().strip().split()]


n = _i()
xy = [_ia() for _ in range(n)]

tot = 0
for s in permutations([i for i in range(n)]):
    i = s[0]
    tmp = 0
    for j in s[1:]:
        dx = xy[i][0] - xy[j][0]
        dy = xy[i][1] - xy[j][1]
        tmp += sqrt(dx ** 2 + dy ** 2)
        i = j
    tot += tmp

print(tot / factorial(n))


Measured memory_bytes: 41580
int main(void){
  long int sum, i, n;
  
  scanf("%ld", &n);
  sum = 0;
  for(i = 1; i <= n; i++){
   if((i % 3) != 0){
     if((i % 5) != 0){
       if(((i % 3) != 0) && ((i % 5) != 0)){
         sum = sum + i;
       }
     }
   }
  }
  printf("%ld\n",sum);
  return 0;
}

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

int N,M;
const int tam =100005;
vector<int> g [tam];
bool vs[tam];
int ds[tam];

int dfs(int n){
    int rta = 0;
    vector<int> v = g[n];
    if(v.size()==0){
        return 0;
    }
    for(int i=0; i<v.size(); i++){
        if(!vs[v[i]]){
            rta = max(rta,dfs(v[i]));
        }
        else{
            rta = max(rta,ds[v[i]]);
        }
    }
    vs[n] = true;
    return ds[n] = rta+1;
    
}

int main(){
    int a,b;
    memset(ds, 0, sizeof(ds));
    memset(vs, false, sizeof(vs));
    scanf("%d %d", &N, &M);
    for(int i=1; i<=M; i++){
        scanf("%d %d", &a, &b);
        g[a].push_back(b);
    }
    int maxi =0;
    
    for(int i=1; i<=N; i++){
        if(!vs[i]){
            maxi = max(maxi, dfs(i));
        }
    }
    printf("%d\n", maxi);
    
    return 0;
}

Measured memory_bytes: 9600
import numpy as np

H, W = map(int, input().split())
val = []
INF = 10**9
for i in range(H):
    tmp = input()
    val.append([0 if tmp[j] == '#' else INF for j in range(W)])
val = np.array(val)

for i in range(H-1):
    val[i+1, :] = np.minimum(val[i, :]+1, val[i+1, :])
for i in range(H-1, 0, -1):
    val[i-1, :] = np.minimum(val[i, :]+1, val[i-1, :])
for j in range(W-1):
    val[:, j+1] = np.minimum(val[:, j]+1, val[:, j+1])
for j in range(W-1, 0, -1):
    val[:, j-1] = np.minimum(val[:, j]+1, val[:, j-1])

print(val.max())

Measured memory_bytes: 36964
import java.util.*;

class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt()-1;
        int B = sc.nextInt()-1;
        int C = sc.nextInt()-1;
        int D = sc.nextInt()-1;
        String[] str = sc.next().split("");
        int[] map = new int[N];
        for(int i=0;i<N;i++){
            if(str[i].equals("#")){
                map[i] = 1;
            }
        }

        if(C > D){
            for(int i=A;i<=C-1;i++){
                if(map[i]==1 && map[i+1]==1){
                    System.out.println("No");
                    return;
                }
            }
            for(int i=B;i<=D;i++){
                if(map[i-1]==0 && map[i]==0 && map[i+1]==0){
                    System.out.println("Yes");
                    return;
                }
            }
            System.out.println("No");
        }
        else{
            for(int i=A;i<=D-1;i++){
                if(map[i]==1 && map[i+1]==1){
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
        }
    }

    public static void dump(int[] a) {
        for(int i : a){
            System.out.print(i + " ");
        }
        System.out.println();
        return;
    }
}

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

const int N = 1e5 + 5;
bool in[N];
vector<vector<int> > g;

int main() {

	//freopen("readin.txt", "r", stdin);

	deque<int> q;
	int n, m;
	scanf("%d%d", &n, &m);
	g.resize(n + 1);
	for (int i = 0, a, b; i < m; i++) {
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		swap(a, b);
		g[a].push_back(b);
	}
	in[1] = true;
	q.push_front(1);
	while (1) {
		int a = q.front();
		int b = q.back();
		bool c1 = 0, c2 = 0;
		for (int i = 0; i < g[a].size(); i++) {
			int v = g[a][i];
			if (!in[v]) {
				c1 = true;
				in[v] = true;
				q.push_front(v);
				break;
			}
		}
		for (int i = 0; i < g[b].size(); i++) {
			int v = g[b][i];
			if (!in[v]) {
				c2 = true;
				in[v] = true;
				q.push_back(v);
				break;
			}
		}
		if (!c1 && !c2) break;
	}
	cout << q.size() << endl;
	while (q.size()) {
		printf("%d ", q.front());
		q.pop_front();
	}

}


Measured memory_bytes: 6740
#include <iostream>

int main(int argc, char **argv){
	int h = 0;
	int w = 0;

	while(std::cin >> h >> w, (h != 0 || w != 0)){
		for(int y = 0; y < h; y++){
			for(int x = 0; x < w; x++){
				if(x >= 1 && x <= w - 2 && y >= 1 && y <= h - 2){
					std::cout << ".";
				}
				else{
					std::cout << "#";
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int a[12] = {1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049};
    int n;
    cin >> n;
    vector<vector<ll>> num(13, vector<ll>(n + 1, INF)); 
    num[0][0] = 0;
    for(int i = 1; i <= 12; i++){
        int val = a[i - 1];
        for(int j = 0; j <= n; j++){
            if(j < val) num[i][j] = num[i - 1][j];
            else{
                num[i][j] = min(num[i - 1][j], num[i][j - val] + 1);
            }
        }
    }
    //for(int i = 0; i <= 12; i++){ cout << "\n"; for(int j = 0; j <= n; j++) cout << num[i][j] << " ";}
    cout << num[12][n];
}

Measured memory_bytes: 11264
n = int(input())
values = [0] + list(map(int, input().split())) + [0]
total_value = 0
for i in range(1, len(values)):
    total_value += abs(values[i] - values[i - 1])

for i in range(1, len(values) - 1):
    add = abs(values[i + 1] - values[i - 1])
    rem1 = abs(values[i] - values[i - 1])
    rem2 = abs(values[i + 1] - values[i])
    res = total_value + add - rem1 - rem2
    print(res)


Measured memory_bytes: 13920
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var c = cin.ReadLine.ToCharArray()[0];
            var A = new string[] { "a","b","c","d", "e","f","g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };

            WriteLine(A[ c - 'a' + 1]);
        }

        private BigInteger Lcm(BigInteger a, BigInteger b)
        {
            return (a * b) / Gcd(a, b);
        }

        /// <summary>
        /// 最大公約数計算
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        private BigInteger Gcd(BigInteger a, BigInteger b)
        {
            if (a < b) return Gcd(b, a);

            while (b != 0)
            {
                var mod = a % b;
                a = b;
                b = mod;
            }
            return a;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine{ get { return _stream.ReadLine(); } }
        public int ReadInt{ get { return int.Parse(Read); } }
        public long ReadLong{ get { return long.Parse(Read); } }
        public double ReadDouble{ get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

}


Measured memory_bytes: 26172
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;

    cout << (X - Z) / (Y + Z) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    
    int m,nmax,nmin;

    while(cin>>m>>nmin>>nmax,m){
    
        int P[m];
        int M=0,ans=0;


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

        for(int i=nmin-1;i<nmax;i++){
            
            if(M<=P[i]-P[i+1]){
                
                M=P[i]-P[i+1];
                ans=i+1;
            }
            
        }


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

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    for (int i=1; i<=5; i++) {
        int j;
        cin >> j;
        if (j==0) cout << i << endl;
    }

    // output

    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
//#define num 1000000007
#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define up(a,b) (((a)%(b)==0)?((a)/(b)):((a)/(b))+1)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
#define pb push_back
#define pob pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;

ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b, a%b);
}
bool prime[3001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=3000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=3000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[20];
void power()
{
	powe[0]=1;
	REP(i,1,20)
	{
		powe[i]=(powe[i-1]*10)%num;
        if(powe[i]<0)
        powe[i]+=num;
	}
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll facto[200005];
void f()
{
	facto[0]=1;
	REP(i,1,200005)
	{
		facto[i]=mod((i*facto[i-1]),num);
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll a,b,c;
    cin>>a>>b>>c;
    if(a+b<c && (4*a*b)<(c-a-b)*(c-a-b))
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
    Node *cur = nil->next;
    while(cur != nil && cur->key != key ){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil -> prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf=0;
    while(1){
        if(cur==nil)break;
        if(isf++ > 0)printf(" ");
        printf("%d", cur->key);
        cur=cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if(t==nil)return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
    int key, n, i;
    char com[20];
    scanf("%d", &n);
    init();
    for(i=0; i<n; i++){
        scanf("%s%d", com, &key);
        if(com[0]=='i'){insert(key);
        }else if(com[0]=='d'){
            if(strlen(com)>6){
                if(com[6]=='F')deleteFirst();
                else if(com[6]=='L')deleteLast();
            }else{
                deleteKey(key);
            }
        }
            
    }
    printList();
    
    
    return 0;
}



Measured memory_bytes: 37068
N,S = map(int,input().split())

A = list(map(int,input().split()))

mod = 998244353

dp = [0] * (S+1)
dp[0] = pow(2,N,mod)

half = 499122177

for i in range(N):

    for j in range(S,-1,-1):

        if j + A[i] <= S:
            dp[j+A[i]] += dp[j] * half
            dp[j+A[i]] %= mod

print (dp[-1] % mod)


Measured memory_bytes: 68388
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;

int main() {
    int n;cin>>n;
    bool f = false;
    for(int i = 1;i<=9;i++) {
        for(int j = 1;j<=9;j++) {
            if(i*j == n) f = true;
        }
    }
    if(f)cY
    else cN
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQUE(c)   sort(ALL((c)));(c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m;
LL x[101010], y[101010];
vector<LL> xx, yy;
int rui[5050][5050];

int main() {
	cin >> n >> m;
	REP(i, n) {
		cin >> x[i] >> y[i];
		xx.emplace_back(x[i]);
		yy.emplace_back(y[i]);
	}
	xx.emplace_back(-HLINF);
	xx.emplace_back(HLINF);
	yy.emplace_back(-HLINF);
	yy.emplace_back(HLINF);

	UNIQUE(xx);
	UNIQUE(yy);

	REP(i, n) {
		int xxx = lower_bound(ALL(xx), x[i]) - xx.begin();
		int yyy = lower_bound(ALL(yy), y[i]) - yy.begin();
		rui[yyy][xxx]++;
	}
	REP(i, n+2) {
		REP(j, n+2) {
			if (i > 0 && j > 0) {
				rui[i][j] += rui[i][j - 1] + rui[i - 1][j];
				rui[i][j] -= rui[i - 1][j - 1];
			}
			else if (i > 0)rui[i][j] += rui[i - 1][j];
			else if (j > 0)rui[i][j] += rui[i][j - 1];
		}
	}
	REP(i, m) {
		LL x1, x2, y1, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1 = lower_bound(ALL(xx), x1) - xx.begin();
		y1 = lower_bound(ALL(yy), y1) - yy.begin();
		x2 = upper_bound(ALL(xx), x2) - xx.begin() - 1;
		y2 = upper_bound(ALL(yy), y2) - yy.begin() - 1;
		cout << rui[y2][x2] - rui[y1 - 1][x2] - rui[y2][x1 - 1] + rui[y1 - 1][x1 - 1] << endl;
	}
}


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

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

        int n = Integer.parseInt(sc.next());
        int[] list = new int[n];
        for (int i = 0; i < n; i++) {
            list[n - i - 1] = Integer.parseInt(sc.next());
        }

        int count = 0;
        String ans = "";
        for (int val : list) {
            if (count != 0) {
                ans += " ";
            }
            ans += String.valueOf(val);
            count++;
        }
        out.printf("%s\n", ans);
        out.flush();
    }
}


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

int main(){
//srandom((unsigned long)time(NULL));
int n,m;
cin>>n>>m;
vector<tuple<int,int>> a;
for(int i=0;i<m;i++){
    int ss,cc;
    cin>>ss>>cc;
    a.emplace_back(tie(ss,cc));
}
int x=1;
if(n==1){
    for(tuple<int,int> t:a){
        int ss,cc;
        tie(ss,cc)=t;
        if(cc!=0)x=0;
}
 if(x==1){
     cout<<0<<endl;
 return 0;
 }
}
//cout<<"kiteru"<<endl;
for(int i=pow(10,n-1);i<pow(10,n);i++){
    x=1;
    for(tuple<int,int> t:a){
        int ss,cc;
        tie(ss,cc)=t;
        //cout<<"ccnon"<<(i%(int)pow(10,n-ss+1))/pow(10,n-ss)<<endl;
        if((int)((i%(int)pow(10,n-ss+1))/pow(10,n-ss))!=cc)x=0;
        //n=3 ss2 999 999%100 /10
        //(i%pow(10,n-ss+1)/pow(10,n-ss))
        
}
if(x==1){
    cout<<i<<endl;
    return 0;
}
}


cout<<-1<<endl;

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, i, check = 0;
	int p[20];
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d", &p[i]);
	}
	
	for (i = 1; i < n - 1; i++){
		if (p[i] < p[i - 1] && p[i] > p[i + 1]){
			check++;
		}
		else if (p[i] > p[i - 1] && p[i] < p[i + 1]){
			check++;
		}
	}
	
	printf("\n%d\n", check);
	
	return (0);
}

Measured memory_bytes: 128
from collections import defaultdict
import sys
input = sys.stdin.readline


n = int(input())
A = list(map(int, input().split()))

dict = defaultdict(int)
for a in A:
    dict[a] += 1


ans = sum(A)
q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    count = dict[b]
    dict[b] = 0
    ans -= b * count
    ans += c * count
    dict[c] += count
    print(ans)


Measured memory_bytes: 24008
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		
		int left = x - k + 1;
		int right = x + k - 1;
		
		for (int i = left; i <= right; i++) {
			String out = i + (i < right ? " " : "");
			System.out.print(out);
		}
		System.out.println();
		
		sc.close();
	}
	
}




Measured memory_bytes: 27036
{-# LANGUAGE MultiParamTypeClasses,FlexibleContexts,FlexibleInstances,TypeSynonymInstances,BangPatterns,RankNTypes,TupleSections #-}
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Control.Arrow
import Debug.Trace
import Text.Printf

import Data.List
import Data.Int
import Data.Bits
import Data.Maybe
import Data.Monoid
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.Base
import Data.Function(on)
import Data.Tuple(swap)
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B

warshallFloyd :: Int -> [((Int,Int),Int)] -> UArray (Int,Int) Int
warshallFloyd n es = runSTUArray $ do
    d <- newArray ((0,0),(n-1,n-1)) inf
    rep n $ \i -> writeArray d (i,i) 0
    forM_ es $ \(p,c) -> do
        c' <- readArray d p
        when (c' > c) $ writeArray d p c
    rep n $ \k -> rep n $ \i -> rep n $ \j -> do
        dij <- unsafeRead d (i*n + j)
        dik <- unsafeRead d (i*n + k)
        dkj <- unsafeRead d (k*n + j)
        when (dij > dik + dkj) $ unsafeWrite d (i*n+j) (dik+dkj)
    return d
    where
    rep n = stepM_ 0 (<n) succ

main :: IO ()
main = do
    (n,m) <- readIntPair
    es <- replicateM m $ fmap (\[a,b,c] -> ((a-1,b-1),c)) readInts 
    let dist = warshallFloyd n $ es >>= (\(p,c) -> [(p,c),(swap p,c)])
    print $ length [ () | ((a,b),c) <- es, dist ! (a,b) < c ]


-- IO
readInt :: B.ByteString -> Int
readInt = fromJust . fmap fst . B.readInt
readInts :: IO [Int]
readInts = map readInt . B.words <$> B.getLine
readIntPair :: IO (Int,Int)
readIntPair = l2p . map readInt . take 2 . B.words <$> B.getLine
readAllInts :: IO [[Int]]
readAllInts = map (map readInt . B.words) . B.lines <$> B.getContents
readLns :: Read a => IO [a]
readLns = map read . words <$> getLine

-- Utilities
l2p :: [a] -> (a,a)
l2p (a:b:_) = (a,b)
l2p _ = error "l2p: the input list is too short"
p2l :: (a,a) -> [a]
p2l (a,b) = [a,b]
itof :: Int -> Double
itof = fromIntegral
inf :: Int
inf = maxBound `div` 2

-- Monad
stepM_ :: Monad m => a -> (a -> Bool) -> (a -> a) -> (a -> m ()) -> m ()
stepM_ i0 judge incr step = sub i0 where 
    sub i | judge i = step i >> sub (incr i) 
          | otherwise = return ()
rep_ :: Monad m => Int -> (Int -> m ()) -> m ()
rep_ n = stepM_ 0 (<n) (+1)
thru :: Monad m => (v -> m ()) -> v -> m v
thru m v = m v >> return v
memoize :: (Monad m) => (k -> m (Maybe v)) -> (k -> v -> m ()) -> k -> m v -> m v
memoize getter setter key action = do
    mv <- getter key
    case mv of
        Just v -> return v
        Nothing -> action >>= thru (setter key)

-- Array
newUArray :: (MArray (STUArray s) e (ST s),Ix i) => 
             (i,i) -> e -> ST s (STUArray s i e)
newUArray = newArray
newBArray :: (Ix i) => (i,i) -> e -> ST s (STArray s i e)
newBArray = newArray
defaultArray :: (IArray a e,Ix i) => e -> (i,i) -> [(i,e)] -> a i e
defaultArray = accumArray $ curry snd
fromEdges :: Ix i => (i,i) -> [(i,e)] -> Array i [e]
fromEdges = accumArray (flip (:)) []


Measured memory_bytes: 1276
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
x=int(input())
l=primes(100010)
for i in range(len(l)):
  if l[i]>=x:
    print(l[i])
    exit()

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

N, M = map(int, input().split())

AB = [tuple(map(int,input().split())) for i in range(M)]

es = [[] for _ in range(N)]
for a, b in AB:
    es[a-1].append(b-1)
    es[b-1].append(a-1)

ans = [-1] * N
ans[0] = 0

from collections import deque
que = deque([])
que.append(0)

while que:
    s = que.popleft()
    for v in es[s]:
        if ans[v] == -1:
            ans[v] = s+1
            que.append(v)

print("Yes")
print(*ans[1:], sep="\n")

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

int main() {
  int N;
  scanf("%d", &N);

  vector<string> W(N);
  set<string> st;
  bool follow_rule = true;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    W.at(i) = s;
    if (st.count(s) == 0) {
      st.insert(s);
    } else {
      follow_rule = false;
    }
  }

  for (int i = 0; i < N - 1; i++) {
    if (W.at(i).back() != W.at(i + 1).front()) {
      follow_rule = false;
    }
  }

  if (follow_rule) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>b(n-1);
  for(int i=0;i<n-1;++i){
    cin>>b[i];
  }
  int ans=b[0]+b[n-2];
  for(int i=1;i<n-1;++i){
    ans+=min(b[i-1],b[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'
 
let lines: string[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
 
reader.on('line', function (line: string) {
    lines.push(line);
});
reader.on('close', function () {
    let [x, y] = lines[0].split(' ').map( _ => parseInt(_))

    console.log(x * y)

});

Measured memory_bytes: 30024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ff first
#define ss second
#define pi 3.14159265359 
const int N=2e5+5;
const int mod=1e9+7;
 
int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1LL)
            res = res * a;
        a = a * a;
        b >>= 1LL;
    }
    return res;
}
//const int N=2e5+5;
vector<int> g[N];
int ans[N];
int32_t main()
{
    IOS;
    
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i=1;i<=n;i++)
        ans[i]=-1;
    queue<int> q;
    q.push(1);
    ans[1]=1;
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        for(auto &it:g[x])
        {
            if(ans[it]!=-1)
                continue;
            ans[it]=x;
            q.push(it);
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(ans[i]==-1)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes\n";
    for(int i=2;i<=n;i++)
        cout<<ans[i]<<" ";
}

Measured memory_bytes: 15372
N,A,B = map(int,input().split())
h = [0]*N
for i in range(N):
    h[i] = int(input())

# x回で全モンスター倒せるかどうかをにぶちゃん(にぱー)

import math

def check(x):
    count = 0
    for i in range(N):
        count += math.ceil(max(h[i] - B * x, 0) / (A - B))
           
    if count <= x:
        return True
    else:
        return False
    
def solve():
    
    left = -1
    right = 10**9+1
    
    while abs(right-left) > 1:
    
        center = (right+left)//2
    
        if check(center) == True:
            right = center
        elif check(center) == False:
            left = center
        
    return right
    
print(solve())

Measured memory_bytes: 45680
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#include <sstream>
#include <iomanip>
#include <functional>
using namespace std;

const int maxn = 110;
const int INF = 0x3f3f3f3f;    //无限大
typedef long long ll;
typedef unsigned long long ull;
int main()
{
    ll a,b,k;
    cin>>a>>b>>k;
    for(int i=1;i<=k;++i)
    {
        if(i%2==1)
        {
            if(a%2==1) --a;
            a/=2,b+=a;
        }
        else
        {
            if(b%2==1) --b;
            b/=2,a+=b;
        }
    }
    cout<<a<<' '<<b;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

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

int main(void)
{
	unsigned long n, h;
	VI a, b;
	cin >> n >> h;
	REP(i, n){
		unsigned long c, d;
		cin >> c >> d;
		a.PB(c);
		b.PB(d);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	unsigned long bsum = 0;
	unsigned long bcnt = 0;
	unsigned long res = 100000000000000;
	REP(i, b.size())
	{
		unsigned long _bsum;
		unsigned long _h;
		bsum += b[i];
		bcnt++;
		if(bsum >= h){
			res = min(res, bcnt);
			// return 0;
			continue;
		}

		_h = h-bsum;
		unsigned long acnt = ceil((double)_h / (double)a[0]);
		res = min(res, acnt + bcnt);
	}

	// debug(h);
	// debug(bsum);
	// debug(bcnt);
	// debug(a[0]);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i, a, n) for (int i = a; i < n; i++)
const long long MOD = 1000000007;

int main()
{
    while (1)
    {
        int n;
        cin >> n;
        if (n == 0)
            break;

        vector<int> p = {};
        int ans = 0;

        rep(i, 2, 2 * n + 1)
        {
            bool isPrime = true;
            int j = 0;
            while (j < p.size() && p[j] * p[j] <= i)
            {
                if (i % p[j] == 0)
                    isPrime = false;
                j++;
            }
            if (isPrime)
            {
                p.push_back(i);
                if (i > n)
                    ans++;
            }
        }
        // rep(i, 0, p.size()) cout << p[i] << " ";
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,n) for(ll i=0;i<n;i++)
#define nforn(i,n) for(ll i=n-1;i>=0;i--)
#define forne(i,n) for(ll i=1;i<=n;i++)
#define forse(i,s,e) for(ll i=s;i<e;i++)
#define all(v) v.begin(),v.end()
#define MOD 1000000007
#define d1(x) cerr <<"> "<<#x<<" = "<<x<<'\n'
#define d2(x, y) cerr <<"> "<<#x<<" = "<<x<<' '<<#y<<" = "<<y<<'\n'
#define d3(x, y, z) cerr <<"> "<<#x<<" = "<<x<<' '<<#y<<" = "<<y<<' '<<#z<<" = "<<z<<'\n'
ll s(ll x){
	while(x/10!=0)
		x /= 10;
	return x;
}
ll modpow(ll a, ll b, ll m=MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	// cin>>t;
	while(t--){
		ll n;
		cin>>n;
		ll d = 0;
		ll temp = n;
		while(temp!=0){
			temp /= 10;d++;
		}
		ll ans = 0;
		forne(i,n){
			ll end = s(i);
			ll start = i%10;
			if(!start) continue;
			forne(digits,d){
				if(digits==1)
					ans += (start==end);
				else{
					if(digits==d){
						// d3(start,end,digits);d1(ans);
						if(start<s(n)){
							ans += modpow(10,d-2);
							// d1(ans);
						}
						else if(start==s(n)){
							// d3(start,end,ans);
							ans += (n - end - start*modpow(10,d-1)+10)/10;
						}
					}
					else{
						ans += modpow(10,digits-2);
					}
				}
			}
			// d1(ans);
		}
		cout<<(ans+MOD)%MOD<<"\n";
	}
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        
        int ans = 1;
        int max = 0;
        for(int i=1; i<=N; i++){
            int n = i;
            int count = 0;
            while(true){
                if(n % 2 == 1){
                    break;
                }else{
                    n /=2;
                    count++;
                }
            }
            
            if(max < count){
                ans = i;
                max = count;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputs = br.readLine().split(" ");
		int n = Integer.parseInt(inputs[0]);

		Node[] nodes = new Node[n];
		for ( int i = 0; i < n; i++ ) {
			nodes[i] = new Node();
		}

		for ( int i = 0; i < n - 1; i++ ) {
			inputs = br.readLine().split(" ");
			int u = Integer.parseInt(inputs[0]) - 1;
			int v = Integer.parseInt(inputs[1]) - 1;
			int w = Integer.parseInt(inputs[2]);
			nodes[u].nexts.add(new Edge(v, w));
			nodes[v].nexts.add(new Edge(u, w));
		}
		br.close();

		ArrayDeque<Integer> q = new ArrayDeque<>();
		q.add(0);
		int[] tree = new int[n];
		tree[0] = 1;
		while ( !q.isEmpty() ) {
			int idx = q.poll();

			for ( Edge e : nodes[idx].nexts ) {
				if ( tree[e.to] == 0 ) {
					q.add(e.to);

					if ( e.dist % 2 == 0 ) tree[e.to] = tree[idx];
					else tree[e.to] = tree[idx] * (-1);
				}
			}
		}

		for ( int i : tree ) {
			System.out.println(Math.max(i, 0));
		}
	}
}

class Node {

	ArrayList<Edge> nexts = new ArrayList<>();
}

class Edge {

	int	to		= 0;
	int	dist	= 0;

	public Edge(int t, int d) {
		to = t;
		dist = d;
	}
}

Measured memory_bytes: 74932
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x, y, z; cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using  namespace std;
#define io_ ios_base::sync_with_stdio(0); cin.tie(0);
//da time limit por que el arbol repite indices
int *indices;
int solve(vector<int> &stones, int &i){
if (i==stones.size()-1){return 0;}
int aux=i, salto1=1e7,salto2=1e7;
aux++;
if (indices[i]==-1){
if ((i+1)<=stones.size()-1){
salto1=abs(stones[i]-stones[aux])+solve(stones,aux);
}
aux++;
if ((i+2)<=stones.size()-1){
salto2=abs(stones[i]-stones[aux])+solve(stones,aux);
}
indices[i]=min(salto1,salto2);
}
return indices[i];
}
int main (){
io_;
int n;
cin>>n;
vector<int> v(n);
for (int i=0,val;i<n;i++){
cin>>v[i];

}
indices= new int[n];
memset(indices,-1,n*4);
int i=0 ;
int suma=0;
suma=solve(v,i);
cout<<suma<<endl;
}


Measured memory_bytes: 10296
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_E
#define M_E 2.71828182845904523536
#endif
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
#define pln(x) cout << (x) << endl
#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m*n/gcd(m,n);}

template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename Iter> ostream& out_container(ostream &os, Iter first, Iter last){
  os << "{"; auto itr = first; while(itr != last){if(itr != first) os << ","; os << *itr; ++itr;} os << "}"; return os;
}

template <typename T> ostream& operator<<(ostream &os, const vector<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const deque<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const set<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const unordered_set<T> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream &os, const map<T,U> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream &os, const unordered_map<T,U> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

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

  int N;
  while(cin >> N){
    vector<int> a(N); cin >> a;

    int sum = accumulate(ALL(a),0);
    bool f = true;
    for(auto b : a){
      if(b >= sum-b) f = false;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' && ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1005, M = 31;
int x[MAXN], y[MAXN], d[M + 5];
char s[M + 5];

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n; read(n);
  for (RI i = 1; i <= n; ++i)
    read(x[i]), read(y[i]);
  for (RI i = 2; i <= n; ++i)
    if (((x[i] + y[i]) & 1) != ((x[i - 1] + y[i - 1]) & 1))
      return puts("-1"), 0;
  int op = (x[1] + y[1]) & 1;
  printf("%d\n", M + !op);
  for (RI i = 1; i <= M; ++i)
    printf("%d ", d[i] = 1 << (i - 1));
  if (!op) printf("%d ", d[M + 1] = 1);
  puts("");
  for (RI i = 1; i <= n; ++i) {
    memset(s, 0, sizeof(s));
    for (RI j = M + !op; j; --j)
      if (abs(x[i]) > abs(y[i]))
        if (x[i] > 0) s[j] = 'R', x[i] -= d[j];
        else s[j] = 'L', x[i] += d[j];
      else 
        if (y[i] > 0) s[j] = 'U', y[i] -= d[j];
        else s[j] = 'D', y[i] += d[j];
    puts(s + 1);
  }

  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

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

int main(){

  string s;

  while(true){
    getline(cin, s);
    if(s.size() == 1 && s[0] == '0') break;

    int k = 0, p = 0, ans = 0;
    for(int i=0;i<s.size();i++){

      if(s[i] == ' ') continue;

      p += s[i]-'0';

      if(i+1 != s.size() && s[i+1] != ' '){
	p *= 10;
	continue;
      }

      if(p > 10) ans += 10;
      else ans += p;

      if(p == 1) k++;
      p = 0;
    }

    while(k--){
      if(ans+10 < 22) ans += 10;
    }

    if(ans > 21) ans = 0;

    cout << ans << endl;

  }
}

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


using ll =long long;
const ll MOD = 998244353;

int main(){
    ll n,i,k,j;
    cin>>n>>k;
    ll dp[n+2] ={0};
    dp[1] = 0;
    ll arr[k][2];
    for(i=0;i<k;i++)cin>>arr[i][0]>>arr[i][1];
    for(i=0;i<k;i++){
        dp[min(n+1,1+arr[i][0])]++;
        dp[min(n+1,1+arr[i][1]+1)]--;
    }

    //for(i=1;i<=n+1;i++)cout<<dp[i]<<" ";
    //cout<<"\n";
    for(i=2;i<=n;i++){
        //for(int q=1;q<=n+1;q++)cout<<dp[q]<<" ";
        //cout<<"\n";
        dp[i]+=dp[i-1];
        while(dp[i]<0)dp[i]+=MOD;
        dp[i]%=MOD;
        for(j=0;j<k;j++){
            dp[min(n+1,i+arr[j][0])]+=dp[i];
            dp[min(n+1,i+arr[j][1]+1)]-=dp[i];
        }
        //cout<<dp[i]<<"\n";
    }
    //for(i=1;i<=n+1;i++)cout<<dp[i]<<" ";
    //dp[n]+=dp[n-1];
    cout<<(dp[n]%MOD);
}


Measured memory_bytes: 5188