akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	if n == 1 {
		fmt.Println(1)
	} else {
		p, q := 2, 1
		for i := 2; i <= n; i++ {
			p, q = q, p+q
		}
		fmt.Println(q)
	}
}


Measured memory_bytes: 1776
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
//		int[] lines = new int[n];
		List<Integer> line = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
//			lines[i] = sc.nextInt();
			line.add(sc.nextInt());
		}
		Collections.sort(line);
		
		int ans = 0;
		Integer one = null;
		Integer two = null;
		Integer three = null;
		for (int i = 0; i < line.size(); i++) {
			one = line.get(i);
			for (int j = i + 1; j < line.size(); j++) {
				if (one.intValue() == line.get(j).intValue()) {
					continue;
				}
				two = line.get(j);
				for (int k = j +1; k < line.size(); k++) {
					if (two.intValue() == line.get(k).intValue()) {
						continue;
					}
					three = line.get(k);
					if (one.intValue() + two.intValue() > three.intValue()) {
						ans++;
					}
				}
			}
		}
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 36928
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,m,l;
int a,b,c;
int q,s,t;
int dist[301][301], fuel[301][301];

signed main(){
    I(n); I(m); I(l);
    REP(i,n) REP(j,n) dist[i][j] = INT64_MAX / 4;
    REP(i,m){
        I(a); I(b); I(c);
        a--; b--;
        dist[a][b] = dist[b][a] = c;
    }
    REP(_,3) REP(i,n) REP(k,n) REP(j,n) 
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    REP(i,n) REP(j,n) fuel[i][j] = (dist[i][j] <= l ? 1 : INT64_MAX/4);
    
    REP(_,3) REP(i,n) REP(k,n) REP(j,n) 
        fuel[i][j] = min(fuel[i][j], fuel[i][k] + fuel[k][j]);
    I(q);
    REP(_,q){
        I(s); I(t);
        s--; t--;
        cout << (fuel[s][t] < INT32_MAX ? fuel[s][t] - 1: -1) << endl;
    }
}

Measured memory_bytes: 1920
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

ll N, K, R, S, P;
string T;

const string h = "rsp";
const int LIM = 202020;
ll dp[3][LIM];

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

    cin >> N >> K >> R >> S >> P >> T;
    ll c[3] = {R, S, P};

    ll ans = 0;
    int W = N/K + 3;
    for (int m = 0; m < K; ++m) {
        for (int i = 0; i < 3; ++i) { fill(dp[i], dp[i]+W, 0); }

        ll pa = 0;
        for (int i = 0; i*K+m < N; ++i) {
            for (int j = 0; j < 3; ++j) {
                int score = (h[(j+1)%3] == T[i*K+m]) ? c[j] : 0;
                if (i == 0) {
                    dp[j][i] = score;
                } else {
                    dp[j][i] = max(dp[(j+1)%3][i-1], dp[(j+2)%3][i-1]) + score;
                }
                pa = max(pa, dp[j][i]);
            }
        }
        ans += pa;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3792
#include <iostream>
#include <string>
using namespace std;
#define P pair<int,string>
const P m[10] = {
  P(0,""), P(5,".,!? "), P(3,"abc"), P(3,"def"), P(3,"ghi"),
  P(3,"jkl"), P(3,"mno"), P(4,"pqrs"), P(3, "tuv"), P(4,"wxyz"),
};
int main()
{
  int n;
  cin >> n;
  while(n--){
    string s;
    cin >> s;
    int p,i,j=0;
    for(i=0;i<s.length();i++){
      if(s[i] == '0' && j != 0){
	cout << (m[p].second)[(j-1)%(m[p].first)];
	j = 0;
      }else if(s[i] != '0'){
	p = s[i] - '0';
	j++;
      }
    }
    cout << endl;
  }
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; ll a, b;
	cin>>n>>a>>b;
	vector<int> x(n);
	for(int i = 0; i < n; i++){
		cin>>x[i];
	}
	ll ans = 0;
	for(int i = 1; i < n; i++){
		ans += min(a*(x[i] - x[i - 1]), b);
	}
	cout<<ans<<'\n';

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    n *= 3;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n, greater<int>());

    ll ans = 0;
    for (int i = 1; i < n / 3 * 2; i += 2) ans += a[i];

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


Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
using namespace std;
#define rep(i, a, b) for(int i=(a); i<(b); i++)
int main(){
  int n,m,L[100000],R[100000];
  cin>>n >> m;
  int Lmax = 0, Rmin = 100001;
  
  rep(i,0,m){
    cin >> L[i] >> R[i];
    Lmax = max(Lmax, L[i]);
    Rmin = min(Rmin,R[i]);
  }

  if(Rmin - Lmax+1>=0) cout<< Rmin - Lmax+1<< endl;
  else cout << "0" << endl; 
}


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


int main(){
    int N; cin >> N;
    vector<pair<int,int>> student(N);
    rep(i, N){
        int a; cin >> a;
        student[i] = make_pair(a, i+1);
    }

    sort(begin(student), end(student));

    rep(i, N){
        cout << student[i].second;
        if(i < N) cout << " ";
    }
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int k, n, t[112345], d[112345], ma[112345] = {0};
    V v;
    priority_queue<int> q;

    ll sum = 0;
    ll s = 0;

    cin >> n >> k;
    REP(i, n)
    {
        cin >> t[i] >> d[i];
        ma[t[i]] = max(ma[t[i]], d[i]);
    }

    bool b[112345] = {false};

    V v_;

    REP(i, n)
    {
        if (!b[t[i]] && ma[t[i]] == d[i])
        {
            b[t[i]] = true;
            v.push_back(ma[t[i]]);
            s += ma[t[i]];
        }
        else
        {
            q.push(d[i]);
            v_.push_back(d[i]);
        }
    }

    SORT(v);
    SORT(v_);

    sum = 0;

    if (k > v.size())
    {
        REP(i, k - v.size())
        {
            sum += q.top();
            q.pop();
        }
    }

    ll res = 0;

    for (ll i = v.size(); i > 0; i--)
    {
        if (i <= k)
        {
            res = max(res, s + sum + i * i);

            q.push(v[v.size() - i]);
            s -= v[v.size() - i];

            sum += q.top();
            q.pop();
        }
        else
        {
            q.push(v[v.size() - i]);
            s -= v[v.size() - i];
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 2808
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<vector<int>> to;
int dp(int now) {
  if (!to[now].size())
    return 0;
  vector<int> res;
  for (auto next : to[now])
    res.push_back(dp(next));
  sort(res.rbegin(), res.rend());
  int mx = 0;
  rep(i, res.size()) {
    res[i] += 1+i;
    chmax(mx, res[i]);
  }
  return mx;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  to.resize(n);
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    --a;
    to[a].push_back(i);
  }
  int ans = dp(0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19304
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    int n, k;
    string s;
    cin >> n >> s >> k;
    char tmp = s[k - 1];
    for (int i = 0; i < n;i++){
        if(s[i]!=tmp)
            s[i] = '*';
    }
    cout << s << endl;
}

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

int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  int sum = 0;
  int min = A * X + B * Y;
  for(int i = 0; i <= 100000; i++) {
    sum = 2 * C * i + max( X - i , 0 ) * A + max( Y - i, 0 ) * B;
    if(min > sum) min = sum;
  }

  cout << min; 
  return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

# input
N,M =map(int,input().split())
A = [0]*N
B = [0]*M
C = [0]*M

A = list(map(int, input().split()))
A.sort()
for i in range(M):
    B[i],C[i] = list(map(int,input().split()))


def solve():

    pairs = zip(C, B)
    sortedpairs = sorted(pairs, key=lambda x: x[0])
    for i in range(M):
        B[i]=sortedpairs[i][1]
        C[i]=sortedpairs[i][0]

    ansA=[0]*N
    for j in range(N):
        ansA[j] = A[j]

    p = int(0)
    j = int(0)
    while  j<N and M>=1+p :
        jd = int(0)
        if ansA[j] >= C[M - 1 - p]:
            break
        while  B[M-1-p]-jd>0 :
            if j==N : break
            if ansA[j]>=C[M-1-p] :
                break
            else:
                ansA[j]=C[M-1-p]
            jd +=1
            j +=1

        p +=1

    ans = int(0)
    for j in range(N):
        ans += ansA[j]

    print(ans)

solve()



Measured memory_bytes: 24092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] s = new char[h][w];
		for (int i = 0; i < h; i++) {
			s[i] = sc.next().toCharArray();
		}
		sc.close();

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '#') {
					boolean flg = false;
					if (i - 1 >= 0 && s[i - 1][j] == '#') flg = true;
					if (i + 1 < h && s[i + 1][j] == '#') flg = true;
					if (j - 1 >= 0 && s[i][j - 1] == '#') flg = true;
					if (j + 1 < w && s[i][j + 1] == '#') flg = true;
					if (!flg) {
						System.out.println("No");
						return;
					}
				}
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 23252
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func calc(array []int) int {
	return array[2] - (array[0] - array[1])
}

// run is run
func run(array []string) int {
	var arrayInt = make([]int, len(array))

	// for i := 0; i < len(array); i++ {
	for idx, value := range array {
		valueInt, _ := strconv.Atoi(value)
		arrayInt[idx] = valueInt
	}

	if ret := calc(arrayInt); ret > 0 {
		return ret
	}
	return 0
}

func main() {
	var n string
	var sc = bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		n = sc.Text()
	}

	array := strings.Fields(n)[:3]

	fmt.Println(run(array))
}



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

int main(){
  int a,b;
  cin >> a >> b;
  if(a%2 == 1 && b%2 == 1){
    puts("Odd");
    return 0;
  }
  puts("Even");
  return 0;
}


Measured memory_bytes: 256
input = gets(nil).chomp

ns = input.split("\n").map(&:to_i)
max = ns.max

f = {}
1.upto(max) do |i|
  if i == 1
    f[1] = 1
  else
    f[i] = i * f[i-1]
  end
end

ns.each do |n|
  exit if n == 0
  s = f[n].to_s.reverse
  a = 0
  s.each_char do |c|
    if c == "0"
      a += 1
    else
      puts a
      break
    end
  end
end

Measured memory_bytes: 185700
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f //inf=1061109567
#define Max 100100
#define pii pair<int, int>
using namespace std;

int n, m; 
vector<pii>edges[Max]; 
int dist[Max];   
int vis[Max];
int pred[Max];

void dijkstra(int s){ 

	for(int i=1; i<=n; i++) dist[i]=inf; 
	dist[s]=0; 

	priority_queue<pii, vector<pii>, greater<pii>>queue; 

	queue.push(make_pair(dist[s], s));
	
	while(true){
		int u=-1; 
		
		while(!queue.empty()){
			
			int a = queue.top().second;
			queue.pop();	
			
			if(!vis[a]){
				u = a;
				break;
			}
		}
		
		if(u == -1) break;
		vis[u] = true;		
		
		for(int i=0; i < (int)edges[u].size(); i++){
			
			int v = edges[u][i].first; 
			int w = edges[u][i].second; 
			
			if(dist[w] > dist[u]+v){
				dist[w] = dist[u]+v; 
				pred[w] = u;
				queue.push(make_pair(dist[w], w)); 
			}
		}
	}

}

int main(){
	cin >> n >> m;
	
	int x, y;
	for(int i=0; i<m; i++){
		cin >> x >> y;
		edges[x].push_back({1, y});
		edges[y].push_back({1, x});
	}
	
	if(edges[1].size() == 0){
		cout << "No" << endl;
		return 0;
	}
	
	dijkstra(1);
	cout << "Yes" << endl;
	for(int i=2; i<=n; i++){
		cout << pred[i] << endl;
	}
	
	return 0;
}
 


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

int main()
{
    int n;
    cin>>n;
    vector<vector<int>> v(n,vector<int>(3,0));
    for(int i=0;i<n;i++)
        cin>>v[i][0]>>v[i][1]>>v[i][2];

    vector<vector<int>> dp(n,vector<int>(3,0));
    dp[0][0]=v[0][0];
    dp[0][1]=v[0][1];
    dp[0][2]=v[0][2];

    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            dp[i][j]=v[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
        }
    }
    int Max=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<< Max;
}


Measured memory_bytes: 11136
#include <stdio.h>

int main(void){
    int h, w;
    char s[50+5][50+5];
    scanf("%d %d", &h, &w);
    for(int i=0; i<h; i++)scanf("%s", s[i]);
    
    for(int y=0; y<h; y++){
        for(int x=0; x<w; x++){
            if(s[y][x]=='.'){
                int cnt=0;
                for(int yy=-1; yy<2; yy++){
                    for(int xx=-1; xx<2; xx++){
                        if(y+yy>=0 && y+yy<h && x+xx>=0 && x+xx<w && !(xx==0 && yy==0)){
                            if(s[y+yy][x+xx]=='#')cnt++;
                        }
                    }
                }
                printf("%d", cnt);
            }else{
                printf("#");
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1736
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		char arr[] = new char[s.length()];
		arr = s.toCharArray();
		for(int i=0;i<s.length();i++)
		{
			if(arr[i]==' ')
				arr[i]=',';
		}
		String ss = new String(arr);
		// System.out.println(ss);
		// int n = sc.nextInt();
		// System.out.println(0);
		// String s = sc.next();
		String sarr[] = ss.split(",");
		int aarr[] = new int[sarr.length];
		// sarr[] = ;
		// System.out.println("fghj");
		for(int i=0;i<sarr.length;i++)
			aarr[i]=Integer.parseInt(sarr[i]);
		Arrays.sort(aarr);
		
		int count = 0;
		for(int i=sarr.length - 1;i>0;i--)
			count+= aarr[i]-aarr[i-1];

		System.out.println(count);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <cassert>
using namespace std;
typedef long long ll;
ll dp[200010] = {},fib[200010],mod = 1000000007;
string s;
vector<pair<char,int>> v;
int main(){
	ll i,j,n,m;
	cin >> n >> m >> s;
	if(s[0]=='B'){
		for(i=0;i<m;i++){
			if(s[i]=='R') s[i] = 'B';
			else s[i] = 'R';
		}
	}
	for(i=0;i<m;i++){
		if(i==0 || v.back().first!=s[i]){
			v.push_back({s[i],1});
		}else{
			v.back().second++;
		}
	}
	if(v.size()==1){
		fib[0] = 1,fib[1] = 1;
		for(i=2;i<=n;i++){
			fib[i] = (fib[i - 1] + fib[i - 2])%mod;
		}
		cout << (fib[n] + fib[n - 2])%mod << endl;
		return 0;
	}
	if(n&1){
		cout << 0 << endl;
		return 0;
	}
	if(v.back().first=='R'){
		v.pop_back();
	}
	int mn = -1;
	for(i=0;i<v.size();i++){
		if(i==0){
			mn = v[i].second + 1 - (v[i].second&1);
		}
		if(v[i].first=='R' && (v[i].second&1)){
			mn = min(mn,v[i].second);
		}
	}
	mn++;
	dp[0] = 1;
	ll sum = 1;
	for(i=2;i<=n;i+=2){
		(dp[i] += sum) %= mod;
		(sum += dp[i]) %= mod;
		if(i>=mn) sum -= dp[i - mn];
		if(sum<0) sum += mod;
	}
	ll ans = 0;
	for(i=2;i<=mn;i+=2){
		(ans += i*dp[n - i]) %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2808
/*Flamenco Sketches*/
#include<bits/stdc++.h>
using namespace std;
 
#define NL '\n'
#define xx first
#define yy second
#define ll long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define async() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 
//#define FayeValentine 
void dbg(){cerr<<NL;}template<typename H,typename... T> void dbg(H h,T... t){cerr<<' '<<h;dbg(t... );}
#ifdef  FayeValentine
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",dbg(__VA_ARGS__)
#else
#define debug(...) 
#endif


void absinthe() {
	int n, k; cin >> n >> k;
	vector<ll>a(n); rep(i, 0, n) { cin >> a[i]; a[i] -= k; } 
	sort(all(a)); 
	ll gcd = 0;
	for(int i = 0; i < n; i++) gcd =  __gcd(a[i], gcd);	
	cout << abs(gcd) << NL;
}
 
 
int main(){
  //freopen("input.txt", "r", stdin);
  async();
  int __t = 1; //cin >> __t;
  for(int __c = 1; __c <=__t; __c++) {
    //cout << "Case #" << __c << ": "; 
    absinthe();
  }
}  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll v1[110];
void comb(vector<vector <ll> > &v) {
	
	rep (i,0,v.size()) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	rep (k,1,v.size()) {
		rep (j,1,k) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}

int main(){
  ll n,a,b;
  ld ans=0;
  cin>>n>>a>>b;
  rep(i,0,n)cin>>v1[i];
  sort(v1,v1+n,greater<ll>());
  rep(i,0,a)ans+=v1[i];

  
  cout<<fixed<<setprecision(12)<<ans/a<<endl;
  ans/=a;

  vector<vector<ll> > v(n + 1, vector<ll>(n + 1, 0));
  comb(v);

  ll pos=-1;
  ll cnt=0,cnt2=0;
  ll ans2=0;
  ll x=v1[a-1];
  bool p=false;

  rep(i,0,n){
    if(!p&&v1[i]==x&&ans!=(ld)v1[i]){cnt++;p=true;pos=i;}
    else if(v1[i]==x&&ans!=(ld)v1[i])cnt++;
    
  }
  rep(i,0,n){
    if(ans==(ld)v1[i])cnt2++;
  }

  ans2+=v[cnt][a-pos];
  rep(i,a,min(b,cnt2)+1)ans2+=v[cnt2][i];
  cout<<ans2<<endl;
  //rep(i,0,n)cout<<v1[i]<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[45], *outs=B+40, *outr=B+40;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MOD = 998244353;
const int INF = 1000000000;
const int MAXN = 100010;

int n;
string s[MAXN];

int cnt[2][2];

int main()
{
	/*
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i)
		scanf("%d", &a[i]);
	*/
	ll n;
	cin >> n;
	
	ll ans = 0;
	
	auto check = [&](ll k)
	{
		ll m = k-1;
		if (!m) return;
		if ((m+1)*(n/m) == n) ans += m;
	};
	
	for (ll i = 1; i*i <= n; ++ i)
	{
		if (n%i == 0)
		{
			check(i);
			if (i*i != n) check(n/i);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

#define ll long long

using namespace std;

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

    int n = s.size();

    ll temp,temp1,temp2;
    ll ans = 0;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n-i;j++)
        {
            temp = 0;

            for(int k=j;k<=j+i;k++)
                temp = temp*10 + (s[k]-'0');

            temp1 = max(1,(int)pow(2,(j-1)));
            temp2 = max(1,(int)pow(2,(n-j-i-2)));

            temp = temp1*temp2*temp;
            //cout << temp << endl;
            ans += temp;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string s;
int main(void){
  int ans = 0;
  while(cin >> s){
    int c = 0;
    for(int i = 0; i < (int)s.size(); i++){
      if('0' <= s[i] && s[i] <= '9'){
	c *= 10;
	c += s[i] - '0';
      }else{
	ans += c;
	c = 0;
      }
    }
    ans += c;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1184
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val n = input.nextInt()
    var countAC = 0
    var countWA = 0
    var countTLE = 0
    var countRE = 0
    
    for (i in 1..n) {
      val veridict = input.next()
      
      when (veridict) {
        "AC" -> ++countAC
        "WA" -> ++countWA
        "TLE" -> ++countTLE
        "RE" -> ++countRE
      }
    }
    
    println("AC x $countAC")
    println("WA x $countWA")
    println("TLE x $countTLE")
    println("RE x $countRE")
  }
}

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

using namespace std;
using ll = long long;

ll hoge(ll n, ll life, ll x=0, bool flag3=false, bool flag5=false, bool flag7=false) {
  if (life == 0) {
    if (n < x || not flag3 || not flag5 || not flag7)
      return 0;
    return 1;
  }
  ll ret = 0;
  ret += hoge(n, life/10, x * 10 + 3, true, flag5, flag7);
  ret += hoge(n, life/10, x * 10 + 5, flag3, true, flag7);
  ret += hoge(n, life/10, x * 10 + 7, flag3, flag5, true);
  if (x == 0)
    ret += hoge(n, life/10, x, flag3, flag5, flag7);
  return ret;
}

int main() {
  ll n;
  cin >> n;
  cout << hoge(n, n) << endl;
}


Measured memory_bytes: 3584
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	string s;
	cin >> s;
	int ans = 0;
	REP(i, s.length()) {
		if (s[i] == '1') ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        int[] xa = Console.ReadLine().ToIntArray();

        int x = xa[0];
        int a = xa[1];

        Console.WriteLine(x < a ? 0 : 10);

    }
}

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

using namespace std;

#define ll long long 

int main() {
    int n;
    cin>>n;
    ll a[n][n]; ll d[n][n];
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            cin>>a[i][j];
            d[i][j]=a[i][j];
        }
    }
    
    for(int k=0;k<n;k++) {
        for(int i=0;i<n;i++) {
            for(int j=0;j<n;j++) {
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    
    int flag=0;
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            if(a[i][j]!=d[i][j]) flag=1;
        }
    }

    if(flag) cout<<-1<<endl;
    else {
        ll ans=0;
        for(int i=0;i<n;i++) {
            for(int j=i+1;j<n;j++) {
                int mask=0;
                for(int k=0;k<n;k++) {
                    if(k!=i && k!=j) {
                        mask|=(d[i][j]==d[i][k]+d[k][j]);
                    } 
                }
                if(!mask) ans+=d[i][j];
            }
        }
        cout<<ans<<endl;
    }
    
    return 0;;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <cstring>
using namespace std;
int n,m;
int T[1 << 15];
int G[15][15];
int dp[15][1 << 15];
int DP[2][1 << 15];
int fp[1 << 15];
int turn;
vector<int> sm[1 << 15];
int vis[15][1 << 15];
int tot = 0;
int dfs(int pos,int leave){
    if(leave == 0){
        return G[pos][n - 1];
    }
    if(vis[pos][leave] == turn){
        return dp[pos][leave];
    }
    vis[pos][leave] = turn;
    dp[pos][leave] = -1;
    for(int i = 1; i < n; ++i){
        if(leave >> (i - 1) & 1){
            int nxt = dfs(i,leave - (1 << (i - 1)));
            if(nxt == -1 || G[pos][i] == -1)continue;
            dp[pos][leave] = max(dp[pos][leave],nxt + G[pos][i]);
        }
    }
    return dp[pos][leave];
}
int work(int o,int p){
    vector<int> a;
    a.push_back(0);
    for(int i = 0;i < n - 2; ++i){
        if(o >> i & 1){
            a.push_back(i + 1);
        }
    }
    a.push_back(n - 1);
    for(auto &j:sm[p]){
        DP[0][p - j] = T[j * 2 + 1];
    }
    int st = 0;
    for(int i = 1;i < a.size(); ++i){
        st ^= 1;
        memset(DP[st],0,sizeof(DP[st]));
        for(auto &j:sm[p]){
            for(auto &k:sm[j]){
                DP[st][j - k] = max(DP[st][j - k],DP[st ^ 1][j] + T[k * 2 + (1 << a[i])]);
            }
        }
    }
    return DP[st][0];
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i = 0;i < n; ++i){
        for (int j = 0;j < n; ++j) {
            if(i == j)continue;
            G[i][j] = -1;
        }
    }
    for(int i = 0;i < m; ++i){
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        u--;
        v--;
        tot += w;
        G[u][v] = w;
        G[v][u] = w;
    }
    int all = (1 << n);
    
    for(int j = 0;j < all; ++j){
        for(int i = 0;i < n; ++i){
            if((j >> i & 1) == 0)continue;
            for(int k = i + 1; k < n; ++k){
                if(j >> k & 1){
                    T[j] += G[i][k] > 0 ? G[i][k] : 0;
                }
            }
        }
    }
//    for(int i = 0;i < (1 << n);++i){
//        cout << i<<" "<<T[i] << endl;
//    }
    for(int i = 0;i < all;++i){
        int j = i;
        do{
            //cout << i <<" "<<j<<endl;
            sm[i].push_back(j);
            j = (j - 1) & i;
        }while(j != i);
    }
    int ret = all / 4 - 1;
    for(int i = 0;i <= ret; ++i){
        turn = i;
        fp[i] = dfs(0,i);
    }
    int ans = 0;
    for(int i = 0;i <= ret; ++i){
        if(fp[i] == -1)continue;
        ans = max(ans,fp[i] + work(i,ret - i));
    }
    cout << tot - ans<<endl;
    return 0;
}


Measured memory_bytes: 62208
import java.util.Scanner;

public class Main {
		public static void testArr(int[][] a)
		{
			int a1=0;
			int a2=0;
			int a3=0;
			int b1=0;
			int b2=0;
			int b3=0;
			for(int i=0;i<=a[0][0];i++)
			{
				for(int j=0;j<=a[1][1];j++)
				{
					for(int k=0;k<=a[2][2];k++)
					{
						a1=i;
						b1=a[0][0]-i;
						a2=j;
						b2=a[1][1]-j;
						a3=k;
						b3=a[2][2]-k;
						
						if(a1+b1==a[0][0]&&a1+b2==a[0][1]&&a1+b3==a[0][2]&&
								a2+b1==a[1][0]&&a2+b2==a[1][1]&&a2+b3==a[1][2]&&
									a3+b1==a[2][0]&&a3+b2==a[2][1]&&a3+b3==a[2][2])
						{
							System.out.println("Yes");
							return;
						}
					}
				}
			}
			System.out.println("No");
			return;
		}
		
		public static void main(String[] args){
			
			Scanner s = new Scanner(System.in);
			int[][] a = new int[3][3];
			for(int i=0;i<3;i++)
			{
				for(int j=0;j<3;j++)
				{
					a[i][j]=s.nextInt();
				}
			}
			testArr(a);
			
			s.close();
		}		
}

Measured memory_bytes: 23252
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
day = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
day = day[::-1]
i = day.index(S)
print((i+1))



Measured memory_bytes: 2940
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<math.h>
#include <cassert>
using namespace std;
typedef long long ll;
struct node
{
	char a[111];
	int b;
	int t;
}a[110];
bool cmp(node a, node b)
{
	if (strcmp(a.a, b.a) == 0)
	{
		return a.b > b.b;
	}
	else
	{
		return strcmp(a.a, b.a)<0;
	}
}
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		scanf("%s %d", a[i].a, &a[i].b);
		a[i].t = i;
	}
	sort(a + 1, a + 1 + n, cmp);
	for (int i = 1; i <= n; i++)
	{
		printf("%d\n", a[i].t);
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void){
int x,y,z;
  int ans;
  scanf("%d %d %d",&x,&y,&z);
  ans=x+y;
  ans=min(ans,y+z);
  ans=min(ans,x+z);
  printf("%d\n",ans);
  return 0;  
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	long long n, t, v[65000], sum;

	while (true)
	{
		cin >> n;

		if (n == 0) { break; }

		sum = 0;

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

			sum += t;
		}
		
		for (int j = 0; j < n - 1; j++)
		{
			cin >> v[j];

			sum += v[j];
		}

		sort(v, v + n - 1);

		int ptr = 0;

		while(ptr++ < n - 1)
		{
			if (ptr * sum < (ptr + 1) * (sum - v[ptr - 1]))
			{
				sum -= v[ptr - 1];
			}
			else
			{
				break;
			}
		}
		
		cout << ptr * sum << endl;
	}

	return 0;
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  vector<int> C(N), S(N), F(N);
  for ( int i = 0; i < N-1; i++ ) {
    cin >> C[i] >> S[i] >> F[i];    
  }

  for ( int q = 0; q < N-1; q++ ) {
    int t = 0;  
    for ( int i = q; i < N-1; i++ ) {
      int c, s, f;
      c = C[i]; s = S[i]; f = F[i];      
      if ( s > t ) {
	t = s+c;      
      } else {
      t = f*((t-1)/f+1);
      t += c;
      }
    }

    cout << t << endl;
  }

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 文字列の入力
# 昇順ソート
s = "".join(sorted(list(input())))
# 降順ソート
t = "".join(sorted(list(input()), reverse=True))
# 比較
ans = "Yes" if s < t else "No"
# 表示
print(ans)

Measured memory_bytes: 2940
#include<cstdio>
#define MN 300000
int q[MN+5],ql,qr;
int main()
{
	int n,i,x,l=1;
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&x);
		if((x-l)&1){if(x!=i)return 0*puts("No");}
		else if(ql==qr||x>q[qr-1])q[qr++]=x;
		else if(x==l)l+=2;
		else return 0*puts("No"); 
		while(ql<qr&&q[ql]==l)l+=2,++ql;
		if(l>i+1)l=i+1;
	}
	puts("Yes");
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

class BIT
{
private:
	std::vector<LL>dat;

public:
	void init(LL size)
	{
		dat.resize(size + 1, 0);
	}

	void update(LL k, LL x)
	{
		if (k >= dat.size()) return;
		dat[k] += x;
		update(k + (k & -k), x);
	}

	LL sum(LL k)
	{
		if (!k) return 0;
		return dat[k] + sum(k - (k & -k));
	}
};

int main()
{
	LL n, q;
	in >> n >> q;

	BIT tree;
	tree.init(n + 1);
	rep(loop, q)
	{
		LL com, x, y;
		in >> com >> x >> y;
		if (com == 0) tree.update(x, y);
		else out << tree.sum(y) - tree.sum(x - 1) << std::endl;
	}
}



Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << p.first << " " << p.second;
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string S1;
  std::cin >> S1;

  std::string S2 = S1;
  std::reverse(S2.begin(), S2.end());

  std::string T1 = "";
  ll xcnt = 0LL;
  for (auto c : S1) {
    if (c == 'x') {
      xcnt++;
      continue;
    }
    T1 += c;
  }

  std::string T2 = T1;
  std::reverse(T2.begin(), T2.end());
  if (T2 != T1) {
    print(-1);
    return 0;
  }

  ll N = T1.size()+1;
  std::vector<ll> vx(N, 0LL);
  ll idx = 0LL;
  for (auto c : S1) {
    if (c != 'x') idx++;
    else vx[idx]++;
  }

  ll ans = 0LL;
  for (ll i = 0; i < N/2; i++) {
    ans += std::abs(vx[i] - vx[N-i-1]);
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 1488
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// 移動元と行先と辺のコストを記録する構造体
template <typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int s, T d) : to(s), cost(d) {}
    Edge(int f, int s, T d) : from(f), to(s), cost(d) {}

    bool operator<(const Edge &e) const {
        return cost < e.cost;
    }
    bool operator>(const Edge &e) const {
        return cost > e.cost;
    }
};

template <typename T>
using Graph = vector< vector< Edge<T> > >;

void add_edge(Graph<int> &G, int a, int b, int c, int cost) {
    // a - b
    G[a].push_back(Edge<int>(b, cost));
    G[b].push_back(Edge<int>(a, cost));

    // b - c
    G[b].push_back(Edge<int>(c, cost));
    G[c].push_back(Edge<int>(b, cost));

    // c - a
    G[c].push_back(Edge<int>(a, cost));
    G[a].push_back(Edge<int>(c, cost));
}

struct Elem {
    int pos, cost;
    bool operator<(const Elem &e) const {
        return cost > e.cost;
    }
};
 
signed main() {
    int N, M, s, t; cin >> N >> M >> s >> t;
    s--; t--;

    Graph<int> G(N);
    for(int i=0; i<M; i++) {
        int a, b, c, cost; cin >> a >> b >> c >> cost;
        a--; b--; c--;
        add_edge(G, a, b, c, cost);
    }

    vector<int> dist(N, INF);
    dist[s] = 0;
    priority_queue<Elem> que;
    que.push(Elem{s, 0});

    while(que.size()) {
        Elem cur = que.top(); que.pop();
        int v = cur.pos, cost = cur.cost;
        for(auto e : G[v]) {
            if(dist[e.to] > cost + e.cost) {
                dist[e.to] = cost + e.cost;
                que.push(Elem{e.to, cost + e.cost});
            }
        }
    }

    cout << dist[t] << endl;
    return 0;
}


Measured memory_bytes: 28816
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var pmax = long.MinValue;
        var pmin = long.MaxValue;
        var mmax = long.MinValue;
        var mmin = long.MaxValue;
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var x = long.Parse(line[0]);
            var y = long.Parse(line[1]);
            pmax = Max(pmax, x + y);
            pmin = Min(pmin, x + y);
            mmax = Max(mmax, x - y);
            mmin = Min(mmin, x - y);
        }
        var ans = Max(pmax - pmin, mmax - mmin);
        Console.WriteLine(ans);
    }
}


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

using namespace std;


#define INF 1000000007

int main()
{
    long long int n,d;
    long long int ans=0;
    cin>>n>>d;
    while(n--){
        long long int x, y;
        cin>>x>>y;
        long long int distance  = x*x+y*y;
        if(distance<=(d*d)){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3636
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (i32, i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn main() {
    let (a, b, c) = input_int_tuple();
    if c - (a - b) > 0 {
        println!("{}", c - (a - b));
    } else{
        println!("0");
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	m1 += h1 * 60;
	m2 += h2 * 60;
	int ans = m2 - m1 - k;
	chmax(ans, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <cmath>
#include <fstream>
const int MAX = 1e4+10;
const int INF = 1e6;

using namespace std;

int n;
int cs;
int d[MAX][MAX] = {0};//两点间最短距离 
int sum, ans;
int pos;//最合适位置 

//弗洛伊德最短路径 
void  Floyd(){
	for(int i=0; i<=cs; i++)
		for(int j=0; j<=cs; j++)
			for(int k =0; k<=cs; k++){
				d[j][k] = min(d[j][k], d[j][i]+d[i][k]);
			}			
}
 
//测试函数 
int main(){
	/*ifstream cin ("D:\\钢铁程序员\\程序数据\\062最佳宿舍.txt");//从文件读取数据流，省去手动输入的麻烦 
	if(!cin){//读取如果失败 
		cout << "ERROR" << endl;
	}*/
	while(cin >> n, n){
		cs = 0;//最大城市编号 
		for(int i=0; i<=n; i++)
			for(int j=0; j<=n; j++){
				if(i == j)
					d[i][j] = 0;
				else
					d[i][j] = INF;
			}
		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;
			d[a][b] = c;
			d[b][a] = c;
			cs = max(cs, a);
			cs = max(cs, b);
		}
				
		Floyd();		
		//找最合适位置 
		ans = INF;
		for(int i=0; i<=cs; i++){
			sum = 0;
			for(int j=0; j<=cs; j++){
				sum += d[i][j];
			}
			if(sum < ans){
				pos = i;
				ans = sum;
			}
		} 
		cout << pos << " " << ans << endl;
	}
	//cin.close();//打开文件以后要关闭 
	return 0;
} 


Measured memory_bytes: 3132