akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>
char lowcmp[26]="abcdefghijklmnopqrstuvwxyz";
char upcmp[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
long long mod=1000000007;
int max(int a, int b){return a>b?a:b;}
int min(int a, int b){return a<b?a:b;}
int gcd(int a, int b){return min(a,b)==0?max(a,b):gcd(min(a,b),max(a,b)%min(a,b));}
long long llmax(long long a, long long b){return a>b?a:b;}
long long llmin(long long a, long long b){return a<b?a:b;}
long long llgcd(long long a, long long b){return llmin(a,b)==0?llmax(a,b):llgcd(llmin(a,b),llmax(a,b)%llmin(a,b));}
int assort(const void *a, const void *b){return *(int*)a-*(int*)b;}
int dessort(const void *a, const void *b){return *(int*)b-*(int*)a;}
int llassort(const void *a, const void *b){return *(long long*)a-*(long long*)b;}
int lldessort(const void *a, const void *b){return *(long long*)b-*(long long*)a;}
int charassort(const void *a, const void *b){return strcmp((char*)a ,(char*)b);}
int chardessort(const void *a, const void *b){return strcmp((char*)b ,(char*)a);}
int ntoi(char c){return c-'0';}
int ltoi(char c){return c-'a';}
int utoi(char c){return c-'A';}
long long ncr(int a,int b){long long ans=1;for(int i=0;i<b;i++){ans=ans*(a-i)/(i+1);}return(ans);}
long long npr(int a,int b){long long ans=1;for(int i=0;i<b;i++){ans=ans*(a-i);}return(ans);}


int main(void){
    int x,y;
    scanf("%d%d",&x,&y);
    printf("%d\n",x+y/2);
    
    
    
    
    
	return 0 ;
}

Measured memory_bytes: 128
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    h, w, a, b = map(int, input().split())
    for i in range(b):
        print('1'*a + '0'*(w-a))
    for i in range(h-b):
        print('0'*a + '1'*(w-a))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9156
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    h, w = list(map(int, readline().split()))
    s = [list(str(readline().rstrip().decode('utf-8'))) for _ in range(h)]

    mt = 0
    for i in range(h):
        for j in range(w):
            if s[i][j] != "#":
                ql = [[0, i, j]]
                ql = collections.deque(ql)
                fq = collections.defaultdict(list)
                fq[i, j]
                while True:
                    if len(ql) != 0:
                        cost, xv, yv = ql.popleft()
                        mt = max(mt, cost)
                        for xv, yv in [[xv + 1, yv], [xv - 1, yv], [xv, yv + 1], [xv, yv - 1]]:
                            if 0 <= xv < h and 0 <= yv < w and s[xv][yv] != "#":
                                if (xv, yv) not in fq:
                                    ql.append([cost + 1, xv, yv])
                                    fq[xv, yv]
                    else:
                        break
    print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 46428
#include <bits/stdc++.h>
using namespace std;
#include<chrono>
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define mt make_tuple
#define tc  ll t; cin>>t; while(t--)
#define io ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F first
#define S second
#define vi vector<ll>
#define pii pair<ll,ll>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define vii vector<pair<ll,ll>>
ll gcd(ll n,ll m)
{
    if(n==0)
            return m;
    return gcd(m%n,n);
}
bool ifprime(ll n)
{
if(n==1)
return false;
    ll i;
for(i=2;i*i<=n;i++)
{
if(n%i==0)
return false;
 
}
return true;
}
void disp(vi v)
{
    for(auto u:v)
    cout<<u<<" ";
    cout<<"\n";
}
void remleadzero(vector<int> &v)
{
    vector<int> u;
    int i=0;
    while(v[i]==0)
        i++;
    while(i<v.size())
    {
        u.push_back(v[i]);
        i++;
    }
    v=u;
}
#define mod 1000000007LL
/*
void myscanf(long long *n)
{
    register long long c=getchar_unlocked();
    *n=0;
    for(;(c<48 ||c>57);c=getchar_unlocked())
        ;
    for(;(c>47 && c<58);c=getchar_unlocked())
    {
        *n=(*n<<1)+(*n<<3)+(c&15);
    }
 
}
void fastscan(long long &number)
{
    bool negative = false;
    register long long c;
 
    number = 0;
 
    c = getchar_unlocked();
    if (c=='-')
    {
 
        negative = true;
 
        c = getchar_unlocked();
    }
 
 
    for (; (c>47 && c<58); c=getchar_unlocked())
        number = number *10 + c - 48;
 
 
    if (negative)
        number *= -1;
}
*/
ll fast_expo(ll n,ll m, ll md)
{
    ll a=1;
    while(m>0)
    {
        if(m&1) a=(a*n)%md;
        n=(n*n)%md;
        m/=2;
    }
    return a%md;
}
long long sqroot(long long n){
    long double N = n;
    N = sqrtl(N);
    long long sq = N-2;
    sq = max(sq,0LL);
    while(sq*sq<n){
        sq++;
    } 
    if((sq*sq)==n)
        return sq;
    return -1;
}

int main()
{
	io;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<n-2;i++){
        ans+=(s.substr(i,3)=="ABC");
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,m,i,x,y,k,viz[nmax];
ll a[nmax],ans;
vector<int>v[nmax];
vector<pair<int,int> >b;
multiset<ll>s[nmax];
multiset<ll>::iterator it;
void dfs(int x)
{
	viz[x]=1;
	s[k].in(a[x]);
	for(int i=0;i<v[x].size();i++)if(!viz[v[x][i]])dfs(v[x][i]);
}
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=1;i<=n;i++)cin>>a[i];
	while(m--)
	{
		cin>>x>>y;
		x++,y++;
		v[x].pb(y);
		v[y].pb(x);
	}
	for(i=1;i<=n;i++)
	 if(!viz[i])
	 {
	 	k++;
	 	dfs(i);
	 	b.pb({s[k].size(),k});
	 }
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	for(i=1;i<k;i++)
	{
		if(s[b[0].sc].empty())rc("Impossible");
		ans+=(*s[b[0].sc].begin())+(*s[b[i].sc].begin());
		s[b[0].sc].er(s[b[0].sc].begin());
		it=s[b[i].sc].begin(),it++;
		if(it!=s[b[i].sc].end())for(;it!=s[b[i].sc].end();it++)s[b[0].sc].in((*it));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 17144
five_handred = int(input())
handred = int(input())
fifty = int(input())

target = int(input())

count = 0

for i in range(min(five_handred, int(target/500)) + 1):

    y = target - 500 * i

    for j in range(min(handred, int(y/100)) + 1):

        z = y - 100 * j

        if int(z/50) <= fifty:
            count += 1

        else:
            pass

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char const* argv[])
{
	double a,b,c,d;

	while( cin >> a >> b >> c && a != 0 ){
		double h[3];
		h[0] = sqrt( a * a + b * b );
		h[1] = sqrt( a * a + c * c );
		h[2] = sqrt( b * b + c * c );

		cin >> d;
		for( int i = 0;i < d;i++ ){
			double n;
			cin >> n;
			n *= 2;

			int j;
			for( j = 0;j < 3;j++ ){
				if( n > h[j] ){ cout << "OK" << endl; break; }
			}
			if( j == 3 ) cout << "NA" << endl;
		}
	}


	return 0;

}

Measured memory_bytes: 0
N = int(input())
v = list(map(int, input().split()))

for i in range(1, N - 1):
    left = v.pop(v.index(min(v)))
    right = v.pop(v.index(min(v)))
    v.append((left + right) / 2)
    
print((v[0] + v[1]) / 2)


Measured memory_bytes: 2940
N = int(input())
A = sorted([int(input()) for _ in range(N)])
cnt = 0
cur = 0
for i in range(1,N):
    if A[i]!=A[cur]:
        if (i-cur)%2==1:
            cnt += 1
        cur = i
if (N-cur)%2==1:
    cnt += 1
print(cnt)

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

int main() {
  int N; cin >> N;
  int A[N]; A[0] = -1;
  for (int i = 1; i < N; i++) {
    cin >> A[i]; A[i]--;
  }
  int C[N]; for (int i = 0; i < N; i++) C[i] = 0;
  for (int i = 1; i < N; i++) C[A[i]]++;
  for (int i = 0; i < N; i++) cout << C[i] << endl;
}

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

int n;
int* cnt, *use;
int p;
map<int,bool> memo;

int main(){
	while(true){
		cin >> n;
		if(!n)
			return 0;
		memo.clear();
		p=0;
		cnt = new int[(n+1)/2];
		use = new int[n];

		for(int i=0; i<(n+1)/2; i++)
			cnt[i] = 0;

		for(int i=1; i<n; i++){
			int tmp = i*i%n;
			if(memo[tmp])
				continue;
			memo[tmp] = true;
			use[p++] = tmp;
		}

		for(int i=0; i<p-1; i++){
			for(int k=i+1; k<p; k++){
				int tmp = use[i]-use[k];
				if(tmp<0)
					tmp += n;
				if(tmp>(n-1)/2)
					tmp = n-tmp;
				cnt[tmp]++;
				tmp = use[k]-use[i];
				if(tmp<0)
					tmp += n;
				if(tmp>(n-1)/2)
					tmp = n-tmp;
				cnt[tmp]++;
			}
		}

		for(int i=1; i<(n+1)/2; i++)
			cout << cnt[i] << endl;

		delete[] cnt;
		delete[] use;
	}
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int left[n],right[n];
    left[0] = 0, right[n-1] = 0;
    for(int i=1; i<n; i++){
        if(s[i-1] == 'W') left[i] = left[i-1] + 1;
        else left[i] = left[i-1];
    }
    for(int i=n-2; i>=0; i--){
        if(s[i+1] == 'E') right[i] = right[i+1] + 1;
        else right[i] = right[i+1];
    }
    int ans = 1000000;
    for(int i=0; i<n; i++){
        if(left[i]+right[i] < ans) ans = left[i]+right[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3076
N = int(input())
S = input()

saidai = 0

for i in range(1,N):
    cnt = 0
    search = []
    tmp1 = S[0:i]
    tmp2 = S[i:N]
    for k in range(len(tmp1)):
        if tmp1[k] not in search:
            search.append(tmp1[k])
    for j in range(len(search)):
        if search[j] in tmp2:
            cnt += 1
    if saidai < cnt:
        saidai = cnt

print(saidai)

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

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

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,d=0,r=0;
	double f=0;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <vector>

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI 3.141592653589

using namespace std;

int main(void){
    int A,B,C;
    cin >> A >> B >> C;

    if(A+B+C >= 22) cout << "bust";
    else cout << "win";

    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a_list = list(map(int,input().split()))

def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

g = a_list[0]
for i in range(1,N):
    g = gcd(g,a_list[i])

print(g)

Measured memory_bytes: 62704
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

bool pal(const std::string& s) {
	for(int i = 0; i < s.size() / 2; i++) {
		if(s[i] == s[s.size() - i - 1]) continue;
		return false;
	}
	return true;
}

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

	if(pal(s) and pal(s.substr(0, s.size() / 2)) and pal(s.substr(s.size() / 2 + 1, s.size() / 2))) printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

struct Point {
  double x;
  double y;
};
void koch(int n,Point a,Point b) {
  if (n==0) {
    return;
  }
  Point s, t, u;
  double th=M_PI*60.0/180.0;
  s.x=(2.0*a.x+1.0*b.x)/3;
  s.y=(2.0*a.y+1.0*b.y)/3;
  t.x=(1.0*a.x+2.0*b.x)/3;
  t.y=(1.0*a.y+2.0*b.y)/3;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
  koch(n-1,a,s);
  cout<<fixed<<setprecision(8)<<s.x<<" "<<s.y<<endl;
  koch(n-1,s,u);
  cout<<fixed<<setprecision(8)<<u.x<<" "<<u.y<<endl;
  koch(n-1,u,t);
  cout<<fixed<<setprecision(8)<<t.x<<" "<<t.y<<endl;
  koch(n-1,t,b);
}
int main() {
  int n;
  cin>>n;
  Point a, b;
  a.x=0;
  a.y=0;
  b.x=100.0;
  b.y=0;
  cout<<fixed<<setprecision(8)<<a.x<<" "<<a.y<<endl;
  koch(n,a,b);
  cout<<fixed<<setprecision(8)<<b.x<<" "<<b.y<<endl;
  return 0;
}



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

int main(){
    int R;
    cin >> R;
    if(R < 1200) {
        cout << "ABC" << endl;
    }
    else if(R < 2800) {
        cout << "ARC" << endl;
    }
    else {
        cout << "AGC" << endl;
    }
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v(n, 0);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        v[a - 1]++;
        v[b - 1]++;
    }
    for_each(v.begin(), v.end(), [](int x){ cout << x << "\n"; });
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>


using namespace std;


int main() {
	long long n;
	cin >> n;
	if (n == 2) {
		cout << "1\n";
		return 0;
	}
	double level = sqrt(n);
	long long count = 2;
	long long work;
	long long j;
	for (long long i = 2;i <= level;i++) {
		if (n % i == 0) {
			work = n;
			while (work >= i) {
				if (work % i == 0)work /= i;
				else work %= i;
			}
			if (work == 1)count++;
			if ((double)i != level) {
				work = n;
				j = n / i;
				while (work >= j) {
					if (work % j == 0)work /= j;
					else work %= j;
				}
				if (work == 1)count++;
			}
		}
		if ((n - 1) % i == 0) {
			if ((double)i == sqrt(n - 1))count++;
			else count += 2;
		}
	}
	cout << count << "\n";
}


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

class ListNode {
public:
    int val;
    ListNode* next;
    ListNode* prev;
    ListNode() : val(0), next(this), prev(this) {}
    ListNode(int val) : val(val), next(this), prev(this) {}
};

class LinkedList {
public:
    ListNode* head;
    ListNode dummy;
    LinkedList() {
        head = &dummy;
    }

    void insertNode(int x) {
        ListNode* node = new ListNode(x);
        node->next = head->next;
        node->prev = head;
        head->next->prev = node;
        head->next = node;
    }

    void deleteNode(int x) {
        ListNode* node = head->next;
        while (node != head) {
            if (node->val == x) {
                node->next->prev = node->prev;
                node->prev->next = node->next;
                delete node;
                return;
            }
            node = node->next;
        }
    }

    void deleteFirst() {
        ListNode* node = head->next;
        node->next->prev = node->prev;
        node->prev->next = node->next;
        delete node;
    }

    void deleteLast() {
        ListNode* node = head->prev;
        node->next->prev = node->prev;
        node->prev->next = node->next;
        delete node;
    }

    void print() {
        ListNode* node = head->next;
        while (node != head) {
            cout << node->val;
            node = node->next;
            if (node != head) {
                cout << " ";
            }
        }
        cout << endl;
    }
};

int main()
{
    int n;
    cin >> n;
    LinkedList list;
    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s == "insert") {
            int val;
            cin >> val;
            list.insertNode(val);
        } else if (s == "delete") {
            int val;
            cin >> val;
            list.deleteNode(val);
        } else if (s == "deleteFirst") {
            list.deleteFirst();
        } else if (s == "deleteLast") {
            list.deleteLast();
        }
    }
    list.print();
    return 0;
}



Measured memory_bytes: 34420
function HW(){
   var arr=[];
   for(var i=1;i<150;i++){
      for(var j=i+1;j<=150;j++){
         arr.push([i,j,i*i+j*j]);
      }
   }
   arr.sort(function(a,b){
      if(a[2]==b[2])return a[0]-b[0];
      else return a[2]-b[2];
   });
   return arr;
}
var Rectangles=HW();
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var hw=Arr.shift().split(" ").map(Number);
   var h=hw[0];
   var w=hw[1];
   if(h==0 && w==0)break;
   for(var i=0;i<Rectangles.length;i++){
      if(Rectangles[i][0]==h &&Rectangles[i][1]==w)break;
   }
   console.log(Rectangles[i+1][0]+" "+Rectangles[i+1][1]);
}

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

int main() {
    int N;
    cin >> N;
    int max = -1;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec.at(i);
        
    }

    rep(i,N){
        if (vec.at(i) > max){
            max = vec.at(i);
        }
    }

    int sum;
    int min = 99999999;
    for (int i = 1; i <= max; i++)
    {
        sum = 0;
        for (int j = 0; j < N; j++)
        {
            sum += pow(vec.at(j) - i, 2);
        }
        if (sum < min){
            min = sum;
        }
        
    }
    cout << min << endl;
    
}

Measured memory_bytes: 3516
var color = Array(1) { 0 }
var inTree = Array(1) { false }
var evenTree = mutableMapOf<Int, MutableList<Int>>()
var oddTree = mutableMapOf<Int, MutableList<Int>>()

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    color = Array(n + 1) { 0 }
    inTree = Array(n + 1) { false }
    for (i in 1 until n) {
        val (u, v, w) = readLine()!!.split(' ').map(String::toInt)
        if (w % 2 == 0) {
            if(evenTree.containsKey(u)){
                evenTree[u]!!.add(v)
            }else{
                evenTree[u] = mutableListOf(v)
            }
            if(evenTree.containsKey(v)){
                evenTree[v]!!.add(u)
            }else{
                evenTree[v] = mutableListOf(u)
            }
        } else {
            if(oddTree.containsKey(u)){
                oddTree[u]!!.add(v)
            }else{
                oddTree[u] = mutableListOf(v)
            }
            if(oddTree.containsKey(v)){
                oddTree[v]!!.add(u)
            }else{
                oddTree[v] = mutableListOf(u)
            }
        }
    }
    paint(1, 0)


    for(i in 1..n){
        println(color[i])
    }
}

fun paint(target: Int, curColor: Int) {
    inTree[target] = true
    color[target] = curColor

    for (t in evenTree[target]?: emptyList<Int>()) {
        if (!inTree[t]) {
            paint(t, curColor)
        }
    }
    for (t in oddTree[target]?: emptyList<Int>()) {
        if (!inTree[t]) {
            paint(t, (curColor + 1) % 2)
        }
    }
}

Measured memory_bytes: 115384
/*  CREATED BY
    STREAM_CIPHER
    29-aug-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout << fixed << setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        int n;
        cin>>n;
        vector<int>a(n);
        for(auto &i:a)
        	cin>>i;
        int mx=a[0];
        int ans=0;
        for(int i=1;i<n;i++)
        {
        	// debug2(a[i],mx);
        	if(a[i]<mx)
        		ans+=mx-a[i];
        	mx=max(a[i],mx);
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 4744
from math import radians,sqrt,cos
a,b,h,m = map(int,input().split())
short = h*5 + 5*(m/60)
long = m

gap = min(abs(60-abs(long-short)),abs(long-short))
arg = 6*gap

x = radians(arg)
print(sqrt(a**2+b**2-2*a*b*cos(x)))

Measured memory_bytes: 62188
import java.lang.*;
import java.util.*;
public class Main{
public static void main(String[] args) 
{
	Scanner scanner=new Scanner(System.in);
	int x1=scanner.nextInt();
	int y1=scanner.nextInt();
	int x2=scanner.nextInt();
	int y2=scanner.nextInt();
	int t=x2-x1;
	int d=y2-y1;
	for(int i=0;i<d;i++)
		System.out.print("U");
	for(int i=0;i<t;i++)
		System.out.print("R");
	for(int i=0;i<d;i++)
		System.out.print("D");
	for(int i=0;i<t;i++)
		System.out.print("L");
	System.out.print("L");
	for(int i=0;i<d+1;i++)
		System.out.print("U");
	for(int i=0;i<t+1;i++)
		System.out.print("R");
	System.out.print("DR");
	for(int i=0;i<d+1;i++)
		System.out.print("D");
	for(int i=0;i<t+1;i++)
		System.out.print("L");
	System.out.print("U");

}	
}


Measured memory_bytes: 25408
from collections import defaultdict

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

# 3つめの要素でsort からの 2つめの要素でsort
l_sorted = sorted((y,p,i) for i,(p,y) in enumerate(l))

d = defaultdict(lambda: 0)

ans = [None] * M

for a,b,c in l_sorted:
    d[b] += 1
    ans[c] = str(b).zfill(6) + str(d[b]).zfill(6)
print(*ans, sep='\n')


Measured memory_bytes: 44040
#include<stdio.h>
main()
{
int a,b,c,x,y,m,n,J,K;
scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
if(x>=y) {m=x;n=y;} else {m=y;n=x;}
J=c*2*m;
if(x>=y){ K=c*2*n+(m-n)*a; if(J>K) J=K;}
if(x<=y){ K=c*2*n+(m-n)*b; if(J>K) J=K;}
K=x*a+2*y*c;if(J>K) J=K;
K=y*b+2*x*c;if(J>K) J=K;
K=a*x+b*y;if(J>K) J=K;
printf("%d",J);
}


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

// in-short-use macros

#define all(c) (c).begin(),(c).end()
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010



//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin>>n;
    ll a[n+10];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    map<ll,ll> m;   
    for(int i=1;i<=n;i++)
    {
        m[a[i]+i]++;
    }
    ll c=0;
    for(int i=1;i<=n;i++)
    {
        c+=m[i-a[i]];
    }
    cout<<c<<"\n";
    return 0;
}

Measured memory_bytes: 27820
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m=nii()
l=[lnii() for i in range(m)]

for i in range(1000):
  num=str(i)
  judge=True
  for j in range(m):
    s,c=l[j]
    s-=1
    c=str(c)
    if s>=len(num) or num[s]!=c:
      judge=False

  if judge and len(num)==n:
    print(i)
    exit()

print(-1)

Measured memory_bytes: 9144
s = list(str(input()))

for i in range(2**3):
    t = ['']
    ans = int(s[0])
    for j in range(3):
        if (i >> j) & 1:
            t.append('+')
            ans += int(s[j+1])
        else:
            t.append('-')
            ans -= int(s[j+1])
    if ans == 7:
        siki = ''
        for i in range(4):
            siki += t[i]+s[i]
        siki += '=7'
        print(siki)
        exit()

Measured memory_bytes: 38256
import java.util.*;
public class Main { 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); // osatu
		int y = sc.nextInt(); // goukei
		int yukiti = 0;
		int higuti = 0;
		int noguti = 0;
		
		loop : for(int a = 0; a <= n; a++) {
			for(int b = 0; b <= n - a; b++ ) {
				for(int c = 0; c <= n - a - b; c++) {
					if(a + b + c == n && 10000* a + 5000*b + 1000*c == y) {
						yukiti = a;
						higuti = b;
						noguti = c;
						break loop;//ループ抜ける
					}
				}
			}
		}
		if(yukiti == 0 && higuti == 0 && noguti == 0) {
			yukiti = -1;
			higuti = -1;
			noguti = -1;
		}
		System.out.print(yukiti + " " + higuti + " " + noguti);
     }
}

Measured memory_bytes: 21972
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s;cin>>s;
    replace(s.begin(),s.end(),'?','D');
    cout<<s<<endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin>>N;
  vector<int>a(N);
  vector<pair<int,int>>P(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
    P[i]=make_pair(a[i],i);
  }
  sort(P.begin(),P.end());
  for(int i=0;i<N;i++){
    cout<<P[i].second+1<<endl;
  }
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
bool chkInt(double a){
  return a == (int)a;
}

int main(){
  long n;
  cin >> n;
  int a,b,c;
  int i,j;
  for(i=1;i<=3500;i++){
    for(j=1;j<=3500;j++){
      long tmp = 4*i*j-n*(i+j);
      if(tmp>0 && chkInt((double)(n*i*j)/tmp)){
        a = i;
        b = j;
        c = (n*i*j)/tmp;
      }
    }
  }




  cout << a << " " << b <<" "<<c<<endl;


}


Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #l,r,d=map(int,input().split())
    k=int(input())
    a=7
    i=-1
    amari=0
    for j in range(1,k+2):
        temp=a%k
        if temp==0:
            i=j
            break
        a=(7+a*10)%k
    print(i)



if __name__ == "__main__":

    main()


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

int main(){
    
    uint N; cin >> N;
    vector<int> vL(N); for(uint i=0; i<N; ++i){ cin>>vL[i]; }
    sort(vL.begin(), vL.end());
    int sum = std::accumulate(vL.begin(), vL.end()-1, 0); // 0 is a initial value
    
    cout << (sum>vL[vL.size()-1] ? "Yes":"No") << endl;
    
    return 0;
}


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

using std::begin;
using std::end;

int main() {
  char c;
  std::vector<int> s1;
  std::vector<std::pair<int, int>> s2;
  int i{0};
  int sum{0};
  while(std::cin >> c) {
    switch(c) {
    case '\\':
      s1.push_back(i);
      break;
    case '/':
    {
      if(s1.empty()) break;
      int p = s1.back();
      s1.pop_back();
      int area = i - p;
      sum += area;
      while(!s2.empty()) {
        auto pp = s2.back();
        if(p < pp.first) {
          s2.pop_back();
          area += pp.second;
        } else {
          break;
        }
      }
      s2.emplace_back(p, area);
      break;
    }
    case '_':
    default:
      // nop
      break;
    }

    ++i;
  }

  std::cout << sum << std::endl;

  std::cout << s2.size();
  for(auto p: s2) {
    std::cout << ' ' << p.second;
  }
  std::cout << std::endl;

  return 0;
}



Measured memory_bytes: 3216
from itertools import accumulate
from bisect import bisect_left

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0] + list(accumulate(A))
b = [0] + list(accumulate(B))

result = 0
for i in range(N + 1):
    t = K - a[i]
    if t < 0:
        break
    j = bisect_left(b, t)
    if j == M + 1:
        result = max(result, i + M)
    elif b[j] == t:
        result = max(result, i + j)
    else:
        result = max(result, i + j - 1)
print(result)


Measured memory_bytes: 48924
#include <stdio.h>
int main()
{
	long long x, y, i;
	scanf("%lld %lld", &x, &y);
	int ans = 0;
	for(;;)
	{
		x = x * 2;
		ans++;
		if(x > y)break;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(b%a==0){
    cout << a+b;
  }else{
    cout << b-a;
  }
}

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

int N;
ll A[200020];
ll B[200020];
ll MOD = 1000000007;

int main(){
  cin >> N;
  rep(i, N) cin >> A[i];

  ll ans = 0;
  B[N-1] = A[N-1];
  rep_rev(i, N){
    B[i-1] = (B[i] + A[i-1]) % MOD;
  }

  rep(i, N-1){
    ans += (A[i] * B[i+1]) % MOD;
  }

  cout << ans % MOD << endl;
}


Measured memory_bytes: 6668
use std::io::*;
const MOD: usize = 998244353;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: usize = itr.next().unwrap().parse().unwrap();
    let b: usize = itr.next().unwrap().parse().unwrap();
    let c: usize = itr.next().unwrap().parse().unwrap();
    let d: usize = itr.next().unwrap().parse().unwrap();
    let n = c - a;
    let m = d - b;

    let mut dp = vec![vec![0; m + 1]; n + 1];
    dp[0][0] = 1;
    for i in 0..=n {
        for j in 0..=m {
            if i > 0 {
                dp[i][j] += (b + j) * dp[i - 1][j] % MOD;
            }
            if j > 0 {
                dp[i][j] += (a + i) * dp[i][j - 1] % MOD;
            }
            if i > 0 && j > 0 {
                dp[i][j] += MOD;
                dp[i][j] -= (a + i - 1) * (b + j - 1) * dp[i - 1][j - 1] % MOD;
            }
            dp[i][j] %= MOD;
        }
    }

    println!("{}", dp[n][m]);
}


Measured memory_bytes: 72312
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    string s2, t;
    cin >> s2 >> t;

    string sa = s2;
    for (auto& i : sa)
        if (i == '?')
            i = 'a';

    string s;
    
    REP(i, s2.size()) {
        bool isFound = false;
        REP(j, t.size()) {
            if (s2[i + j] == t[j] || s2[i + j] == '?') {
                if (j == (int)t.size() - 1)
                    isFound = true;
            } else
                break;
        }
        if (isFound) {
            string ss = sa;
            ss.replace(i, t.size(), t);
            s = s.empty() ? ss : (s > ss ? ss : s);
        }
    }

    if (s.empty())
        cout << "UNRESTORABLE" << endl;
    else
        cout << s << endl;

    return 0;
}


Measured memory_bytes: 384
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

long INF = 1L << 59;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto G = new Tuple!(int, long)[][](N);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        G[s[0]-1] ~= tuple(s[1]-1, s[2].to!long);
        G[s[1]-1] ~= tuple(s[0]-1, s[2].to!long);
    }

    auto V = new Tuple!(long, long)[](N);
    fill(V, tuple(INF, INF));

    void dfs(int n, long a, long b) {
        if (V[n][0] != INF) return;
        V[n] = tuple(a, b);
        foreach (to; G[n]) {
            auto m = to[0];
            auto S = to[1];
            if (V[m][0] != INF) continue;
            dfs(m, -1*a, S-b);
        }
    }

    dfs(0, 1, 0);

    auto ans = INF;
    auto X = INF;

    foreach (i; 0..N) {
        long a1 = V[i][0];
        long b1 = V[i][1];
        foreach (e; G[i]) {
            int j = e[0];
            long S = e[1];
            long a2 = V[j][0];
            long b2 = V[j][1];
            if (a1 != a2) {
                if (b1 + b2 != S) {
                    writeln(0);
                    return;
                }
            } else if (a1 == 1) {
                long c = S - b1 - b2;
                if (c % 2 || c < 0) {
                    writeln(0);
                    return;
                }
                auto x = c / 2;
                if (X == INF || X == x) {
                    X = x, ans = 1;
                } else {
                    writeln(0);
                    return;
                }
            } else {
                long c = S - b1 - b2;
                if (c % 2 || c > 0) {
                    writeln(0);
                    return;
                }
                auto x = -c / 2;
                if (X == INF || X == x) {
                    X = x, ans = 1;
                } else {
                    writeln(0);
                    return;
                }
            }
        }
    }

    long lo = 1;
    long hi = INF;

    foreach (i; 0..N) {
        long b = V[i][1];
        if (V[i][0] == 1 && b < 0) {
            lo = max(lo, -b + 1);
        } else if (V[i][0] == -1 && b > 0) {
            hi = min(hi, b - 1);
        }
    }

    ans = min(ans, hi - lo + 1);
    ans = max(0, ans);
    ans.writeln;
}


Measured memory_bytes: 30460
n,k,q = gets.chomp.split.collect{ |item| item.to_i}
alist = []
n.times do |ni|
  alist[ni] = 0
end

q.times do |qi|
  alist[(gets.chomp.to_i)-1] += 1
end
base = k - q
n.times do |ni|
  if((base + alist[ni])>=1)
    puts "Yes"
  else
    puts "No"
  end
end


Measured memory_bytes: 3144
#include <iostream>
using namespace std;
int main(){
  int a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y;
  cin>>x>>y;
  if(a[x]==a[y])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{   
    int x;
    int i;
    int a, b, c, d;
    while (scanf("%d", &x) != EOF) {
        i = 0;
        a = 9;
        b = 9;
        c = 9;
        d = 9;
        for (a = 9; a >= 0;a--) {
            for (b = 9;b >= 0; b--) {
                for (c = 9;c >= 0; c--) {
                    for (d = 9;d >= 0 ;d--) {
                        if ((a + b + c + d) == x) {
                            i += 1;
                        }
                    }
                }
            }
        }
        printf("%d\n", i);
    }
    return 0;
}

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

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

    vector<long long int> p(a);
    for(int i=0; i<a; i++) cin >> p[i];
    vector<long long int> q(b);
    for(int i=0; i<b; i++) cin >> q[i];
    vector<long long int> r(c);
    for(int i=0; i<c; i++) cin >> r[i];

    sort(p.begin(), p.end()); reverse(p.begin(), p.end());
    sort(q.begin(), q.end()); reverse(q.begin(), q.end());
    sort(r.begin(), r.end()); reverse(r.begin(), r.end());

    priority_queue<long long int, vector<long long int>, greater<long long int>> apple;
    for(int i=0; i<x; i++) apple.push(p[i]);
    for(int i=0; i<y; i++) apple.push(q[i]);
    for(int i=0; i<c; i++){
        long long int least = apple.top();
        if(least < r[i]){
            apple.pop();
            apple.push(r[i]);
        }
    }

    long long int ans = 0;
    while(apple.empty() == false){
        long long int ap = apple.top(); apple.pop();
        ans += ap;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4724
// atcoder/abc089/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int h, w, d;
  while (cin >> h >> w >> d) {
    const int H = 300 + 1;
    const int W = 300 + 1;

    int g[H][W];
    map<int, pair<int, int>> m;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> g[i][j];
        m[g[i][j]] = {i, j};
      }
    }

    map<int, int> cnt;
    for (int src = 1; src <= d; ++src) {
      int curr = src;
      int sum = 0;
      while (curr <= h * w) {
        cnt[curr] = sum;
        int next = curr + d;
        pair<int, int> a = m[curr];
        pair<int, int> b = m[next];
        sum += abs(a.first - b.first) + abs(a.second - b.second);
        curr = next;
      }
      cnt[curr] = sum;
    }

    int q;
    cin >> q;
    while (q--) {
      int a, b;
      cin >> a >> b;
      cout << cnt[b] - cnt[a] << endl;
    }
  }

  return 0;
}


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

using namespace std;

int main() {
  int ans = 700;
  char c[3];
  for (int i = 0; i < 3; i++) {
    scanf("%c", &c[i]);
    if (c[i] == 'o')
      ans += 100;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
import sys

#Union Find

#木の根を求める
def find(x,par):
    if par[x] == x:
        return x
    else:
        return find(par[x],par)

#xとyの属する集合の併合
def unite(x,y,par,rank):
    x = find(x,par)
    y = find(y,par)
    
    if x != y:
        #xとyの属している集合が異なる時
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x]==rank[y]:
                rank[x] += 1

#xとyが同じ集合に属するかの判定
def same(x,y,par):
    return find(x,par) == find(y,par)
    
input = sys.stdin.readline
n,k,L = map(int,input().split())
rpar = [] #親
tpar = []
rrank = [0]*n#木の深さ
trank= [0]*n

#初期化
for i in range(n):
    #par[i]:i rank[i]:0
    rpar.append(i)
    tpar.append(i)


for i in range(k):
    x,y = map(int,input().split())
    unite(x-1,y-1,rpar,rrank)
for i in range(L):
    x,y = map(int,input().split())
    unite(x-1,y-1,tpar,trank)

num = []
d = {}
for i in range(n):
    num.append(find(i,rpar)+find(i,tpar)*10**6)
    if num[-1] in d:
        d[num[-1]] += 1
    else:
        d[num[-1]] = 1
res = ''
for i in range(n):
    if i != 0:
        res += ' '
    
    res += str(d[num[i]])

print(res)

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }

  if (k == 0)
  {
    cout << *max_element(a.begin(), a.end());
    return;
  }

  auto f = [&](ll arg)
  {
    ll cnt = 0;
    for(int i = 0; i < n; ++i)
    {
      cnt += a[i] / arg;
      if (a[i] % arg == 0) cnt--;
    }
    return cnt <= k;
  };

  ll le = 0LL, re = 1000000001LL;
  while(re - le > 1)
  {
    ll mid = (le + re) / 2;
    if ( f(mid) ) re = mid;
    else le = mid;
  }

  cout << re;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;

int n;

bool solve(vector<int> t){
    int dist = 0;

    REP(i,n){
        if(dist < 10 * i) return false;
        dist = max(dist, t[i] + 10*i);
    }
    return true;
}

int main(){
    cin >> n;
    vector<int> d;

    REP(i,n){
        int t;
        cin >> t;
        d.pb(t);
    }

    REP(i,2){
        bool a = solve(d);
        if(a == false){
            cout << "no" << endl;
            return 0;
        }
        
        reverse(d.begin(),d.end());
    }   

    cout << "yes" << endl;
    return 0;
}



Measured memory_bytes: 5312
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	string s[h + 1][w + 1];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> s[i][j];
		}
	}
/*
	char *s[h];
	for(int i = 0; i < h; i++){
	c[i] = (char *)calloc(sizeof(char) ,1); //#include <cstdlib>
		cin >> s[i];
		cout << s[i] << endl;
	}
*/
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(s[i][j] == "snuke"){
				cout << (char)(j + 65) << i + 1<< endl;
			}
		}
	}
/*
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
		cout << s[i][j] << " ";
		}
		cout << endl;
	}
	*/
	return 0;	
}


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

using namespace std;

struct Team {
	int tid, ac, penalty;
	Team() { tid = -1, ac = 0, penalty = 0; }
};
bool operator >(const Team& t1, const Team& t2) {
	if (t1.ac == t2.ac) {
		if (t1.penalty == t2.penalty) return t1.tid > t2.tid;
		else return t1.penalty < t2.penalty;
	}
	else return t1.ac > t2.ac;
}
bool operator ==(const Team& t1, const Team& t2) {
	return t1.ac == t2.ac && t1.penalty == t2.penalty;
}

int main() {
	int M, T, P, R;
	while ( cin >> M >> T >> P >> R, M || T || P || R ) {
		int wa[10][50] = {0};
		int ac[10][50] = {0};
		vector<Team> tdt(T);
		for (int i = 0; i < T; ++i) {
			tdt[i].tid = i+1;
			tdt[i].ac = 0;
			tdt[i].penalty = 0;
		}
		for (int i = 0; i < R; ++i) {
			int m, t, p, j; cin >> m >> t >> p >> j;
			--t, --p;
			if (j == 0) {
				if (ac[p][t] == 0) {
					++ac[p][t];
					++tdt[t].ac;
					tdt[t].penalty += m + 20 * wa[p][t];
				}
			}
			else {
				++wa[p][t];
			}
		}
		sort( tdt.begin(), tdt.end(), greater<Team>() );
		for (int i = 0; i < tdt.size(); ++i) {
			if (i) {
				if (tdt[i] == tdt[i-1]) cout << "=";
				else cout << ",";
			}
			cout << tdt[i].tid;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1200
//q003.cpp
//Sat Sep 19 15:39:18 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

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

	int ans = 0;
	int tmp = 0;
	rep(i,s.length()){
		if (s[i]=='A' || 
			s[i]=='T' ||
			s[i]=='G' ||
			s[i]=='C'){
			tmp++;
		}else{
			ans = max(ans,tmp);
			tmp=0;
		}
	}

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

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

int main() {
  int r, D;
  cin >> r >> D;
  vector<int> x(11);
  cin >> x.at(0);
  for (int i = 0; i < 10; i++)
    x.at(i+1) = r * x.at(i) - D;
  for (int i = 0; i < 10; i++)
    cout << x.at(i+1) << endl;
  return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

N = int(input())

A = list(map(int, input().split()))
Ap = [i - A[i] for i in range(N)]
Ap.sort()

ans = 0
for i in range(N):
	ans += bisect_right(Ap, i + A[i]) - bisect_left(Ap, i + A[i])

print(ans)

Measured memory_bytes: 106136
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string str;
    int sum;
    
    while(cin>>str && str!="0"){
        sum=0;
        for(int i=0; i<str.size(); i++){
            sum+=str[i]-'0';
        }
        cout<<sum<<endl;
    }
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
//allocation rule
//allocate to the highest low
//update the highest low to high
//keep
typedef long long ll;
ll n,x;
typedef struct T{
    ll b,l,u;
    ll getX(){return b*l+(x-b)*u;}
} T;
bool cmp(T a, T b){ return a.getX()>b.getX();}
ll cal(T a, ll h){
    if (h<=a.b) return h*a.l;
    else return a.b*a.l+(h-a.b)*a.u;
}
vector<T> t;
vector<ll> sum;
int main(void){
    cin >> n >> x;
    ll mx=0,mn=0,diff=0;
    for(int i=0;i<n;i++){
        ll b,l,u;
        cin >> b >> l >> u;
        T tmp={b,l,u};
        t.push_back(tmp);
        mx+=b;
        diff+=b*l;
    }
    ll ans=mx;
    mx++;
    sort(t.begin(),t.end(), cmp);
    sum.resize(t.size()+1);
    sum[0] = 0;
    for (int i=0;i<t.size();i++)
        sum[i+1]=sum[i]+t[i].getX();
    while(mn<mx){
        ll cur=(mn+mx)/2;
        ll buf=sum[cur/x];
        ll res=-1, tmp;
        if (cur%x!=0){
            for (int i=0;i<cur/x;i++){
                assert(cur/x<t.size());
                tmp=buf-t[i].getX()+cal(t[i],cur%x)+t[cur/x].getX();
                res=max(res,tmp);
            }
            for (int i=cur/x;i<t.size();i++){
                tmp=buf+cal(t[i],cur%x);
                res=max(res,tmp);
            }
        }else{
            res=buf;
        }
        if (res>=diff){
            ans=min(ans,cur);
            mx=cur;
        }else{
            mn=cur+1;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<long long int>a(n);
   
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    long long int ans=1000000000;
    rep(i,n-k+1){
        long long int now=a[i+k-1]-a[i];
        ans=min(ans,now);

    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 1152