akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args)
	{
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 	
 		int k =fr.nextInt() ,n =fr.nextInt() ,a[] =new int[n] ,i ,j ;
 		for (i =0 ; i<n ; ++i)	a[i] =fr.nextInt() ;	sort (a , 0 , n-1) ;	j =a[0] ;
 		for (i =0 ; i<n ; ++i)	a[i] -= j ;	j =a[n-1] ;
 		for (i =1 ; i<n ; ++i) {
 			j =Math.min(j , k - (a[i]-a[i-1])) ;
 		}
		op.println(j) ;	op.flush();	op.close();
	}
		public static void sort(int[] arr , int l , int u) {
			int m ;
	 
			if(l < u){
				m =(l + u)/2 ;
	 
				sort(arr , l , m);	sort(arr , m + 1 , u);
	 
				merge(arr , l , m , u);
			}
		}
	 
		public static void merge(int[] arr , int l , int m , int u) {
			int[] low = new int[m - l + 1] ;
	 
			int[] upr = new int[u - m] ;
	 
			int i ,j =0 ,k =0 ;
	 
			for(i =l;i<=m;i++)
				low[i - l] =arr[i] ;
	 
			for(i =m + 1;i<=u;i++)
				upr[i - m - 1] =arr[i] ;
	
			i =l;
	 
			while((j < low.length) && (k < upr.length))
			{
				if(low[j] < upr[k])
					arr[i++] =low[j++] ;
				else 
					arr[i++] =upr[k++] ;
			}
	 
			while(j < low.length)
				arr[i++] =low[j++] ;
	 
			while(k < upr.length)
				arr[i++] =upr[k++] ;
		}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

Measured memory_bytes: 52940
#include <iostream>
#include <string.h>
using namespace std;

char yard[102][102];
int ans=0;

void dfs(int x,int y,char c){
	if(yard[x][y]!=c) return;
    if(yard[x][y]==c) yard[x][y]='.';
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if((i==0||j==0)&&(i!=0||j!=0)){
				dfs(x+i,y+j,c);
			}
		}
	}
	return;
}
int main(){
	memset(yard,'.',sizeof(yard));
	int H,W;
	cin>>H>>W;
	while(H!=0||W!=0){
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				cin>>yard[i][j];
			}
		}
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				if(yard[i][j]!='.'){
					dfs(i,j,yard[i][j]);
					ans++;
				}
			}
		}
		cout<<ans<<endl;
		ans=0;
		cin>>H>>W;
	}
	
}

Measured memory_bytes: 1952
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

lint a[51];
lint b[51];
lint c[51];
lint d[51];
int n, m;
int q;

lint ans;

void dfs(int i, vector<int> &v) {

  if (i == n) {

    lint tmp = 0;
    for (int j = 0; j < q; j++) {
      if (v[b[j] - 1] - v[a[j] - 1] == c[j]) tmp += d[j];
    }

    ans = max(ans, tmp);
    // スコア計算
    return;
  }

  if (i == 0) {
    for (int j = 1; j <= m; j++) {
      v[i] = j;
      dfs(i + 1, v);
    }
  } else {
    for (int j = v[i - 1]; j <= m; j++) {
      v[i] = j;
      dfs(i + 1, v);
    }
  }
}

int main() {
  ans = 0;
  cin >> n >> m >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  vector<int> v(n);
  dfs(0, v);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {
    char s[4];
    scanf("%s", s);
    for(int i = 1; i < 4; i++){
        if(s[i - 1] == s[i]){
            printf("Bad\n");
            return 0;
        }
    }
    printf("Good\n");
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>

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

using namespace std;
typedef long long ll;

string fill_m(string s,int m) {
    string ret = s;
    rep(i,m-s.size()) {
        ret = "0" + ret;
    }
    return ret;
}

string next(string s,int m) {
    sort(s.begin(),s.end());
    string ret = s;
    sort(s.begin(),s.end(),greater<char>());
    string ret2 = s;

    int a,b;
    stringstream ss;
    ss << ret;
    ss >> a;

    stringstream ss2;
    ss2 << ret2;
    ss2 >> b;

    b -= a;

    stringstream ss3;
    ss3 << b;
    return fill_m(ss3.str(),m);
}

int main()
{
    int n,m;
    while(cin >> n >> m) {
        if(n == 0 && m == 0) break;
        
        stringstream ss;
        ss << n;

        string ret = fill_m(ss.str(),m);
        vector<string> v;
        v.push_back(ret);
        
        REP(i,1,25) {
            v.push_back(next(v[i-1],m));
        }

        int ans = 25,ai,aj;
        rep(i,25) {
            REP(j,i+1,25) {
                if(v[i] == v[j]) {
                    if(ans > j) {
                        ans = j;
                        ai = i;
                    }
                }
            }
        }
        
        stringstream ss2;
        rep(i,v[ai].size()-1) {
            if(v[ai][i] == '0') continue;
            else {
                REP(j,i,v[ai].size()-1) ss2 << v[ai][j];
                break;
            }
        }

        ss2 << v[ai][v[ai].size()-1];

        cout << ai << " " << ss2.str() << " " << ans-ai << endl;
    }

    return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000001
#define r(i,a,b)    for(i=a;i<b;i++)
#define ra(i,a,b)   for(i=a;i<=b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ss          set<ll int>
using namespace std;
 
#define N 1000000
#define M 100000000

struct unit {
  ll int a[N];  
};

ll fact (ll int x)
{if(x==1 || x==0)return 1;
else return x*fact(x-1);}

ll power(ll int x,ll int n)
{if(n==0)return 1;
else if(n%2 == 0)return power(x*x,n/2);
else return x*power(x*x,(n-1)/2);}

bool cmp (const pii&a,const pii&b)
{ return((a.F-a.S) > (b.F-b.S));
/*if(a.S<=b.S){if(a.S==b.S)return a.F<b.F;else return a.S<b.S;}
else return a.S<b.S;*/}


int main()
{
    cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
    ll i,j,k,l,m,n;
    string s1="";
    string s2="";
    cin>>s1>>s2;
    k=sz(s1),l=sz(s2);
    char c[k+1],d[l+1];
    for(i=1,j=0;j<k;i++,j++)
    c[i]=s1[j];
    for(i=1,j=0;j<l;j++,i++)
    d[i]=s2[j];
    ll lcs[k+1][l+1];
    for(i=0;i<=k;i++)
    {
        for(j=0;j<=l;j++)
        {
            if(i==0||j==0)
            lcs[i][j]=0;
            else
            if(c[i]==d[j])
            lcs[i][j]=lcs[i-1][j-1]+1;
            else
            lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
        }
    }
    vector<char> s;
    i=k,j=l;
    while(i>=0&&j>=0){
            if(lcs[i][j]==lcs[i][j-1])
            j--;
            else
            if(lcs[i][j]==lcs[i-1][j])
            i--;
            else
            {
                s.pb(c[i]);
                i--;
                j--;
            }
            if(lcs[i][j]==0)
            break;
    }
    reverse(all(s));
    if(sz(s)!=0){
    for(i=0;i<sz(s);i++)
    cout<<s[i];}
    else
    cout<<" ";
}

Measured memory_bytes: 70656
#include "bits/stdc++.h"
using namespace std;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	string b;
	if (n % 2 != 0) {
		cout << "No";
		return 0;
	}
	for (int i = 0; i < s.size()/2; i++) {
		b = b + s[i];
	}
	string k;
	k = b + b;
	for (int i = 0; i < s.size(); i++) {
		if (k[i] != s[i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll l,r,d;cin>>l>>r>>d;
  ll ans=r/d-l/d;
  if(l%d==0){ans++;}
  cout<<ans<<endl;
}







Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#define N 101
using namespace std;

int A[N][N];
int n;
int father[N];

int getparent(int i){
    while(father[i]!=i){
        i=father[i];
    }
    return i;
}
void mergeGroup(int a,int b){
    int fa=getparent(a);
    int fb=getparent(b);
    father[fb]=fa;
}

int prim(){
    int ans=0;
    int c=0;
    int minval=4000;
    int ab,ae;
    while(c<n-1){
        int b,e;
        minval=4000;
        for(b=0;b<n;b++){
            for(e=b+1;e<n;e++){
                if(A[b][e]!=-1 && A[b][e]<minval &&getparent(b)!=getparent(e)){
                    minval=A[b][e];
                    ab=b;
                    ae=e;
                    //printf("b= %d  e= %d \n",b,e);
                }
            }
        }
        ans+=A[ab][ae];
        //printf("ab= %d  ae= %d  mincost=%d \n ",ab,ae,minval);
        c++;
        mergeGroup(ab,ae);
    }
    return ans;
}

int main(){

    int k,i,j;
    cin>>n;
    for(int i=0;i<n;i++){
        father[i]=i;
        for(int j=0;j<n;j++){
            cin>>A[i][j];
        }
    }
    cout<<prim()<<endl;
    return 0;
}



Measured memory_bytes: 3080
import numpy as np


def main(N, A, B):
    min = np.median(A)
    max = np.median(B)
    if N % 2 == 1:
        return int(max-min+1)
    else:
        return int((max-min)*2+1)
    print(min, max)
    return 0


N = int(input())
A = np.zeros((N), np.int32)
B = np.zeros((N), np.int32)
for i in range(N):
    A[i], B[i] = map(int, input().split())
print(main(N, A, B))


Measured memory_bytes: 29076
#include<stdio.h>
#include<stdlib.h>

int compare_ll(const void *a, const void *b)
{
    return *(long long*)a - *(long long*)b;
}

long long a[51] = {};

int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  qsort(a, n, sizeof(long long), compare_ll);
  long long count = 0;
  while (a[n-1] >= n) {
    long long sho = a[n-1] / n;
    long long amari = a[n-1] % n;
    count += sho;
    a[n-1] = amari;
    /*printf("%lld, %lld\n", sho, amari);*/
    for (i = 0; i < n-1; i++) {
      a[i] += sho;
    }
    int ptr;
    for (i = 0; i < n; i++) {
      if (a[i] > amari) {
	ptr = i;
	break;
      }
    }
    for(i = n-1; i > ptr; i--) {
      a[i] = a[i-1];
    }
    a[ptr] = amari;
    /*
    for (i = 0; i < n; i++) {
    printf("%lld ", a[i]);
    }
    */
  }
  printf("%lld\n", count);
  return 0;
}

  

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int a[5];
	rep(i,5)cin>>a[i];
	int ans=0;
	int rm=10;
	rep(i,5){
		if(a[i]%10==0)ans+=a[i];
		else {
			ans+=((a[i]/10)+1)*10;
			rm=min(rm,a[i]%10);
		}
	}
	cout<<ans-10+rm;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;

signed main() {
   string S;
   cin >> S;
   int win = 0;
   int total = S.length();
   for (int i = 0; i < S.length(); i++) {
       if (S[i] == 'o') ++win;
   }
   if (win + (15 - total) >= 8) {
       cout << "YES" << endl;
   } else {
       cout << "NO" << endl;
   }
}


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

typedef long long ll;
const int maxg = 10;
const int maxn = 2e3 + 3;
vector<ll> G[maxg];
int n, m;
ll dp[maxn][maxn];

int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 0; i < maxg; ++i)
		G[i].push_back(0);
	for (int i = 0; i < n; ++i)
	{
		ll c, g;
		scanf("%lld %lld", &c, &g);
		--g;
		G[g].push_back(c);
	}/*
	for (int i = 0; i < maxg; ++i)
	{
		for (int j = 0; j < G[i].size(); ++j)
		{
			printf("%4d", G[i][j]);
		}
		putchar('\n');
	}*/
	for (int i = 0; i < maxg; ++i)
	{
		sort(G[i].begin(), G[i].end());/*
		for (int j = 0; j < G[i].size(); ++j)
		{
			printf("%4d", G[i][j]);
		}
		putchar('\n');*/
		auto ite = G[i].begin(); ite++;
		reverse(ite, G[i].end());/*
		for (int j = 0; j < G[i].size(); ++j)
		{
			printf("%4d", G[i][j]);
		}
		putchar('\n');*/
		for (int j = 1; j < G[i].size(); ++j)
			G[i][j] += G[i][j - 1] + 2 * (j - 1);/*
		for (int j = 0; j < G[i].size(); ++j)
		{
			printf("%4d", G[i][j]);
		}
		putchar('\n');*/
	}/*
	for (int i = 0; i < maxg; ++i)
	{
		for (int j = 0; j < G[i].size(); ++j)
		{
			printf("%4d", G[i][j]);
		}
		putchar('\n');
	}*/
	
	for (int i = 1; i < G[0].size(); ++i)
		dp[0][i] = G[0][i];
	for (int i = 1; i < maxg; ++i)
	{
		int len = G[i].size();
		if (len == 1)
		{
			for (int j = m; j >= 1; --j)
				dp[i][j] = dp[i - 1][j];
			continue;
		}
		for (int j = 1; j <= m; ++j)
			for (int k = 1; k <= j && k < len; ++k) 
				dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i - 1][j - k] + G[i][k]));
	}
	printf("%lld\n", dp[9][m]);
	return 0;
}
/*
7 4 
14 1 
13 2 
12 3 
14 2 
8 2 
16 3 
11 2
*/


Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
vector<int>son[100010];
ll f[100010][2];
int n;
void dp(int root,int fa){
    f[root][0]=f[root][1]=1;
    for(int i=0;i<son[root].size();i++){
        int y=son[root][i];
        if(y==fa)continue;
        dp(y,root);
        f[root][0]=f[root][0]*(f[y][0]+f[y][1])%mod;
        f[root][1]=f[root][1]*f[y][0]%mod;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n-1;i++){
        int x,y;cin>>x>>y;
        son[y].push_back(x);
        son[x].push_back(y);
    }
    dp(1,0);
    cout<<(f[1][0]+f[1][1])%mod<<endl;
    return 0;
}

Measured memory_bytes: 14208
import math
x1, y1, x2, y2 = map(int, input().split())

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x1 - dy
y4 = y1 + dx

print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &v[i]);
	const int M = 1000000007;
	vector<vector<int> > dp(n + 1, vector<int>(k + 1));
	fill(dp[n].begin(), dp[n].end(), 1);
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j <= k; ++j) {
			int l = max(0, j - v[i]);
			int r = j;
			dp[i][j] = dp[i + 1][r];
			if (l) {
				dp[i][j] += M - dp[i + 1][l - 1];
					dp[i][j] %= M;
			}
			if (j) {
				dp[i][j] += dp[i][j - 1];
					dp[i][j] %= M;
			}
		}
	}
	printf("%d\n", (dp[0][k] - (k ? dp[0][k - 1] : 0) + M) % M);
	return 0;
}


Measured memory_bytes: 40192
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/cmplx"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	q := getNextInt(scanner)
	for i := 0; i < q; i++ {
		xx := make([]float64, 4)
		yy := make([]float64, 4)
		for i := 0; i < 4; i++ {
			xx[i] = getNextFloat64(scanner)
			yy[i] = getNextFloat64(scanner)
		}

		s1 := complex(xx[1]-xx[0], yy[1]-yy[0])
		_, th := cmplx.Polar(s1)
		s2 := rotate(complex(xx[2]-xx[0], yy[2]-yy[0]), -th)
		s3 := rotate(complex(xx[3]-xx[0], yy[3]-yy[0]), -th)
		ans := rotate(complex(real(s2)+(real(s3)-real(s2))*math.Abs(imag(s2))/(math.Abs(imag(s2))+math.Abs(imag(s3))), 0), th)
		fmt.Fprintln(writer, fmt.Sprintf("%.10f %.10f", real(ans)+xx[0], imag(ans)+yy[0]))
	}
}
func compare(a, b float64) int {
	eps := 1e-10
	if a-b > eps {
		return 1
	}
	if b-a > eps {
		return -1
	}
	return 0
}
func rotate(v complex128, theta float64) complex128 {
	r, th := cmplx.Polar(v)
	th += theta
	return cmplx.Rect(r, th)
}
func degToRad(deg float64) float64 {
	return deg * math.Pi / 180.0
}
func radTodeg(rad float64) float64 {
	return rad * 180.0 / math.Pi
}



Measured memory_bytes: 1364
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD=1000000007LL;
LL x[100000];
LL sumX[100000];
LL y[100000];
LL sumY[100000];
int main() {
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++) {
		cin>>x[i];
	}
	for(int i=0;i<m;i++) {
		cin>>y[i];
	}
	sumX[0]=x[0];
	for(int i=1;i<n;i++) {
		sumX[i]=sumX[i-1]+x[i];
	}
	sumY[0]=y[0];
	for(int i=1;i<m;i++) {
		sumY[i]=sumY[i-1]+y[i];
	}
	LL X=0,Y=0;
	for(int i=1;i<n;i++) {
		X=(X+i*x[i]-sumX[i-1])%MOD;
	}
	for(int i=0;i<m;i++) {
		Y=(Y+i*y[i]-sumY[i-1])%MOD;
	}
	cout<<(X*Y)%MOD<<endl;
}

Measured memory_bytes: 3328
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Point[] points = new Point[n];
		for (int i = 0; i < n; i++) {
		    points[i] = new Point(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(points);
		StringBuilder sb = new StringBuilder();
		for (Point p : points) {
		    sb.append(p).append("\n");
		}
		System.out.print(sb);
	}
	
	static class Point implements Comparable<Point> {
	    int x;
	    int y;
	    
	    public Point(int x, int y) {
	        this.x = x;
	        this.y = y;
	    }
	    
	    public int compareTo(Point another) {
	        if (x == another.x) {
	            return y - another.y;
	        } else {
	            return x - another.x;
	        }
	    }
	    
	    public String toString() {
	        return x + " " + y;
	    }
	}
}



Measured memory_bytes: 106064
#include <bits/stdc++.h>
using namespace std;
int dp[301][301];

int main(){
    int n;
    while(true){
        cin >> n;
        if(n == 0){
            break;
        }
        for(int i = 0; i < 301; ++i){
            for(int j = 0; j < 301; ++j){
                dp[i][j] = 0;
            }
        }
        int w[n + 1];
        w[0] = 0;
        for(int i = 1; i < n + 1; ++i){
            cin >> w[i];
        }
        for(int dif = 1; dif < n; ++dif){
            for(int st = 1; st < n - dif + 1; ++st){
                if(dp[st + 1][st + dif - 1] == dif - 1 && abs(w[st] - w[st + dif]) < 2){
                    dp[st][st + dif] = dif + 1;
                    continue;
                }
                for(int mid = st; mid < st + dif; ++mid){
                    dp[st][st + dif] = max(dp[st][st + dif], dp[st][mid] + dp[mid + 1][st + dif]);
                }
            }
        }
        cout << dp[1][n] << endl;
    }
    return 0;
}


Measured memory_bytes: 3368
n = int(input())
zahyo = [[0 for i in range(2*n)] for j in range(2*n)]
for i in range(n):
    a , b = map(int,input().split())
    zahyo[a][b] = 1

for i in range(n):
    c , d = map(int,input().split())
    zahyo[c][d] = -1
ans = 0
for i in range(2*n):#x R
    for j in range(2*n):#y R
        if zahyo[i][j] == -1:
            flag = False
            for l in reversed(range(j)):#y B
                if flag:
                    break
                for k in reversed(range(i)):#x B
                    if zahyo[k][l] == 1:
                        zahyo[i][j] = 0
                        zahyo[k][l] = 0
                        flag = True
                        ans += 1
                        break
print(ans)

Measured memory_bytes: 74068
S=input()
lists=list(S)
if S[:7]=='keyence':
    print('YES')
elif S[-7:]=='keyence':
    print('YES')
elif S[:6]=='keyenc':
    if S[-1]=='e':
        print('YES')
    else:
        print('NO')
elif S[:5]=='keyen':
    if S[-2:]=='ce':
        print('YES')
    else:
        print('NO')
elif S[:4]=='keye':
    if S[-3:]=='nce':
        print('YES')
    else:
        print('NO')
elif S[:3]=='key':
    if S[-4:]=='ence':
        print('YES')
    else:
        print('NO')
elif S[:2]=='ke':
    if S[-5:]=='yence':
        print('YES')
    else:
        print('NO')
elif S[1]=='k':
    if S[-6:]=='eyence':
        print('YES')
    else:
        print('NO')
else:
    print('NO')

Measured memory_bytes: 3064
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class MainApp
{

	static public void Main()
	{

		int K = Oneint();
		int[] k = new int[K];
		string ans = "";
		int num = 0;
		int A = 0;

		if (K < 10)
		{
			Console.WriteLine(K);
		}
      	else if(K < 11){
        	Console.WriteLine(10);
        }
		else
		{
			A = 1;      //基準
			k[0] = -1;	//1桁目
			num = 1;    //機能している桁
			for(int j = 11; j < K+1; j++)
			{
				int ok = 0;
				while(ok == 0)
				{
					k[0]++;							//数字を一つ増やす
					
					for (int i = 0; i < num-1; i++)
					{
                      
						if (k[i] == 2)              //2になったら
						{
							k[i] = -1;
							k[i + 1]++;
						}
						else
						{
							i = num;
						}
					}
					if (k[num - 1] == 2)                //基準の一つ下が2になったら
					{
						A++;                        //Aの値を1増やす
						k[num - 1] = -1;             
						
						if (A == 10)                        //桁が変わったら
						{
							num++;                      //機能桁をふやして
							k[num - 1] = -1;            //一番上の機能桁を-1にして
							A = 1;                      //Aを1にする
						}
					}
	
					 


					int ifnum = A;
                  
					for (int i = 0; i < num; i++)       //その数字が数字として成立するか否か
					{
						ifnum += k[num - i - 1];
                      
						if (ifnum < 0 || ifnum > 9)              //もし数字として成立しなかったら
						{
							i = num;                //ループを出る
						}
						else
						{
							if(i == num - 1)
							{
								ok = 1;
                              //Console.WriteLine(ifnum);
							}
                          
						}
					}
				}
			}
			int ifif = A;         
            ans = ifif.ToString();
			for(int i = 0; i < num; i++)
			{
				ifif += k[num - i -1];
				ans += ifif.ToString();
              //Console.WriteLine(k[num - i -1]);
			}
			Console.WriteLine(ans);
			
		}



	}


	private static string[] Arraystring()
	{
		return Console.ReadLine().Split(' ');
	}

	private static string Onestring()
	{
		return Console.ReadLine();
	}

	private static int Oneint()
	{
		return int.Parse(Console.ReadLine());
	}

	private static int[] Arrayint()
	{
		return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
	}
}

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

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++)
		cin >> a[i];
	for (int i = 0; i < a.size(); i++)
	{
		bool del = true;
		for (int j = 0; j < w; j++)
			if (a[i][j] == '#')
				del = false;
		if (del)
		{
			a.erase(a.begin() + i);
			i--;
		}
	}
	for (int i = 0; i < a[0].length(); i++)
	{
		bool del = true;
		for (int j = 0; j < a.size(); j++)
			if (a[j][i] == '#')
				del = false;
		if (del)
		{
			for (int k = 0; k < a.size(); k++)
				a[k].erase(a[k].begin() + i);
			i--;
		}
	}
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
    int n,b[8],k=0,temp,a[8],ans;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        ans=0;
        scanf("%d",&temp);
        for(int j=0;j<8;j++){
            a[j]=temp%10;
            temp/=10;
        }
        sort(a,a+8);
        for(int j=0;j<8;j++){
            b[7-j]=a[j]-a[7-j]-k;
            k=0;
            if(b[7-j]<0){
                b[7-j]+=10;
                k=1;
            }
        }
        for(int j=0;j<8;j++){
            ans+=b[j];
            ans*=10;
        }
        ans/=10;
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 2780
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let r : u64 = read();
    let ans = if r < 1200 {
        "ABC"
    } else if r < 2800 {
        "ARC"
    } else{
        "AGC"
    };
    println!("{}",ans );
}

Measured memory_bytes: 4352
use proconio::input;

fn main() {
    input! {
        x: usize,
        y: usize,
    }

    let prize = [300_000, 200_000, 100_000];

    let ans = if x <= 3 { prize[x - 1] } else { 0 }
        + if y <= 3 { prize[y - 1] } else { 0 }
        + if x == 1 && y == 1 { 400_000 } else { 0 };

    println!("{}", ans);
}


Measured memory_bytes: 2136
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var a, b, c, d, e int
	fmt.Scan(&a, &b, &c, &d, &e)
	arr := []int{a, b, c, d, e}
	sort.Sort(sort.IntSlice(arr))
	sum := 0
	min := math.MaxInt32
	for _, i := range arr {
		if i % 10 != 0 {
			if min > i % 10 {
				min = i % 10
			}
		}
		tmp := math.Ceil(float64(i) * 0.1)
		sum += int(tmp) * 10
	}
	if min != math.MaxInt32 {
		fmt.Println(sum - (10 - min))
	} else {
		fmt.Println(sum)
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
const int N=(1<<18)+10;
struct Data{
	ll mx,smx;
	void init(ll x){mx=x; smx=-1;}
	void update(Data x){
		if (x.mx>mx)
			smx=mx,mx=x.mx;
		else if (x.mx>smx)
			smx=x.mx;
		if (x.smx>smx)
			smx=x.smx;
	}
}info[N];
ll a[N];
int n;
ll ans;
bool in(int st,int x){return st>>x&1;}
int St(int x){return 1<<x;}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("a.in","r",stdin);
#endif
	scanf("%d",&n);
	for (int i=0;i<(1<<n);++i) scanf("%lld",a+i),info[i].init(a[i]);
	for (int i=0;i<n;++i){
		for (int j=0;j<(1<<n);++j){
			if (in(j,i))
				info[j].update(info[j^St(i)]);
		}
	}
	ans=0;
	for (int i=1;i<(1<<n);++i){
		ans=max(ans,info[i].mx+info[i].smx);
		printf("%lld\n",ans);
	}
}


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



int main()
{
    
    int n, ret = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        int cnt = 0;
        int tmp = i;
        while(tmp)
        {
            cnt++;
            tmp /= 10;
        }
        if(cnt % 2 == 1)
            ret++;
    }
    
    cout << ret;
    
    
    return 0;
}

Measured memory_bytes: 256
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.13 19:41:39
**/

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

#include <atcoder/all>
template< int MOD >
struct mint {
public:
    long long x;
    mint(long long x = 0) :x((x%MOD+MOD)%MOD) {}
    mint(std::string &s) {
        long long z = 0;
        for (int i = 0; i < s.size(); i++) {
            z *= 10;
            z += s[i] - '0';
            z %= MOD;
        }
        this->x = z;
    }
    mint& operator+=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint& operator/=(const mint &a) {
        long long n = MOD - 2;
        mint u = 1, b = a;
        while (n > 0) {
            if (n & 1) {
                u *= b;
            }
            b *= b;
            n >>= 1;
        }
        return *this *= u;
    }
    mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-() const {return mint() -= *this; }
    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
    friend std::ostream& operator<<(std::ostream &os, const mint &n) {
        return os << n.x;
    }
    friend std::istream &operator>>(std::istream &is, mint &n) {
        long long x;
        is >> x;
        n = mint(x);
        return is;
    }
    bool operator==(const mint &a) const {
        return this->x == a.x;
    }
    mint pow(long long k) const {
        mint ret = 1;
        mint p = this->x;
        while (k > 0) {
            if (k & 1) {
                ret *= p;
            }
            p *= p;
            k >>= 1;
        }
        return ret;
    }
};
const int MOD = 998244353;
struct S {
    mint<MOD> a;
    int size;
    
};
struct F {
    mint<MOD> a,b;
    
};
S op(S l, S r) { return S{l.a + r.a, l.size + r.size}; }
S e() { return S{0, 0}; }
S mapping(F l, S r) { return S{r.a * l.a + l.b * r.size, r.size}; }
F composition(F l, F r) { return F{r.a * l.a, r.b * l.a + l.b}; }
F id() { return F{1, 0}; }
int main() {
    int n,q;cin >> n >> q;
    vector<S> a(n);
    for (int i = 0; i < n; i++) {
        int aa;
        scanf("%d",&aa);
        a[i].a = aa;
        a[i].size = 1;
    }
    atcoder::lazy_segtree<S,op,e,F,mapping,composition,id> seg(a);
    while(q--) {
        int t;cin >> t;
        if (t == 0) {
            int l, r;
            int c, d;
            scanf("%d %d %d %d", &l, &r, &c, &d);
            seg.apply(l, r, F{c, d});
        }
        else {
            int l, r;
            scanf("%d %d", &l, &r);
            cout << seg.prod(l,r).a << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 35772
/*
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1234567891
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 200000;

const int TTL = 1;

int n, m, can[N];
int cnt[N];
int a, b;
int ans;

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n >> m;

	can[1] = 1;
	for (int i = 1; i <= n; i++)
	{
		cnt[i] = 1;
	}

	for (int i = 1; i <= m; i++)
	{
		int a, b;
		cin >> a >> b;
		cnt[a]--;
		cnt[b]++;
		if (can[a])
			can[b] = 1;
		if (cnt[a] == 0)
			can[a] = 0;
	}

	for (int i = 1; i <= n;i++)
	if (can[i])
		++ans;
	cout << ans << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    int A[N],i,j,minj,c=0,k;
    for(i=0;i<N;i++) cin>>A[i];
    for(i=0;i<N;i++){
        minj=i;
        for(j=i;j<N;j++){
            if(A[j]<A[minj]) minj=j;
        }
        k=A[i];
        A[i]=A[minj];
        A[minj]=k;
        if(minj!=i) c++;
    }
    for(i=0;i<N;i++){
        cout<<A[i];
        if(i!=N-1) cout<<" ";
    }
    cout<<endl<<c<<endl;
}


Measured memory_bytes: 3096
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

def func(a, b, c):
    if a%2 == 1 or b%2 == 1 or c%2 ==1:
        return 0
    if a == b and a == c:
        return -1
    return func((b+c)//2, (c+a)//2, (a+b)//2) + 1

a, b, c= inpl()
ans = func(a, b, c)
print(ans)

Measured memory_bytes: 4080
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>
#include <stack>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    string X;
    cin >> X;
    stack<char> st;
    string res = "";
    rep(i, 0, X.length()) {
        if (st.empty()) {
            if (X[i] == 'S') {
                st.push(X[i]);
            } else {
                res.push_back(X[i]);
            }
        } else {
            if (st.top() == 'S') {
                if(X[i] == 'T') {
                    st.pop();
                } else {
                    st.push(X[i]);
                }
            }
        }

    }
    cout << res.length() + st.size() << endl;
    return 0;
}

Measured memory_bytes: 644
import java.util.HashMap;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		HashMap<Integer, Integer> hs = new HashMap<Integer, Integer>();

		hs.put(500, scanner.nextInt());
		hs.put(100, scanner.nextInt());
		hs.put(50, scanner.nextInt());
		int total = scanner.nextInt();
		int success = 0;

		for(int i = 0; i <= hs.get(500); i++) {
			for(int j = 0; j <= hs.get(100); j++) {
				for(int k = 0; k <= hs.get(50); k++) {
					if(500 * i + 100 * j + 50 * k == total)success++;
				}
			}
		}

		System.out.println(success);

		scanner.close();
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ",a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf=0x3f3f3f3f;
const int MAXN = 3e2+10;
const int mode=1e9+7;
int N,x;
int num[4];
double dp[MAXN][MAXN][MAXN];
double dfs(int a,int b,int c)
{
	if(a==0&&b==0&&c==0)return 0;
	if(dp[a][b][c])return dp[a][b][c];
	double sum=a+b+c;
	double ans=1.0*N/sum;
	if(a)ans+=a*1.0/sum*dfs(a-1,b,c);
	if(b)ans+=b*1.0/sum*dfs(a+1,b-1,c);
	if(c)ans+=c*1.0/sum*dfs(a,b+1,c-1);
	return dp[a][b][c]=ans;
}
int main()
{
	IO;
	cin>>N;
	for(int i=1;i<=N;++i)
	{
		cin>>x;
		num[x]++;
	}
	cout<<fixed<<setprecision(10)<<dfs(num[1],num[2],num[3])<<endl;
 } 


Measured memory_bytes: 225664
#include <iostream>
using namespace std;
int main(void){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if(a <= c && d <= b)
    cout << d - c << endl;
  else if(c <= a && b <= d)
    cout << b - a << endl;
  else if(b <= c)
    cout << 0 << endl;
  else if(d <= a)
    cout << 0 << endl;
  else if(b - c >= 0 && a <= c)
    cout << b - c << endl;
  else
    cout << d - a << endl;
  
  
  return 0;
}

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

using namespace std;

typedef pair<int,int>P;

const int N = 1 << 17;
const ll INF = (1<<31) - 1;

int n,n_;
ll dat[2*N-1];

void init(int x)
{
	n_=1;
	while(n_<x){
		n_*=2;
	}
	rep(i,2*n_-1){
		dat[i] = INF;
	}
}

void update(int k,ll a)
{
	k += n_-1;
	dat[k] = a;
	while(k>0){
		k = (k-1)/2;
		dat[k] = min(dat[2*k+1],dat[2*k+2]);
	}
}

ll query(int a,int b,int k,int l,int r)
{
	if(r <= a || b <= l){
		return INF;
	}
	if(a <= l && r <= b){
		return dat[k];
	}else{
		ll vl = query(a,b,2*k+1,l,(l+r)/2);
		ll vr = query(a,b,2*k+2,(l+r)/2,r);
		return min(vl,vr);
	}
}

int main()
{
	int q;
	scanf("%d%d",&n,&q);
	init(n);
	rep(i,q){
		int k,x;
		ll y;
		scanf("%d",&k);
		scanf("%d%lld",&x,&y);
		if(k==0){
			update(x,y);
		}else{
			printf("%lld\n",query(x,y+1,0,0,n_));
		}
	}
	return 0;
}

Measured memory_bytes: 5224
import Data.Bool

main :: IO ()
main = do
  (n:ps) <- readParams
  putStrLn $ solve [1..n] ps

readParams :: Read a => IO [a]
readParams = map read . words <$> getContents

solve :: [Int] -> [Int] -> String
solve = format .: solve'

format :: Bool -> String
format = bool "NO" "YES"

solve' :: [Int] -> [Int] -> Bool
solve' = (<=2) .: length .: filter (/=0) .: zipWith (-)

infixr 8 .:
(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(f .: g) x y = f $ g x y


Measured memory_bytes: 636
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion

int fpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = res * a % M7;
        }
        b /= 2;
        a = a * a % M7;
    }
    return res;
}

int gcd(int a, int b) {
    while (b != 0) {
        int t = a % b;
        a = b;
        b = t;
    }
    return a;
}

int32_t main() {
    make(int, n, k);
    VI p;
    VI dl(k + 1), f(k + 1);
    f[1] = 1;
    dl[1] = 1;
    for (int i = 2; i <= k; ++i) {
        if (dl[i] == 0) {
            dl[i] = i;
            f[i] = -1;
            p.push_back(i);
        }
        for (int j = 0; j < p.size() && p[j] <= dl[i] && i * p[j] <= k; ++j) {
            int num = i * p[j];
            dl[num] = p[j];
            if (dl[num] == dl[num / dl[num]]) {
                f[num] = 0;
            } else {
                f[num] = -f[i];
            }
        }
    }


    int ans = 0;
    for (int i = 1; i <= k; ++i) {
        for (int m = 1; m * i <= k; ++m) {
            int num = m * i;
            int d = k / num;
            ans = (ans + (fpow(d, n) * i * f[m]) % M7 + M7) % M7;
        }
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 5080
v = require('fs').readFileSync('/dev/stdin', 'utf8').replace(/\n/g, ' ').split(' '), arr = [];
for (i = 1; i <= v[0]; i++) arr[i] = 0;
for (i = 2; i <= v.length; i++) arr[parseInt(v[i])]++;
for (i = 1; i < arr.length; i++) console.log(arr[i]);

Measured memory_bytes: 7628
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i = 0; i < (int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int n, l;
	cin >> n >> l;
	int sum = 0;
	int ans = l;
	int a[200];
	int absans = abs(l);
	rep(i, n) {
		a[i] = l + i;
		sum += l + i;
		if (abs(a[i]) < absans) {
			absans = abs(a[i]);
			ans = a[i];
		}
	}
	cout << sum - ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a <= b) {
			if((b - (a + w)) >= 0) {
				System.out.println(b - (a + w));
			}else {
				System.out.println(0);
			}
		}else if(a > b) {
			if((a - (b + w)) >=0) {
				System.out.println(a - (b + w));
			}else {
				System.out.println(0);
			}
		}
	}
}


Measured memory_bytes: 35636
#include<stdio.h>
#include<string.h>
#define N 36

typedef struct{
  char rom;
  int value;
}card;

void Bsort(card ary[],int n){
  int i,j;
  card tmp;
for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(ary[j].value<ary[j-1].value){
        tmp=ary[j];
        ary[j]=ary[j-1];
        ary[j-1]=tmp;
      }
    }
  }
}

void Ssort(card ary[],int n){
  int i,j,minj;
  card tmp;
  for(i=0;i<n-1;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(ary[j].value<ary[minj].value){
	minj=j;
      }
    }
    tmp=ary[i];
    ary[i]=ary[minj];
    ary[minj]=tmp;
  }
}
void print(card ary[],int n){
  int i;
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%c%d",ary[i].rom,ary[i].value);
  }
  printf("\n");
}

int stable(card ary1[],card ary2[],int n){
  int i;
  for(i=0;i<n;i++){
    if(ary1[i].rom!=ary2[i].rom)return 0;
  }
  return 1;
}
int main(){
  char kuhaku;
  int i,n;
  card ary1[N],ary2[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%c%c%d",&kuhaku,&ary1[i].rom,&ary1[i].value);
  }
  for(i=0;i<n;i++){
    ary2[i]=ary1[i];
  } 
  Bsort(ary1,n);
  Ssort(ary2,n);
  
  print(ary1,n);
  printf("Stable\n");
  print(ary2,n);
  if(stable(ary1,ary2,n))printf("Stable\n");
  else printf("Not stable\n");
  
  return 0;
}



Measured memory_bytes: 2076
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#define re register
#define N 55
#define LL long long
using namespace std;
int n,A,a[N];
LL f[N][N][N*N],ans=0;
int main(){
	scanf("%d%d",&n,&A);
	for(re int i=1;i<=n;++i) scanf("%d",&a[i]);
	memset(f,0,sizeof(f)); f[0][0][0]=1ll;
	for(re int i=0;i<=n;++i){
		for(re int j=0;j<=i;++j){
			for(re int k=0;k<=2500;++k){
				if(f[i][j][k]){
					f[i+1][j+1][k+a[i+1]]+=f[i][j][k];
					f[i+1][j][k]+=f[i][j][k];
				}
			}
		}
	}
	for(re int i=1;i<=n;++i) if(f[n][i][i*A]) ans+=f[n][i][i*A];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 71680
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <stack>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

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

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair

#define F first
#define S second

#define popcnt __builtin_popcountll

#define rep( i, n ) for ( ll i = 0; i < (ll)( n ); ++i )
#define reps( i, n ) for ( ll i = 1; i <= (ll)( n ); ++i )
#define rrep( i, n ) for ( ll i = (ll)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( ll i = (ll)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }


int main()
{
	ll n; cin >> n;
	vector<ll> a( n );
	rep( i, n ) cin >> a[i];

	ll ans = 0;
	rep( i, n - 1 )
	{
		if ( a[i] > a[i + 1] )
		{
			ans += a[i] - a[i + 1];
			a[i + 1] += a[i] - a[i + 1];
		}
	}

	cout << ans << endl;

	return ( 0 );
}


Measured memory_bytes: 4364