akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
 
using namespace std;
 
#ifdef DEBUG
#define dprintf      printf
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(1){}else
#define drep(i,n)    if(1){}else
#define dstop()      if(1){}else
#endif
 
#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair
 
#define loop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__);
#define array(T,id,n) T id[n]; rep(i,n)cin>>id[i];
 
//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif
 
typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;
 
void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}
 
signed main(void)
{
  char s[112345]={};
  scanf("%s",s);
  in(int,k);
  int len=strlen(s);
  rep(i,len)
    {
      if('z'-s[i]+1<=k)
	{
	  if(s[i]=='a')continue;
	  dout(k);
	  k-='z'-s[i]+1;
	  s[i]='a';
	}
      dprintf("%d文字目:残り%d回\n",i+1,k);
    }
  k%=26;
  rep(i,k)
    {
      s[len-1]++;
      if(s[len-1]>'z')
	s[len-1]='a';
    }
  puts(s);
  return 0;
}


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

const int MAXN = 5005;
const int MAXM = 205;
const int MX = 8192;

struct SEG {
	int d[MX*2];

	void upd(int x, int r) {
		for(x += MX; x; x >>= 1)
			if(d[x] < r) d[x] = r;
	}
	int get(int s, int e) {
		int r = 0; for(s += MX, e += MX; s <= e; s >>= 1, e >>= 1) {
			if(s&1) { if(r < d[s]) r = d[s]; s++; }
			if(~e&1) { if(r < d[e]) r = d[e]; e--; }
		}
		return r;
	}
} seg[MAXM];

int A[MAXN][MAXM];
ll B[MAXN];

ll Ans;
int N, M;

int mx[MAXM];
void f(int s, int e, int p, int q) {
	if(s > e || p > q) return;
	int m = (s+e) >> 1;
	ll sum = 0, hc = -1; int hi = -1;
	for(int j = 1; j <= M; j++)
		sum += (mx[j] = seg[j].get(m, p-1));
	for(int i = p; i <= q; i++) if(m <= i) {
		for(int j = 1; j <= M; j++) {
			if(A[i][j] <= mx[j]) continue;
			sum += -mx[j] + A[i][j];
			mx[j] = A[i][j];
		}
		ll ret = sum - B[i] + B[m];
		if(ret <= hc) continue;
		hc = ret; hi = i;
	}
	if(Ans < hc) Ans = hc;
	f(s, m-1, p, hi);
	f(m+1, e, hi, q);
}

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> M;
	for(int i = 2; i <= N; i++) {
		cin >> B[i];
		B[i] += B[i-1];
	}
	for(int i = 1; i <= N; i++) {
		for(int j = 1; j <= M; j++) {
			cin >> A[i][j];
			seg[j].upd(i, A[i][j]);
		}
	}

	f(1, N, 1, N);
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 17024
#include<iostream>
#include<vector>
#include<string>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
  	string s;
  cin>>s;
  int l = s.length();
  while(l--)
  {
    cout<<'x';
  }
}

Measured memory_bytes: 256
long long n[100][21];a[100],i,j;main(N){
for(scanf("%d",&N);i<N;i++)scanf("%d",a+i);
for(n[0][a[0]]=i=1;i<N-1;i++)for(j=0;j<=20;j++)0<=j-a[i]&&(n[i][j-a[i]]+=n[i-1][j]),j+a[i]<=20&&(n[i][j+a[i]]+=n[i-1][j]);
printf("%lld\n",n[N-2][a[N-1]]);exit(0);}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D, G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  for (int i = 0; i < D; i++){
    cin >> p[i] >> c[i];
  }
  int sum = 0;
  for (int i = 0; i < D; i++){
    sum += p[i];
  }
  int ans = sum;
  for (int i = 0; i < (1 << D); i++){
    int s = 0;
    int cnt = 0;
    for (int j = 0; j < D; j++){
      if (i >> j & 1){
        s += p[j] * (j + 1) * 100 + c[j];
        cnt += p[j];
      }
    }
    if (s >= G){
      ans = min(ans, cnt);
    } else {
      int mx = 0;
      for (int j = 0; j < D; j++){
        if (!(i >> j & 1)){
          mx = j;
        }
      }
      int cnt2 = (G - s + (mx + 1) * 100 - 1) / ((mx + 1) * 100);
      if (cnt2 <= p[mx]){
        ans = min(ans, cnt + cnt2);
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0; i<n; i++)
    cin >> h.at(i);
  
  sort(h.begin(), h.end());
  
  int ans = h.at(k-1) - h.at(0);
  
  for(int i=0; i<n-k+1; i++) {
    int temp = h.at(i+k-1) - h.at(i);
    if(temp < ans) {
      ans = temp;
    }
  }
  
  cout << ans << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  string s;

  for(int i=0; i < a; i++) {
    for(int j=0; j < b; j++) {
      cin >> s;
      if (s == "snuke") cout << (char)(j+65) << i + 1 << endl;
    }
  }
}

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

int main(){
    int n, k;
    std::cin >> n >> k;
    std::vector<int> sunuke(n);
    for (int i = 0; i < k; i++)
    {
        int d;
        std::cin >> d;
        for (int j = 0; j < d; j++)
        {
            int a;
            std::cin >> a;
            sunuke[a - 1] = 1;
        }
    }
   
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (sunuke[i] == 0)
        {
            count++;
        }
    }
    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define inf 1000000009
using namespace std;
int read();
int n;
struct P {
    int x, y;
    void init() { x = read(), y = read(), x > y ? swap(x, y) : void(); }
} p[200005];

bool cmp(P a, P b) { return a.x < b.x; }

int main() {
    n = read();
    int mxx = 0, mxy = 0, mnx = inf, mny = inf;
    long long res;
    for (int i = 1; i <= n; ++i) {
        p[i].init();
        mxx = max(mxx, p[i].x), mnx = min(mnx, p[i].x);
        mxy = max(mxy, p[i].y), mny = min(mny, p[i].y);
    }
    res = 1ll * (mxx - mnx) * (mxy - mny);
    long long tmp = mxy - mnx;
    sort(p + 1, p + 1 + n, cmp), mny = inf, mxy = 0;
    res = min(res, tmp * (p[n].x - p[1].x));
    for (int i = 1; i <= n; ++i) {
        mxy = max(mxy, p[i].y), mny = min(mny, p[i].y);
        res = min(res, tmp * (max(mxy, p[n].x) -
                              min(mny, i == n ? inf : p[i + 1].x)));
    }
    printf("%lld\n", res);
    return 0;
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(void)
{
int N;
string str;
char A ='A';
char Z ='Z';
string Out;
cin>>N>>str;


for(int i=0;i<N;i++)
{
	for(int b=0;b<str.size();b++)
	{
	if(str[b]==Z) str[b]=A;
	
 	else str.at(b) +=1;

	}


}
  cout<<str;
} 
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N=1010;
const ll P=1000000007;
int a[MAX_N];
int main(){
	int N;
	cin>>N;
	for(int i=2;i<=N;i++){
		int x=i;
		for(int d=2;d<=x;d++){
			while(x%d==0){
				a[d]+=1;
				x/=d;
			}
		}
		if(x!=1) a[x]+=1;
	}
	ll ans=1;
	for(int p=2;p<=N;p++){
		if(a[p]!=0) ans=(ans*(a[p]+1))%P;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  private[this] val S = "0" + in.next()


  //
  // a は bに含まれているか
  def contain(a: String, b: String): Boolean = {
    val B = 5570293
    val h = 1e9.toLong

    val al = a.length; val bl = b.length
    if (al > bl)
      return false

    // B の al 乗を計算
    var t = 1L
    for (_ <- 1 to al) {
      t *= B
      t %= h
    }

    // aとbの最初のal文字に関するハッシュ値を計算
    var ah = 0L; var bh = 0L
    for (i <- 0 until al)
      ah = (ah * B + a(i).toLong) % h
    for (i <- 0 until al)
      bh = (bh * B + b(i).toLong) % h

    // bの場所を1つずつ進めながらハッシュ値をチェック
    for (i <- 0 to bl-al) {
      if (ah == bh && a == b.substring(i, i+al))
        return true
      if (i + al < bl) {
        bh *= B
        bh %= h
        bh += b(i+al).toLong - b(i).toLong * t
        if(bh < 0)
          bh += h * 1000
        bh %= h
      }
    }

    false
  }


  private[this] def check(end: Int, begin: Int): Boolean = {
    val a = S.substring(begin, end+1)
    val b = S.substring(end+1, N+1)

    contain(a, b)
  }

  // 条件を満たす最大の値を返す
  private[this] def binarySearch(min: Int, max: Int, begin: Int): Int = {
    val mid: Int = (max + min) / 2
      (max - min) match{
      case 0 | 1 =>
        check(max, begin) match{
          case true  => max
          case false => min
        }
      case _ =>
        (check(mid, begin)) match{
          case true  => binarySearch(mid, max, begin)
          case false => binarySearch(min, mid, begin)
        }
    }
  }



  private[this] var ans = 0
  for (i <- 1 to N-1) {
    if (check(i, i)) {
      val tmp = binarySearch(i, i + (N-i) / 2, i) - (i-1)
      ans = Math.max(ans, tmp)
    }
  }
  println(ans)
}


class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 117636
package main

import (
	"fmt"
)

func main() {
	var (
		N, X int
	)
	fmt.Scan(&N, &X)
	mi := 100001
	for i := 0; i < N; i++ {
		var m int
		fmt.Scan(&m)
		if m < mi {
			mi = m
		}
		X -= m
	}
	fmt.Println(N + int(X/mi))
}


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

int main(){
  int N; cin >> N;
  if(N%2!=0) cout << "No" << endl;
  else{
    string S; cin >> S;
    for(int i=0; i<N/2; i++){
      if(S[i]!=S[i+N/2]){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
int main()
{
	int a; cin >> a;
	lli arr[a + 50], dp[a + 50][a + 50];
	memset(dp, 0, sizeof(dp));
	for(int i=1; i<=a; i++)
	{
		cin >> arr[i];
		dp[i][i] = arr[i];
	}
	for(int i=2; i<=a; i++)
	{
		for(int j=1; j + i - 1 <= a; j++)
		{
			int l = j, r = j + i - 1;
			dp[l][r] = max(arr[l] - dp[l + 1][r], arr[r] - dp[l][r - 1]);
		}
	}
	cout << dp[1][a] << '\n';
	return 0;
}

Measured memory_bytes: 72960
def main():
    N=int(input())
    X=input().split()
    if "0" in X:
        print(0)
        return
    ans=1
    for i in X:
        ans = int(i) * ans
        if 1000000000000000000<ans:
            print(-1)
            return
    print(ans)
main()

Measured memory_bytes: 19352
N, C = map(int, input().split())
XV = [[int(x) for x in input().split()] for _ in range(N)]

XV.sort()

def g():
    t_n = [(0, 0)] * (N + 1)
    ans = 0
    score = 0
    pos = 0
    for i, (x, v) in enumerate(XV, 1):
        score += v - (x - pos)
        pos = x
        ans = max(ans, score)
        t_n[i] = (pos, ans)
    
    t_r = [(0, 0)] * (N + 1)
    ans = 0
    score = 0
    pos = C
    for i, (x, v) in enumerate(reversed(XV), 1):
        score += v - (pos - x)
        pos = x
        ans = max(ans, score)
        t_r[i] = (pos, ans)
    
    ans = 0
    for i in range(1, N+1):
        ans = max(
                ans,
                t_n[i][1],
                t_r[i][1],
                t_n[i][1] -      t_n[i][0]  + t_r[N - i][1],
                t_r[i][1] - (C - t_r[i][0]) + t_n[N - i][1],
                )

    return ans

print(g())


Measured memory_bytes: 43116
#include <bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define ucin() ios :: sync_with_stdio(0)
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef long double ld;
typedef long long ll;
typedef double db;

const int N = 1e5 + 10;

int main() {
	ucin();
	ll n; cin >> n; ll ans = n - 1;
	for(ll x = 1; x * x <= n; x ++) {
		if(n % x == 0) {
			ans = min(ans, x - 1 + (n / x) - 1);
		}
	}	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

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

    int n, m, x, a, sum_l = 0, sum_r = 0;

    cin >> n >> m >> x;
    for (int i = 0; i < m; ++i) {
        cin >> a;
        if (a < x) ++sum_l;
        else ++sum_r;
    }

    cout << min(sum_l, sum_r) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	if(y<2019){
		cout<<"Heisei";
		return 0;
	}
	else if(y==2019){
		if(m<=4){
			cout<<"Heisei";
			return 0;
		}
	}
	cout<<"TBD";
} 

Measured memory_bytes: 256
// Practice 40 hours a day to become Ling Ling
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long LL;
typedef pair<LL, LL> II;

#define y0 Sword_Art_Online
#define y1 Your_lie_in_April
#define yn Darling_in_the_Franxx
#define tm Plastic_Memories
#define lr Charlotte
#define norm Weathering_with_you
#define left Violet_Evergarden
#define have Date_a_live
#define ends Your_name
#define prev Five_centimeters_per_second
#define hash Silent_voice
#define endl "\n"

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

LL Rand(LL l, LL h){
    return uniform_int_distribution<LL>(l, h)(rng);
}

template <typename T> void read(T &t){
    t = 0; char ch = getchar(); int f = 1;
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    do { (t *= 10) += ch - '0'; ch = getchar(); } while (isdigit(ch)); t *= f;
}

const LL MaxN = 1 + 2e5, INF = 2e9;

LL nStore, totalTime, dp[MaxN], ans;
vector<II> stores;
vector<LL> remain;

inline bool cmp(II x, II y){
    return y.first * (x.second + 1) < x.first * (y.second + 1);
}

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> nStore >> totalTime;
    for(int iStore = 1 ; iStore <= nStore ; ++iStore){
        LL x, y;
        cin >> x >> y;
        if(x == 0) remain.push_back(y);
        else stores.push_back({x, y});
    }
    sort(stores.begin(), stores.end(), cmp);
    sort(remain.begin(), remain.end());
    fill(dp, dp + 101, INF);
    dp[0] = 0;
    for(int iStore = 0 ; iStore < stores.size() ; ++iStore){
        for(int iVisited = min(50, iStore + 1) ; iVisited > 0 ; --iVisited){
            if(dp[iVisited - 1] > totalTime || dp[iVisited - 1] == INF) continue;
            dp[iVisited] = min(dp[iVisited], dp[iVisited - 1] + 1 + (dp[iVisited - 1] + 1) * stores[iStore].first + stores[iStore].second);
        }
    }
    // cout << dp[5] << endl;
    for(int iVisited = 0 ; iVisited <= 50 ; ++iVisited)
    if(dp[iVisited] <= totalTime){
        LL pos = 0;
        while(pos < remain.size()){
            if(dp[iVisited] + remain[pos] + 1 <= totalTime){
                dp[iVisited] += (remain[pos] + 1);
                pos++;
            } else break;
        }
        ans = max(ans, iVisited + pos);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7440
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
ans=0
for i in range(1,n+2):
  ans+=abs(a[i-1]-a[i])
for i in range(1,n+1):
  res=ans
  res-=abs(a[i-1]-a[i])
  res-=abs(a[i]-a[i+1])
  res+=abs(a[i-1]-a[i+1])
  print(res)

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n;
    cin >> n;

    vector<int> p(n);
    for(int in=0;in<n;in++) {
        cin >> p.at(in);
    }

    int cnt = 0, ptmp;
    for(int in=0;in<n-1;in++) {
        if(p.at(in)==in+1) {
            ptmp = p.at(in);
            p.at(in) = p.at(in+1);
            p.at(in+1) = ptmp;
            cnt++;
        }
    }
    if(p.at(n-1)==n) cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
	//2^aのvector.sizeがKよりでかい→絞り込み
	int N, M,flag=0;
	cin >> N >> M;
	vector<pair<int, int>> U(M);
	for (size_t i = 0; i < M; i++)
	{
		cin >> U.at(i).first >> U.at(i).second;
	}
	if (N == 1) {
		for (int j = 0; j < M; j++)
		{
			//cout << i / pow(10, N - U.at(j).first) << endl;
			if (int(0 != U.at(j).second))flag = 1;
			
		}
		if (flag == 0) {
			cout << 0;
			return 0;
		}
	}
	flag = 0;
	for (size_t i = pow(10,N-1); i < pow(10,N); i++)
	{
		//cout << i << endl;
		for (int j = 0; j < M; j++)
		{
			//cout << i / pow(10, N - U.at(j).first) << endl;
			if (int(i / pow(10, N - U.at(j).first)) % 10 != U.at(j).second) { flag = 1; 
			//cout << ((int(i / pow(10, N - U.at(j).first))) % 10)%10 << endl;
			}
		}
		if(flag==1){
			flag = 0;
			continue;
		}
		else {
			cout << i;
			return 0;
		}
	}
	
	cout << -1;
}

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

const double eps = 1e-11;
double x[4], y[4];
int n;

double dot_product(xy_t a, xy_t b)
{
    return (conj(a) * b).real();
}

double cross_product(xy_t a, xy_t b)
{
    return (conj(a) * b).imag();
}

int main()
{
    cin >> n;
    rep(t, n)
    {
        rep(i, 4) cin >> x[i] >> y[i];
        xy_t a[2] = {
            xy_t(x[0], y[0]) - xy_t(x[1], y[1]),
            xy_t(x[2], y[2]) - xy_t(x[3], y[3])};
        bool p = abs(cross_product(a[0], a[1])) < eps;
        cout << (p ? "YES" : "NO") << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll A, B;
    cin >> A >> B;
    if (A+B >= 10) {
        cout << "error" << endl;
    } else {
        cout << A+ B << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;


int main() {
 int a,b;
 cin>>a>>b;
 if(a*b%2==0){cout<<"Even"<<endl;}
 else{cout<<"Odd"<<endl;}
 return 0;
}


Measured memory_bytes: 256
#include <cstdio>

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

  int total = 0;
  int a, b;
  for(int i = 0; i < n; i++)
  {
    scanf("%d %d", &a, &b);
    total += b - (a - 1);
  }
  printf("%d\n", total);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

main() {
  int i, n;
  double a, b, c;

  scanf("%d", &n);
  for(i=0 ; i<n ; i++) {
    scanf("%lf%lf%lf", &a,&b,&c);
    if(a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b) 
      printf("YES\n");
    else printf("NO\n");
  }

  return 0;
}

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

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

const int INF = 100001;

int d[100][100];

int main() {
    while(true) {
        int n;
        cin >> n;
        if(!n) break;

        rep(i, 10) {
            rep(j, 10) {
                d[i][j] = (i != j ? INF : 0);
            }
        }

        int m = 0;

        rep(i, n) {
            int a, b, cost;
            cin >> a >> b >> cost;
            m = max(m, max(a, b));
            d[a][b] = d[b][a] = cost;
        }

        m++;

        rep(i, m) {
            rep(j, m) {
                rep(k, m) {
                    d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
                }
            }
        }

        int ansd = 10000000, ansi;
        rep(i, m) {
            int sum = 0;
            rep(j, m) {
                sum += d[i][j];
            }
            if(sum < ansd) {
                ansd = sum;
                ansi = i;
            }
        }
        cout << ansi << ' ' << ansd << endl;
    }

    return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <math.h>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int N;
    cin >> N;
    vector<string> S = vector<string>(N);
    vector<Int> T = vi(N);

    Int ans = 0;
    rep(i,N){
        cin >> S[i] >> T[i];
        ans +=T[i];
    }

    string X;
    cin >> X;


    rep(i,N){
        ans-= T[i];
        if(S[i] == X){
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

ll power(ll a, int b) {
  if(!b) return 1;
  ll c = power(a, b/2);
  if(b%2) return c*c*a;
  return c*c;
}

int main() {
  ll N,P;
  cin >> N >> P;
  ll p=P;
  vpli pair;
  for(ll i=2;i*i<=p;i++) {
    if(!(P%i)) {
      int count=0;
      while(!(P%i)) {
        P/=i;
        count++;
      }
      pair.push_back(make_pair(i,count));
    }
  }
  if(P>1) pair.push_back(make_pair(P,1));
  
  ll ans=1;
  rep(i,pair.size()) {
    if(pair[i].second>=N) ans*=power(pair[i].first,pair[i].second/N);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
struct t{
    ll a, b, c, d;
};
ll N, M, Q, ans, T[10];
t A[60];

void dfs(ll idx, ll v){
    T[idx] = v;
    if(idx<N-1){
        repe(i, v, M + 1) dfs(idx + 1, i);
    }
    else{
        ll tmp = 0;
        rep(i,Q){
            if (T[A[i].b] - T[A[i].a] == A[i].c) tmp += A[i].d;
        }
        chmax(ans, tmp);
    }
}

int main() {
    init();
    cin >> N >> M >> Q;
    rep(i,Q){
        cin >> A[i].a >> A[i].b >> A[i].c >> A[i].d;
        A[i].a--, A[i].b--;
    }
    dfs(0, 1);
    cout << ans << endl;
}   

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



int p;

// x / y 
int mdiv( int x, int y ){
	int exp = p - 2;
	while ( exp ){
		if ( exp % 2 )
			x = (x * y) % p;
		y = (y * y) % p;
		exp /= 2;
	}
	return x;
}



/*
  g(x) = x(x-1)(x-2)(x-3)....(x-(p-1)) の多項式を作成する。
  gi(x) = g(x)/(x-i)
  
  result(x) = 0
  for ( i )
    if ( ai == 1 )
       result(x) += gi(x)/gi(i)
  
*/

// g(x) を出力する
void test( vector<int> &g, string label ){
	cout << label << " is ";
	for ( auto it : g ){
		cout << (it%p) << " ";
	}
	cout << endl;
	cout << "f(x) is ";
	for ( int x = 0; x < p; x++ ){
		int sum = 0;
		int mul = 1;
		for ( auto it : g ){
			sum = (sum + (it%p) * mul)%p;
			mul = (mul * x) % p;
		}
		cout << (sum%p) << " ";
	}
	cout << endl;
	cout << endl;
}




int main(){
	cin >> p;
	
	vector<int> a(p);
	for ( int i = 0; i < p; i++ ){
		cin >> a[i];
	}
	
	vector<int> inv(p);
	for ( int i = 1; i < p; i++ ){
		inv[i] = mdiv(1,i);
	}
	
	vector<int> g(p+1);
	g[0] = 1;
	for ( int i = 0; i < p; i++ ){
		// g に (x-i) を掛ける
		int tmp = 0;
		for ( int j = 0; j <= p; j++ ){
			int tmp2 = g[j];
			g[j] = (g[j] * (p-i) + tmp) % p;
			tmp = tmp2;
		}
	}
	
	//test( g, "g" );
	
	vector<int> result(p);
	for ( int i = 0; i < p; i++ ){
		if ( a[i] ){
			
			// gi = g / (x-i)
			vector<int> gi(p);
			vector<int> gg = g;
			
			for ( int j = p-1; j >= 0; j-- ){
				int c = gi[j] = gg[j+1];
				
				gg[j+1] = 0;
				gg[j] = (gg[j] - (-i*c)) % p;
			}
			
			// gii = gi(i)
			int xp = 1;
			int gii = 0;
			for ( int j = 0; j < p; j++ ){
				gii = (gii + gi[j] * xp) % p;
				xp = (xp * i) % p;
			}
			gii = gii % p;
			
			// result(x) += gi(x)/gii
			for ( int j = 0; j < p; j++ )
				result[j] += (gi[j] * inv[gii]) % p;
		}
	}
	
	//test( result, "result" );
	
	for ( int i = 0; i < p; i++ )
		cout << (result[i] % p) << " ";
	cout << endl;
	
	return 0;
}



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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b > c+d) cout << "Left\n";
  else if (a+b < c+d) cout << "Right\n";
  else cout << "Balanced\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
const long long MAX = 1e9;


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


int main(){
    int N;
    long long X;
    cin >> N >> X;
    long long x[N],d[N];
    long long res;
    rep(i,N){
        cin >> x[i];
        d[i] = abs(X-x[i]);
        if (i == 1){
            res = gcd(d[0],d[1]);
        }
        if (i > 1){
            res = gcd(res,d[i]);
        }
    }
    if (N == 1) {
        res = d[0];
    }
    cout << res;

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>

using namespace std;
typedef long long ll;

ll A, B, C, X, Y, ans;

int main() {
	cin >> A >> B >> C >> X >> Y;
	ans = A*X + B*Y;
	if (X > Y) {
		if (ans > C*Y * 2 + (X - Y)*A)ans = C*Y * 2 + (X - Y)*A;
	}
	else {
		if (ans > C*X * 2 + (Y - X)*B)ans = C*X * 2 + (Y - X)*B;
	}
	if (ans > max(X, Y)*C * 2)ans = max(X, Y)*C * 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int D=365,c[26+1],last[26+1];
int main(){
    cin>>D;
    int s[D+1][26+1];
    for(int i=1;i<=26;i++)cin>>c[i];
    for(int i=1;i<=D;i++)for(int j=1;j<=26;j++)cin>>s[i][j];
    int t[D+1];
    for(int i=1;i<=D;i++)cin>>t[i];
    int v[D+1];v[0]=0;
    for(int d=1;d<=D;d++){
        v[d]=v[d-1]+s[d][t[d]];
        last[t[d]]=d;
        for(int i=1;i<=26;i++)v[d]-=c[i]*(d-last[i]);
    }
    for(int i=1;i<=D;i++)cout<<v[i]<<endl;
    return 0;
}

Measured memory_bytes: 3672
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
CD = [list(map(int, input().split())) for _ in range(N)]

CD.sort()
red_check = [0] * N

for i in range(N):
  c, d = CD[i]
  bmax = - 10 ** 15
  maxj = -1
  for j in range(N):
    if red_check[j] == 0:
      a, b = AB[j]
      if a < c and b < d and b > bmax:
        bmax = b
        maxj = j
  if maxj != -1:
    red_check[maxj] = 1

print(sum(red_check))

Measured memory_bytes: 39152
loop do
  a, b = gets.split.map(&:to_i)
  break if a == 0
  n = gets.to_i
  c = []
  n.times { c << gets.split.map(&:to_i) }

  dp = []
  dp[0] = []
  dp[0][0] = 1
  b.times do |bi|
    dp[bi] ||= []
    a.times do |ai|
      # p [bi, ai].to_s
      # p dp
      next if bi == 0 && ai == 0
      dp[bi][ai] = dp[bi - 1][ai] if ai == 0
      dp[bi][ai] = dp[bi][ai - 1] if bi == 0
      dp[bi][ai] = dp[bi - 1][ai] + dp[bi][ai - 1] if bi >= 1 && ai >= 1
      dp[bi][ai] = 0 if c.include? [ai + 1, bi + 1]
    end
  end

  # p dp
  puts dp.last.last
end

Measured memory_bytes: 8560
#include<cstdio>

using namespace std;

int a, b;

int main(){
	scanf("%d%d", &a, &b);
	if(1 <= a && a <= 9 && 1 <= b && b <= 9)
		printf("%d\n", a*b);
	else
		puts("-1");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y;
	cin >> x>> y;
      cout << (x-1)*(y-1) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;
    ll k;
    cin >> k;
    cout << ((k+1)/2)*(k/2)<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[30];
bool rec(int count,int total){
    if(total==0) return true;//合計があった時
    if(count==n||total<0) return false;//countが最大値になった時ortotalがマイナスになった時
    return rec(count+1,total)||rec(count+1,total-a[count]);
}
signed main(){

    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    int q;
    cin>>q;
    int m[q];
    for(int i=0;i<q;i++) cin>>m[i];
    for(int i=0;i<q;i++) cout<<(rec(0,m[i])?"yes":"no")<<endl;
    return 0;
}



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

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll N,M,K;
ll ans = -1;

cin >> N >> M >> K;

vector<ll> A(N);
vector<ll> B(M);

for(ll i = 0;i < N;++i) cin >> A[i];
for(ll j = 0;j < M;++j) cin >> B[j];

vector<ll> sumA(N+1,0);
vector<ll> sumB(M+1,0);

for(ll i = 0;i < N;++i) sumA[i+1] = sumA[i] + A[i];
for(ll i = 0;i < M;++i) sumB[i+1] = sumB[i] + B[i];

for(ll i = 0;i <= N;++i){

  ll t = K - sumA[i];
  ll left = 0;
  ll right = M+1;
  ll mid = 0;

  if(t >= 0){


    while(right - left > 1){

      mid = (left + right)/2;

      if(sumB[mid] <= t) left = mid;
      else right = mid;

    }

    ll res = i + left;

    ans = max(ans,res);

  }

}

cout << ans << endl;

return 0;

}   


Measured memory_bytes: 9496
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int d, g, ans = INF;
    cin >> d >> g;
    vector<int> p(d), c(d), solved(d, 0);
    for (int i = 0; i < d; ++i) {
        cin >> p[i] >> c[i];
    }
    for (int i = 0; i < (1 << d); ++i) {
        int sum = 0;
        solved.assign(d, 0);
        for (int j = 0; j < d; ++j) {
            if (i & (1<<j)) {
                solved[j] = p[j];
                sum += p[j] * (j+1)*100 + c[j];
            }
        }
        for (int j = d-1; j >= 0 ; --j) {
            if(sum >= g) break;
            if(solved[j] != p[j]){
                int k = min(p[j]- solved[j], (g-sum + (j+1)*100 -1) / ((j+1)*100));
                solved[j] += k;
                sum += k * (j + 1) * 100;
            }
        }
        ans = min(accumulate(solved.begin(), solved.end(), 0), ans);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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 ll INF = 1e18;

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[110][5][5][5];
int main(){
    int n;
    cin >> n;
    rep(i,110)rep(j,5)rep(k,5)rep(l,5)dp[i][j][k][l]=0;
    dp[0][0][0][0] = 1;
    rep(i,n+1)rep(j,5)rep(k,5)rep(l,5)for(int m=1;m<=4;m++){
        if(k==1&&l==2&&m==3)continue;
        if(k==1&&l==3&&m==2)continue;
        if(k==2&&l==1&&m==3)continue;
        if(j==1&&l==2&&m==3)continue;
        if(j==1&&k==2&&m==3)continue;
        dp[i+1][k][l][m]+=dp[i][j][k][l];
    }
    mint ans = 0;
    rep(j,5)rep(k,5)rep(l,5)ans+=dp[n][j][k][l];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a < b)
        {
            if (a < c && c < b)
                System.out.println("Yes");
            else
                System.out.println("No");
        }
        else
        {
            if (b < c && c < a)
                System.out.println("Yes");
            else
                System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
char s[11];
int a[20];

for(int i=0;i<=19;i++){
    a[i]=0;
}
scanf("%s",s);
int count=0;
for(int i=0;s[i]!='\0';i++){
    if(s[i]=='0'){
        a[count]=0;count++;
    }
    else if(s[i]=='1'){
        a[count]=1;count++;
    }
    else if(s[i]=='B'&&count!=0){
        count--;
        a[count]=3;
    }
    else{continue;}
}
    for(int i=0;i<=count-1;i++){
        printf("%d",a[i]);
    }
}





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

struct UnionFind {
    vector<int> v;

    UnionFind(int n) {
        v.resize(n);
        rep(i,n) v[i] = i;
    }
    int root(int x) {
        if (v[x] == x) return x;
        return v[x] = root(v[x]);
    }
    void unite(int x,int y) {
        if (root(x) == root(y)) return;
        v[root(x)] = root(y);
    }
};

int main() {
    int v,e; cin >> v >> e;
    tuple<int,int,int> stw[100000];
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> hq;
    rep(i,e) {
        int s,t,w; cin >> s >> t >> w;
        stw[i] = tuple<int,int,int>(s,t,w);
        hq.push(make_pair(w,i));
    }
    lint ans = 0;
    UnionFind uf(v);
    while (hq.size() != 0) {
        pair<int,int> t = hq.top(); hq.pop();
        int x,y;
        x = get<0>(stw[t.second]);
        y = get<1>(stw[t.second]);
        if (uf.root(x) == uf.root(y)) continue;
        uf.unite(x,y);
        ans += get<2>(stw[t.second]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5020
#include <iostream>
#include <algorithm>
#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

typedef long long ll;

int ans;
int N;
pair<int, int> p[100005];

int main(void) {
    scanf("%d", &N);
    REP(i, 0, N) {
    	int A;
    	scanf("%d", &A);
    	p[i] = make_pair(A, i+1);
    }

    sort(p, p+N);
    
    REP(i, 0, N) {
    	if (i > 0) printf(" ");
    	printf("%d", p[i].second);
    }
    printf("\n");
	return 0;
}


Measured memory_bytes: 1536
// ABC 064 C
#include <iostream>
#include <numeric>

using namespace std;

int arraySum(int a[], int n)
{
    int initial_sum  = 0;
    return accumulate(a, a+n, initial_sum);
}


int main(){

    // N : # of players
    // a_1, ...., a_N : ratings of players
    
    int N;
    scanf("%d", &N);
    //int ratings[N+1];
    int ans = 0;
    int divisions[8] = {0};
    int above_red = 0;
    int rating;
    
    
    for(int i=0; i<N; i++){
        scanf("%d", &rating);
        //ratings[i] = rating;
        
        if(rating >=1 && rating <= 399){
            divisions[0] = 1;
        } else if(rating >=400 && rating <= 799){
            divisions[1] = 1;
        } else if(rating >=800 && rating <= 1199){
            divisions[2] = 1;
        } else if(rating >=1200 && rating <= 1599){
            divisions[3] = 1;
        } else if(rating >=1600 && rating <= 1999){
            divisions[4] = 1;
        } else if(rating >=2000 && rating <= 2399){
            divisions[5] = 1;
        } else if(rating >=2400 && rating <= 2799){
            divisions[6] = 1;
        } else if(rating >=2800 && rating <= 3199){
            divisions[7] = 1;
        } else if(rating >=3200){
            above_red += 1;
        }
    }
    
    bool all_above_red = true;
    for(int i=0; i<8; i++){
        if(divisions[i]){
            all_above_red = false;
            break;
        }
    }
    
    if(all_above_red){
        cout << 1 << " " << above_red << endl;
        return 0;
    } else {
        cout << arraySum(divisions, sizeof(divisions)/sizeof(divisions[0])) << " " << arraySum(divisions, sizeof(divisions)/sizeof(divisions[0]))+above_red << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = list(map(int,input().split()))
key = ans[0]
up_key = True
down_key = True
count = 0
for i in range(n):
    if key < ans[i]:
        down_key = False
    if key > ans[i]:
        up_key = False
    if up_key == False and down_key == False:
        count += 1
        up_key = True
        down_key = True
    key = ans[i]
print(count+1)


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

bool has3(int x){
 while(x){
  if ( x % 10 == 3 ) return true;
  x /= 10;
  }
 return false;
}
void call(int n){
 for ( int x = 1; x <= n; x++ ){
  if ( x % 3 == 0 || has3(x) ){
   cout << " " << x;
  }
 }
 cout << endl;
}

int main(){
 int n;
 cin >> n;
 call(n);

 return 0;
}

Measured memory_bytes: 3124
# -*- coding:utf-8 -*-
L, R = map(int, input().split())

min_mod = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        min_mod = min(min_mod, (i * j) % 2019)
        if min_mod == 0:
            print('0')
            exit(0)

print(min_mod)


Measured memory_bytes: 2940
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;


typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void shortestPath(const Graph &g, int s,
	vector<Weight> &dist, vector<int> &prev) {
	int n = g.size();
	dist.assign(n, INF); dist[s] = 0;
	prev.assign(n, -1);
	priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
	for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
		Edge e = Q.top(); Q.pop();
		if (prev[e.dst] != -1) continue;
		prev[e.dst] = e.src;
		for (auto f = g[e.dst].begin();f != g[e.dst].end();f++) {
			if (dist[f->dst] > e.weight + f->weight) {
				dist[f->dst] = e.weight + f->weight;
				Q.push(Edge(f->src, f->dst, e.weight + f->weight));
			}
		}
	}
}
vector<int> buildPath(const vector<int> &prev, int t) {
	vector<int> path;
	for (int u = t; u >= 0; u = prev[u])
		path.push_back(u);
	reverse(path.begin(), path.end());
	return path;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = { 0, 1, 0, -1 };

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N);
	for (int i = 0;i < N;i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	ll ans = 0;
	for (int i = 0;i < N;i++)
		if (i % 2 == 0)
			ans += a[N-1-i];
		else
			ans -= a[N-1-i];
	cout << ans << endl;
	return 0;
}


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

signed main(){

    string s; cin >> s;
    int n = (int)s.size();
    
    int c0 = 0, c1 = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '0') c0++;
        else c1++;
    }

    cout << 2 * min(c0, c1) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <queue>
#include <algorithm>
#include <iostream>
using namespace std;
using namespace std; typedef long long ll;
typedef pair<ll,ll> P;

int main() {
  int n; cin>>n;
  int s[n]; for(int i=0;i<n;i++) cin>>s[i];
  int sm=0;
  for(int i=0;i<n;i++) sm+=s[i];
  int an=0;
  if (sm%10) an=sm;
  for(int i=0;i<n;i++) {
    if ((sm-s[i])%10) an=max(an,sm-s[i]);
  }
  cout<<an<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;

long long powerMod(long long number,long long power,long long mod)
{
    LL ret=0;

    if(power==0) return 1LL%mod;
    if(power==1) return number%mod;
    if(power%2==0)
    {
        ret=powerMod(number,power/2,mod);
        ret=(ret%mod*ret%mod)%mod;
        return ret%mod;
    }
    else
    {
        ret=powerMod(number,power/2,mod);
        ret=(ret%mod*ret%mod*number%mod)%mod;
        return ret%mod;
    }
}

int main()
{

    LL n;
    cin>>n;

    map<string,int> mp;
    S s[n];
    set<string> st;

    for(int i=0;i<n;i++)
    {
       cin>>s[i];
        mp[s[i]]++;

    }
    LL mx=-1;

    for(int i=0;i<n;i++)
    {
       if(mp[s[i]]>mx)
            mx=mp[s[i]];

    }

    vector<string> v;
    set<string> :: iterator itr;
    for(int i=0;i<n;i++)
    {
       if(mp[s[i]]==mx)
           st.insert(s[i]);

    }

    for(itr = st.begin(); itr!= st.end();++itr)
    {
        v.push_back(*itr);
    }


    sort(v.begin(),v.end());

    for(int i=0;i<v.size();i++)
    {
        cout<<v[i]<<nl;
    }

    return 0;
}

/*

*/


Measured memory_bytes: 37876
k,n=map(int,input().split())
a=list(map(int,input().split()))
d=0
s=0
for i in range(1,n):
    if d<a[i]-a[i-1]:
        d=a[i]-a[i-1]
        pos=i
    if d<k-a[-1]+a[0]:
        d=k-a[-1]+a[0]
        pos=0
#print(pos)
for i in range(1,n):
    if i!=pos:
        s+=a[i]-a[i-1]
if pos!=0:
    s+=k-a[-1]+a[0]
print(s)
    
    

Measured memory_bytes: 26444
N = int(input())

A = [i for i in map(int, input().split())]
B = [i for i in map(int, input().split())]
C = [i for i in map(int, input().split())]

ans = 0
for i in range(N):
    ans += B[A[i] - 1]
    if i == 0:
        continue
    if A[i] == A[i - 1] + 1:
        ans += C[A[i - 1] - 1]
print(ans)

Measured memory_bytes: 3064