akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

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

	while (cin >> N >> M, N) {
		vector<pair<int, pair<int, int>>>edge;
		for (int i = 0; i < M; i++) {
			cin >> L >> R >> K;
			L--, R--;
			edge.push_back({ (int)K,{(int)L,(int)R} });
		}
		sort(edge.begin(), edge.end());
		int ans = MOD;
		bool flag = false;
		for (int i = 0; i < M; i++) {
			UnionFind uf(N);
			int num = 0;
			int r = 0;
			for (int j = i; j < M; j++) {
				if (uf.Check_Same(edge[j].second.first, edge[j].second.second))continue;
				r = edge[j].first;
				num++;
				uf.Unite(edge[j].second.first, edge[j].second.second);
			}
			if (num == N - 1) {
				flag = true;
				ans = min(ans, r - edge[i].first);
			}
		}
		if (ans == MOD)ans = -1;
		cout << ans << endl;
	}
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int>t(n);
rep(i,n)cin>>t[i];
int sum=accumulate(t.begin(),t.end(),0);
int m;
cin>>m;
vector<int>p(m),x(m);
rep(i,m){
    cin>>p[i]>>x[i];
    cout<<sum-t[p[i]-1]+x[i]<<endl;
}

return 0;
}

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

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

  vector<int> num(N, 1);

  vector<pair<int, int>> city(M, make_pair(0, 0));
  for (int i = 0; i < M; i++) {
    int P = 0, Y = 0;
    scanf("%d%d", &P, &Y);
    city.at(i) = make_pair(P, Y);
  }
  vector<pair<int, int>> city_(city.size());
  copy(city.begin(), city.end(), city_.begin());
  sort(city_.begin(), city_.end());

  map<pair<int, int>, string> dic;
  for (int i = 0; i < M; i++) {
    char id_first[7];
    char id_second[7];
    string id;
    sprintf(id_first, "%06d", city_.at(i).first);
    sprintf(id_second, "%06d", num.at(city_.at(i).first - 1));
    id += id_first;
    id += id_second;
    dic[city_.at(i)] = id;
    num.at(city_.at(i).first - 1)++;
  }

  for (int i = 0; i < M; i++) {
    printf("%s\n", dic[city.at(i)].c_str());
  }
  return 0;
}


Measured memory_bytes: 14464
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)
  
struct edge{int to,cost;};
  
#define MAX_V 100000
vector<edge> G[MAX_V];
  
  
void dijkstra(int s, vector<int> &d){
    priority_queue< pii,vector<pii>,greater<pii> > que;
    rep( i,d.size() )d[i]=INF;
    d[s] = 0;
    que.push( pii(0,s) );
    
    while( que.size() ){
        pii p=que.top();
        que.pop();
          
        int v=p.second;
        if( d[v] < p.first ) continue;

        rep(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>e.cost && e.cost >= d[v]){
                d[e.to]=e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}
  
  
int main(){
    int n,m;
    cin>>n>>m;
      
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        G[a].pb(edge{b,c});
    }
      
    vector<int> d(n);
    dijkstra(0,d);
      
      
    int ans = -1;
      
    rep(i,n){
        for(auto &e:G[i]){
            if(e.to==n-1){
                if(d[i]>e.cost)continue;
                ans = max(e.cost,ans);
            }
        }
    }
      
    cout<<ans<<endl;
      
      
}

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

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int a=max(h,w);
    cout<< (n+a-1)/a<<endl;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  for(int i = 0; i < N; ++i) cin >> P[i];
  long long s = 0;
  for(int i = 0; i < K; ++i){
    s += (P[i]+1);
  }
  long long ans = 0;
  ans = max(ans,s);
  for(int i = K; i < N; ++i){
    s -= P[i-K]+1;
    s += P[i]+1;
    ans = max(ans,s);
  }
  printf("%.12f\n",(double)ans/2);
}


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

int main(void){
	int H, W;

	while (true){
		cin >> H >> W;

		if (H == 0 && W == 0) break;

		for (int y = 0; y < H; y++){
			for (int x = 0; x < W; x++){
				if (y == 0 || y == H - 1 || x == 0 || x == W-1) cout << "#";
				else cout << ".";
			}
			cout << "\n";
		}
		cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 1120
K = gets[/ .*/].to_i
s = gets.split.map(&:to_i)
dp = [s[0]] * K
s.push(*([s[-1]] * K)).unshift(*([s[0]] * K)).each_cons(K+1) do |h| 
    hk = h.pop
    dp.push(h.map!.with_index { |x, k| (x - hk).abs + dp[k] }.min).shift
end

p dp.min-s[0]


Measured memory_bytes: 22668
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int D = sc.nextInt();
    int N = sc.nextInt();
    switch (D) {
      case 0:
        if (N != 100) {
          System.out.println(N);
        } else {
          System.out.println(N + 1);
        }       
        break;
      case 1:
        if (N != 100) {
          System.out.println(N * 100);
        } else {
          System.out.println((N + 1) * 100);
        }       
        break;
      case 2:
        if (N != 100) {
          System.out.println(N * 100 * 100);
        } else {
          System.out.println((N + 1) * 100 * 100);
        }       
        break;
    }
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0,k,sum=0,x,y,a,b,c;
    cin >> x >> y >> a >> b >> c ;
    ll aa[a],ba[b],ca[c];
    rep(i,a) 
    {
        cin >> aa[i];
    }
    rep(i,b) 
    {
        cin >> ba[i];
    }
    rep(i,c) 
    {
        cin >> ca[i];
    }
    sort(aa,aa+a);
    sort(ba,ba+b);
    sort(ca,ca+c);
    ll mina=aa[a-x];
    ll minb=ba[b-y];
    for(i=c-1;i>=0;--i)
    {
        f=0;
        if(mina>minb)
        {
            if(ca[i]>minb&&y) 
            {
                y--;
                if(y!=0) minb=ba[b-y];
                f=1;    
            }
            else if(ca[i]>mina&&x)
            {
                x--;
                if(x!=0) mina=aa[a-x];
                f=1;
            }
        }
        else if(mina<minb)
        {
            if(ca[i]>mina&&x)
            {
                x--;
                if(x!=0) mina=aa[a-x];
                f=1;
            }
            else if(ca[i]>minb&&y)
            {
                y--;
                if(y!=0) minb=ba[b-y];
                f=1;  
            }
        }
        else if(ca[i]>mina)
        {
            if(x||y)
            {
                if(x>y)
                {
                    x--;
                if(x!=0) mina=aa[a-x];
                f=1;
                }
                else 
                {
                    y--;
                if(y!=0) minb=ba[b-y];
                f=1; 
                }
            }
        }
        if(f==1) ans+=ca[i];
        else break;
    }
    
    
    if(x>0)
    {
        for(i=0;i<x;++i) ans+=aa[a-i-1];
    }
    for(i=0;i<y;++i) ans+=ba[b-i-1];
    cout << ans ;
    
    return 0;
}


Measured memory_bytes: 2560
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


a = inl()
print(max(a)-min(a))


Measured memory_bytes: 3572
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INF 1<<29
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion


LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 



/*****************************************************************************/

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

	int n;
	cin >> n;
	vi a(n + 2);
	a[0] = 0; a[n + 1] = 0;
	vi sums(n + 1, 0);
	f(i, 1, n + 1) {
		cin >> a[i];
	}
	int s = 0;
	f(i, 0, n+1) {
		s += abs(a[i] - a[i + 1]);
	}
	f(i, 1, n + 1) {
		sums[i] = s + abs(a[i - 1] - a[i + 1]) - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1]));
		cout << sums[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<utility>
#include<climits>
using namespace std;
typedef long long Int;
typedef pair<Int,Int> Pair;

#define N_MAX 100000
#define M_MAX 200000

int N,M,K,S;
int P,Q;
vector<int> load[N_MAX];
int zd[N_MAX];
bool done[N_MAX];
Int cost[N_MAX];

int main(){
	int i;
	int a,b;
	queue<Pair> q;

	cin>>N>>M>>K>>S;
	cin>>P>>Q;

	for(i=0;i<N;i++){
		zd[i]=-1;
		done[i]=false;
		cost[i]=LLONG_MAX;
	}
	for(i=0;i<K;i++){
		cin>>a;
		a--;
		q.push(Pair(a,-1));
	}
	for(i=0;i<M;i++){
		cin>>a>>b;
		a--;b--;
		load[a].push_back(b);
		load[b].push_back(a);
	}

	while(!q.empty()){
		int qTo=q.front().first;
		int qCost=q.front().second;
		q.pop();
		if(zd[qTo]<0){
			zd[qTo]=qCost+1;
			for(i=0;i<load[qTo].size();i++){
				q.push(Pair(load[qTo][i],zd[qTo]));
			}
		}
	}

	cost[0]=0;
	priority_queue< Pair , vector<Pair> , greater<Pair> > pq;	//cost,town
	pq.push(Pair(cost[0],0));

	int doneTown;
	while(!pq.empty()){
		doneTown=pq.top().second;pq.pop();
		if(done[doneTown]) continue;
		done[doneTown]=true;
		for(i=0;i<load[doneTown].size();i++){
			int toTown=load[doneTown][i];
			if(done[toTown] || zd[toTown]==0) continue;
			int yado=P;
			if(zd[toTown]<=S) yado=Q;
			if(toTown==N-1) yado=0;

			if(cost[doneTown]+yado<cost[toTown]){
				cost[toTown]=cost[doneTown]+yado;
				pq.push(Pair(cost[toTown],toTown));
			}
		}
	}

	cout<<cost[N-1]<<endl;

	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vs(H + 2);
  for (int i = 0; i < H + 2; ++i) {
    for (int j = 0; j < W + 2; ++j) {
      vs.at(i) += '.';
    }
  }
  for (int i = 0; i < H; ++i) {
    string S;
    cin >> S;
    for (int j = 0; j < W; ++j) {
      vs.at(i + 1).at(j + 1) = S.at(j);
    }
  }
  for (int i = 1; i < H + 1; ++i) {
    for (int j = 1; j < W + 1; ++j) {
      if (vs.at(i).at(j) != '#') {
        int count = 0;
        if (vs.at(i - 1).at(j - 1) == '#') ++count;
        if (vs.at(i - 1).at(j) == '#') ++count;
        if (vs.at(i - 1).at(j + 1) == '#') ++count;
        if (vs.at(i).at(j - 1) == '#') ++count;
        if (vs.at(i).at(j + 1) == '#') ++count;
        if (vs.at(i + 1).at(j - 1) == '#') ++count;
        if (vs.at(i + 1).at(j) == '#') ++count;
        if (vs.at(i + 1).at(j + 1) == '#') ++count;
        vs.at(i).at(j) = count + '0';
      }
      cout << vs.at(i).at(j);
    }
    cout << endl;
  }
}


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

using namespace std;

int main(void) {
	int n,q,temp;
	cin >> n;
	map<int,int> memo;
	for (int i = 0; i < n; ++i) {
		cin >> temp;
		++memo[temp];
	}
	cin >> q;
	int res = 0;
	for (int i = 0; i < q; ++i) {
		cin >> temp;
		if (memo[temp] > 0) {
			++res;
		}
	}
	cout << res << endl;
	return 0;
}



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

int main() {
    // a=青いボールの個数, b=赤いボールの個数
    ll n, a, b;
    cin >> n >> a >> b;
    if (a <= 0) {
        cout << 0 << endl;
        return 0;
    }
    
    ll c = n / (a + b);
    ll ans = a * c;
    ll nm  = n % (a + b);
    if (nm <= a) {
        ans += nm;
    } else {
        ans += a;
    }
    cout << ans << endl;
    return 0;
}


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

#include <vector>
#define rep(i, n) for (long long(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  long long n;
  cin >> n;
  long tmp9, tmp8, all;
  tmp9 = tmp8 = all = 1;
  long BIG = 1000000007;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (long long i = 0; i < n; i++) {
    tmp9 = tmp9 * 9 % BIG;
    tmp8 = tmp8 * 8 % BIG;
    all = all * 10 % BIG;
  }
  all--;
  if (all < 0) {
    all += BIG;
  }
  // cout << tmp9 << " " << tmp8 << endl;
  long tmp = (2 * tmp9) % BIG - tmp8;
  if (tmp < 0) {
    tmp += BIG;
  }
  // cout << all << " " << tmp << endl;
  long result = all - (tmp);
  if (result < 0) {
    result += BIG;
  }
  cout << result + 1 << endl;
}

Measured memory_bytes: 3568
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	s := stdin.Read()
	if s[0] == s[1] && s[0] == s[2] {
		stdout.Println("No")
	} else {
		stdout.Println("Yes")
	}
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bisection(l,r,f,left=True,discrete=True):
    eps=1 if discrete else 10**-12
    if((not left)^f(r)): return r if left else r+1
    elif(left^f(l)): return l-1 if left else l
    while(r-l>eps):
        h=(l+r)//2 if discrete else (l+r)/2
        if((not left)^f(h)): l=h
        else: r=h
    return (l+r)/2 if not discrete else l if left else r

def resolve():
    from math import tan,pi
    a,b,x=map(int,input().split())
    def check(t):
        if(2*x<=a*a*b):
            return 2*x*tan(t)<=a*b*b
        else:
            return 2*x<=a*a*(2*b-a*tan(t))
    print(bisection(0,pi/2-10**-6,check,left=True,discrete=False)*180/pi)
resolve()

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

int main(){
    int n,w,h;
    cin >> n >> w >> h;
    vector<int> hrz(w+2,0), vrt(h+2,0);
    for(int i=0; i<n; i++){
        int x,y,p;
        cin >> x >> y >> p;
        hrz[max(x-p+1, 0)]+=1; hrz[min(x+p+1, w+1)]-=1;
        vrt[max(y-p+1, 0)]+=1; vrt[min(y+p+1, h+1)]-=1;
    }

    bool hyes=true, vyes=true;
    for(int i=1; i<=w; i++){
        hrz[i]+=hrz[i-1];
        if(hrz[i]==0){
            hyes=false;
            break;
        }
    }
    for(int i=1; i<=h; i++){
        vrt[i]+=vrt[i-1];
        if(vrt[i]==0){
            vyes=false;
            break;
        }
    }
    
    if(hyes || vyes){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }    
    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

const int nmax = 10;
int n, m;
bool visited[nmax];
vi graph[nmax];

int dfs(int d, int node) {
  if (d == n) return 1;
  int ret = 0;
  for (auto &nextNode : graph[node]) if (!visited[nextNode]) {
    visited[nextNode] = true;
    ret += dfs(d+1, nextNode);
    visited[nextNode] = false;
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  std::cin >> n >> m;
  rep(i, m) {
    int a, b; std::cin >> a >> b;
    --a, --b;
    graph[a].pb(b), graph[b].pb(a);
  }
  visited[0] = true;
  std::cout << dfs(1, 0) << "\n";
}


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

int main()
{
        int x,y;
        cin >> x>> y;

        if(x>y)
            swap(x,y);
        int d = y-x+1;
        if(d>=2019){
            cout << "0" << endl;
            return 0;
        }

        int mn = 1000000010;
        for(int i=x;i<=y;i++){
            for(int j=i+1;j<=y;j++){
                int t = ((i%2019)*(j%2019))%2019;
                mn = min(mn,t);
            }
        }
        cout << mn << endl;




return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

string s;
// index が条件を満たすかどうか
bool isOK(int index, int ma) {
    if((int)s.length() - index - (index + 1) * ma <= 0) {
        // cout << index << " " << ma << endl;
        return true;
    } else {
        // cout << index << " " << ma << endl;
        return false;
    }
}

// 汎用的な二分探索のテンプレ
ll binary_search(int ma) {
    ll ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll ok =
        (int)s
            .length(); // 「index =
                       // a.size()-1」が条件を満たさないこともあるので、初期値は
                       // a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while(abs(ok - ng) > 1LL) {
        ll mid = (ok + ng) / 2LL;

        if(isOK(mid, ma))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

int main() {
    ll a;
    ll b;
    cin >> a >> b;
    if(a <= 0 and 0 <= b) {
        cout << "Zero" << endl;
        return 0;
    }
    if(0 <= a and 0 <= b) {
        cout << "Positive" << endl;
        return 0;
    }
    if(a <= 0 and b <= 0) {
        if((b % 2LL - a % 2LL) == 0) {
            cout << "Negative" << endl;
            return 0;
        }
        cout << "Positive" << endl;
        return 0;
    }
    if(a % 2 == 1) {
        cout << "Negative" << endl;
        return 0;
    }
    cout << "Positive" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
int main()
{
    cin>>n;
    if(n==1) cout<<1;
    else if(n>=2&&n<4) cout<<2;
    else if(n<8) cout<<4;
    else if(n<16) cout<<8;
    else if(n<32) cout<<16;
    else if(n<64) cout<<32;
    else cout<<64;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
a = map(int, input().split())
alist = list(a)

b = map(int, input().split())
blist = list(b)

c = map(int, input().split())
clist = list(c)
sum = 0
zenkai = 0
for ryouri in alist:
    sum += blist[ryouri-1]
    if zenkai == 0:
        zenkai = ryouri
    else:
        if zenkai+1 == ryouri:
            sum += clist[zenkai-1]
        zenkai = ryouri

print("{}".format(sum))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,a[2001];
ll tot;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(res i=1;i<=n;++i) cin>>a[i];
	sort(a+1,a+1+n);
	for(res i=1;i<n;++i)
	  for(res j=i+1;j<=n;++j) {
	  	int now=lower_bound(a+1,a+1+n,a[i]+a[j])-a;
	  	tot+=now-1-j;
	  }
	cout<<tot<<'\n';
	cout<<flush;
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

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

template<typename T, typename K> struct P{
    T a;
    K b;
};

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	string s;
	cin >> s;
	int N= s.size();
	rep(i,0,N){
		cout << "x";
	}
	cout << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
<?php

while($line = fgets(STDIN)){
	$line = trim($line);
	
	$arr = array();
	for($i = 1; $i <= 9; $i++){
		$arr[$i] = substr($line, $i-1, 1);
	}
	$win = "d";

	if($arr[1] != "s"){
		if($arr[1] == $arr[2] && $arr[1] == $arr[3]){
			$win = $arr[1];
		}
		if($arr[1] == $arr[4] && $arr[1] == $arr[7]){
			$win = $arr[1];
		}
		if($arr[1] == $arr[5] && $arr[1] == $arr[9]){
			$win = $arr[1];
		}
	}

	if($arr[2] != "s" && $arr[2] == $arr[5] && $arr[2] == $arr[8]){
		$win = $arr[2];
	}

	if($arr[3] != "s"){
		if($arr[3] == $arr[6] && $arr[3] == $arr[9]){
			$win = $arr[3];
		}
		if($arr[3] == $arr[5] && $arr[3] == $arr[7]){
			$win = $arr[3];
		}
	}

	if($arr[4] != "s" && $arr[4] == $arr[5] && $arr[4] == $arr[6]){
		$win = $arr[4];
	}
	if($arr[7] != "s" && $arr[7] == $arr[8] && $arr[7] == $arr[9]){
		$win = $arr[7];
	}


	echo $win."\n";
}

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

using namespace std;

int digit(int n) {
    while (n >= 10) {
        n /= 10;
    }
    return n;
}

int main(int argc, char const *argv[]) {
    int n = 0;
    cin >> n;
    vector<vector<long> > out(10, vector<long>(10, 0));
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        out[i % 10][digit(i)] += 1;
    }
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            ans += out[i][j] * out[j][i];
        }
    }
  cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
V<int> graph[200005];
V<int> dist;
int max_dist;
void dfs(int now,int par){
    for(int v:graph[now]){
        if(v==par)continue;
        dfs(v,now);
    }
    int ma1=0,ma2=-1;
    for(int v:graph[now]){
        if(v==par)continue;
        if(ma1<=dist[v]){
            chmax(ma2,ma1);
            ma1=dist[v];
        }
        else if(ma2<=dist[v])ma2=dist[v];
    }
    if(ma2!=-1)chmax(max_dist,ma1+ma2);
    else chmax(max_dist,ma1);
    dist[now]=ma1+1;
    return;
}
int main(){
    int n;
    cin>>n;
    max_dist=0;
    dist.assign(n,0);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    if(n==1){
        cout<<"First"<<"\n";
        return 0;
    }
    dfs(0,-1);
    max_dist--;
    if(max_dist%3==0)cout<<"Second"<<"\n";
    else cout<<"First"<<"\n";
}

Measured memory_bytes: 27008
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		int tri=0,sharp=0, inc=0, right=0;  
		while(true) {
			a[0] = sc.nextInt();
			a[1] = sc.nextInt();
			a[2] = sc.nextInt();
			Arrays.sort(a);
			if(a[2] >= a[0] + a[1]) break;
			else {
				int b = a[0] * a[0];
				int c = a[1] * a[1];
				int d = a[2] * a[2];
				
				if(d == c + b) right++;
				if(d > c + b) inc++;
				if(d < c + b) sharp++;
			}
		}
		tri = right + sharp + inc;
		System.out.println(tri+" "+right+" "+sharp+" "+inc);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void permutation(String q, String ans) { //Call permutation(String, "",) from outside
		if (q.length() <= 1)
			System.out.println(ans + q); //Fill in processing
		else
			for (int i = 0; i < q.length(); i++)
				permutation(q.substring(0, i) + q.substring(i + 1), ans + q.charAt(i));
	}

	public static void combination(String q, String ans, int k) { //Call combination(String, "", n) from outside (nCr)
		if (ans.length() == k)
			System.out.println(ans); //Fill in processing
		else
			while (q.length() > 0) {
				combination(q.substring(1), ans + q.charAt(0), k);
				q = q.substring(1);
			}
	}

	long combination(int n, int r, int m) { //nCr mod m
		long[][] Combination = new long[n + 1][n + 1];
		for (int i = 0; i <= n; i++) {
			Combination[i][0] = 1;
			for (int j = 1; j <= i; j++)
				Combination[i][j] = (Combination[i - 1][j - 1] + Combination[i - 1][j]) % m;
		}
		return Combination[n][r];
	}

	int gcd(int a, int b) {
		if (a < b) {
			int c = a;
			a = b;
			b = c;
		}
		if (b == 0)
			return a;
		else
			return gcd(b, a % b);
	}

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


Measured memory_bytes: 26300
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define ll long long int
#define ld long double
#define vec vector
#define forn(a) for(ll a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl
 
using namespace std;

void dfs(ll node, vec<vec<ll>>& g, vec<bool> &visited, vec<ll> &points, ll peso){
    if(visited[node]) return;
    visited[node] = true;

    points[node] += peso;
    for(auto it: g[node]) dfs(it, g, visited, points, points[node]);
}
 
int main() {
    IOS;

    ll n, q; cin>>n>>q;
    vec< vec<ll> > g(n);

    for(ll i=0; i<n-1; i++){
        ll a, b; cin>>a>>b; a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vec<ll> points(n, 0);
    for(ll i=0; i<q; i++){
        ll a, x; cin>>a>>x; a--;
        points[a] += x;
    }

    vec<bool> visited(n, false);
    dfs(0, g, visited, points, 0);

    for(auto it: points) cout<<it<<" "; cout<<endl;

    return 0;
}

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

int main(void){
    string S;
    cin >> S;
    
    reverse(S.begin(),S.end());
    for(int i = 0 ; i < S.size() ; ){
        if(S.substr(i,7) == "remaerd"){
            i+=7;
        }
        else if(S.substr(i,6) == "resare"){
            i+=6;
        }
        else if(S.substr(i,5) == "maerd"){
            i+=5;
        }
        else if(S.substr(i,5) == "esare"){
            i+=5;
        }
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 3736
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

double dp[301][301][301];
double solve(int x, int y, int z, int& n)
{
    if(x < 0 || y < 0 || z < 0)
        return 0;
    if(x == 0 && y == 0 && z == 0)
        return 0;
    if(dp[x][y][z] > -0.9)
        return dp[x][y][z];
    double exp = n + x*solve(x-1,y,z,n) + y*solve(x+1,y-1,z,n) + z*solve(x,y+1,z-1,n);
    return dp[x][y][z] = exp/(x+y+z);
}

int main() {
   int n, x;
   cin >> n;
   memset(dp, -1, sizeof dp);
   int one = 0, two = 0, three = 0;
   for(int i=1; i <= n; i++)
   {
       cin >> x;
       if(x == 1)
            one++;
       else if(x == 2)
            two++;
       else three++;
   }
   prDouble(solve(one, two, three, n));
}


Measured memory_bytes: 213376
#include <stdio.h>

int main(){
  int A=0,B=0,C=0;
  scanf("%d %d %d",&A,&B,&C);
  if((A==7)&&(B==5)&&(C==5)){
    printf("YES\n");
  }else if((A==5)&&(B==7)&&(C==5)){
    printf("YES\n");
  }else if((A==5)&&(B==5)&&(C==7)){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

const int N = 100010;

struct poi{int x, y, t;} a[N];
bool operator < (poi a, poi b) {return a.t < b.t;}
int n;

int main()
{
    scanf("%d", &n);
    FOR(i, 1, n) scanf("%d%d%d", &a[i].t, &a[i].x, &a[i].y);
    sort(a, a + n + 1);
    FOR(i, 1, n)
    {
        int tm = abs(a[i].x - a[i - 1].x) + abs(a[i].y - a[i - 1].y);
        if (tm > a[i].t - a[i - 1].t || (((a[i].t - a[i - 1].t) ^ tm) & 1))
            {puts("No"); return 0;}
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<deque>
using namespace std;
int H,W,Ch,Cw,Dh,Dw;
int main(){
    cin>>H>>W>>Ch>>Cw>>Dh>>Dw;
    Ch--,Cw--;Dh--,Dw--;
    char S[H][W];
    for(int i=0;i<H*W;i++)cin>>S[i/W][i%W];
    int d[H][W];
    for(int i=0;i<H*W;i++)d[i/W][i%W]=1000000000;
    // bool visited[H][W];
    // for(int i=0;i<H*W;i++)visited[i/W][i%W]=false;

    deque<pair<int,int>>q;
    q.push_front(make_pair(Ch,Cw));
    d[Ch][Cw]=0;
    // visited[Ch][Cw]=true;
    while(!q.empty()){
        auto position=q.front();q.pop_front();
        int x=position.first,y=position.second;
        int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
        for(int i=0;i<4;i++){
            if(x+dx[i]<0||H<=x+dx[i]||y+dy[i]<0||W<=y+dy[i])continue;
            if(S[x+dx[i]][y+dy[i]]=='#')continue;
            if(d[x+dx[i]][y+dy[i]]>d[x][y]){
                d[x+dx[i]][y+dy[i]]=d[x][y];
                q.push_front(make_pair(x+dx[i],y+dy[i]));
            }
        }

        for(int i=0;i<5*5;i++){
            int _dx=i/5-2,_dy=i%5-2;
            if(x+_dx<0||H<=x+_dx||y+_dy<0||W<=y+_dy)continue;
            if(S[x+_dx][y+_dy]=='#')continue;
            if(d[x+_dx][y+_dy]>d[x][y]+1){
                d[x+_dx][y+_dy]=d[x][y]+1;
                q.push_back(make_pair(x+_dx,y+_dy));
                //cout<<x+_dx<<" "<<y+_dy<<endl;
            }
        }
        //for(int i=0;i<H*W;i++)cout<<d[i/W][i%W]<<" \n"[i%W==W-1];
    }
    cout<<(d[Dh][Dw]==1000000000?-1:d[Dh][Dw])<<endl;
    return 0;
}

Measured memory_bytes: 8544
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

int main(){
  int x;
  cin >> x;

  if(1800 <= x) cout << 1 << endl;
  else if(1600 <= x) cout << 2 << endl;
  else if(1400 <= x) cout << 3 << endl;
  else if(1200 <= x) cout << 4 << endl;
  else if(1000 <= x) cout << 5 << endl;
  else if(800 <= x) cout << 6 << endl;
  else if(600 <= x) cout << 7 << endl;
  else if(400 <= x) cout << 8 << endl;

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setpercision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
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;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll n;
vl value;
void add(ll i,ll x){
    i+=n-2;
    value[i]+=x;
    while(i){
        i=(i-1)/2;
        value[i]+=x;
    }
}
ll getSum(ll a,ll b,ll k,ll l,ll r){
    if(r<=a or b<=l)return 0;
    if(a<=l and r<=b)return value[k];
    else{
        ll c1=getSum(a,b,k*2+1,l,(l+r)/2);
        ll c2=getSum(a,b,k*2+2,(l+r)/2,r);
        return c1+c2;
    }
}
int main(){
    ll N,Q;cin>>N>>Q;
    n=1;
    while(N>n)n*=2;
    value=vl(n*2-1);
    while(Q--){
        ll com,x,y;cin>>com>>x>>y;
        if(com)cout<<getSum(x-1,y,0,0,n)<<endl;
        else add(x,y);
    }
    return 0;
}


Measured memory_bytes: 4884
A = input()
n = len(A)
A += "S"
sc, tc, c = 0, 0, 0
for i in range(n):
  if A[i] == "S":
    sc += 1
  else:
    tc += 1
    if A[i+1] == "S":
      if sc <= tc:
        c += sc
        sc = 0
        tc = 0
      else:
        c += tc
        sc -= tc
        tc = 0
print(n-2*c)

Measured memory_bytes: 3500
#include <iostream>
using namespace std;
const static int n = 30;

int main() {
    bool students[n]; for (int j = 0; j < n; j++) students[j] = false;
    for (int i = 0; i < n - 2; i++) {
        int tmp; cin >> tmp;
        students[tmp - 1] = true;
    }

    for (int j = 0; j < n; j++)
        if (students[j] == false) cout << j + 1 << endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll mod_div(ll a,ll b){
  ll tmp=MOD-2,c=b,ret=1;
  while(tmp>0){
    if(tmp&1){
      ret*=c;ret%=MOD;
    }
    c*=c;c%=MOD;tmp>>=1;
  }
  return a*ret%MOD;
}
 
#define MAX_K 2000100
vector<ll> kaijo(MAX_K);
ll combination(ll n, ll r){
  if(n<r||n<0||r<0)
    return 0;
  if(kaijo[0]!=1){
    kaijo[0]=1;
    for(ll i=1;i<MAX_K;i++)kaijo[i]=(kaijo[i-1]*i)%MOD;
  }
  ll ret=kaijo[n];
  long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
  return mod_div(ret,tmp);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  ll ans = 0;
  ll mi=0,ma=0;
  for(ll i = 0;i<k;i++){
    ma+=n-i;
    mi+=i;
  }
  ma%=MOD;mi%=MOD;
  for(ll i = k;i<=n+1;i++){
    ans += (ma-mi+MOD)%MOD+1;
    ans %=MOD;
    ma+=n-i;
    mi+=i;ma%=MOD;
    mi%=MOD;
    //   cout<<ans<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 18652
import java.io.*;

public class Main {
	public static void main(String [] args) throws IOException{
		boolean [] a=new boolean [1000000];
		int [] prime=new int [1000000];
		int cnt=0;
		for (int i=0;i<1000000;i++){
			a[i]=true;
		}
		a[0]=false;
		a[1]=false;
		prime[0]=0;
		prime[1]=0;
		for (int i=2;i<1000000;i++){
			if (a[i]==true){
				cnt++;
				int j=2*i;
				while (j<1000000){
					a[j]=false;
					j+=i;
				}
			}
			prime[i]=cnt;
		}
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str;
		while ((str=br.readLine())!=null){
			System.out.println(prime[Integer.parseInt(str)]);
		}
	}
}

Measured memory_bytes: 29756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll MOD = 1000000007;

int n, p[MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;
    REP1 (i, n) {
        cin >> p[i];
    }

    int ans = 0;
    REP1 (i, n) {
        if (p[i] == i) {
            ans++;
            if (i == n) {
                swap(p[i], p[i-1]);
            } else {
                swap(p[i], p[i+1]);
            }
        }
    }

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


Measured memory_bytes: 768
import std.stdio,std.array,std.conv,std.string,std.algorithm;

void main(){
    string[] a = split(readln());
    int n =  to!int(a[0]);

    string[] s = new string[n];
    for(int i=0;i<n;i++){
        s[i] = chomp(readln());
    }

    sort!("a < b")(s);
    for(int i=0;i<n;i++){
        write(s[i]);
    }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), d(n+5);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    const int MOD= 1e9+7;
    long long ans = 1;
    d[0] = 3;
    for(int i = 0; i < n; i++){
        ans = (ans * d[a[i]])%MOD;
        d[a[i]]--;
        d[a[i]+1]++;
    }
    cout << ans;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	cin>>n;
    	ll x=n/500;
    	ll ans=x*1000;
    	ll y=n%500;
    	ans+=(y/5)*5;
    	cout<<ans;
    }
    return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;
const ll INF=1LL<<60;

int main(){
    
    int H,W;cin>>H>>W;
    ll dp[H+2][W+2];
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin>>S[i];
    }
    for(int i=0;i<H+2;i++){
        for(int j=0;j<W+2;j++){
            if(i==0&&j==1) dp[i][j]=1;
            else dp[i][j]=0;
        }
    }
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(S[i-1][j-1]=='.'){
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    cout<<dp[H][W]<<endl;
}


Measured memory_bytes: 9088
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
temp = []
for i in range(n):
    temp.append(t - h[i] * 0.006)
for i in range(n):
    h[i] = abs(a - temp[i])
ans = 0
turn = h[0]
for i in range(n):
    if h[i] < turn:
        ans = i
        turn = h[i]
print(ans + 1)

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

int main(){
    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);
    int n, m;   cin >> n >> m;
    int ans=0;
    if(n>=2){
        ans+=n*(n-1);
        ans/=2;
    }
    ans+=m*(m-1)/2;
    cout << ans;



}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] h = new int[n];
    Set<Integer> goodH = new HashSet<>();
    Set<Integer> badH = new HashSet<>();
    Set<Integer> hasBridge = new HashSet<>();

    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }
    for (int j = 0; j < m; j++) {
      int a = sc.nextInt();
      int b = sc.nextInt();

      if (h[a-1] > h[b-1]) {
        goodH.add(a);
        badH.add(b);
      } else if (h[a-1] < h[b-1]) {
        goodH.add(b);
        badH.add(a);
      } else {
        badH.add(a);
        badH.add(b);
      }

      hasBridge.add(a);
      hasBridge.add(b);
    }

    int noBridgeCount = 0;
    for (int i = 1; i <= n; i++) {
      if (!hasBridge.contains(i)) {
        noBridgeCount++;
      }
    }
    int goodHCount = 0;
    for (int i = 1; i <= n; i++) {
      if (goodH.contains(i) && !badH.contains(i)) {
        goodHCount++;
      }
    }

    int result = goodHCount + noBridgeCount;

    System.out.println(result);
  }
}


Measured memory_bytes: 81152