akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
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 co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int X = getint(), K = getint();
	int r[100002];
	rep1(i, K) r[i] = getint();
	r[0] = 0;
	r[K + 1] = 2e9;

	int L = 0;
	int R = X;
	int takasa = 0;
	int katamuki = -1;
	int *ri = r;

	int Q = getint();
	rep(i, Q) {
		int t = getint(), a = getint();
		
		while (t > *(ri + 1)) {
			takasa += katamuki * (*(ri + 1) - *ri);
			if (katamuki < 0) {
				L -= min(0, takasa + L);
				R -= min(0, takasa + R);
			}
			else {
				L -= max(0, takasa + L - X);
				R -= max(0, takasa + R - X);
			}
			ri++;
			katamuki *= -1;
		}
		chmax(a, L);
		chmin(a, R);
		a += takasa + katamuki * (t - *ri);
		chmax(a, 0);
		chmin(a, X);
		putint(a);
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 2560
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

const int N = 1e5 + 100;
vector<vector<pii>> g(N);
map<int, int> mp;
vector<bool> visited(N, false);

void dfs(int v) {
  visited[v] = true;
  for (auto &u : g[v]) {
    if (!visited[u.fi]) {
      mp[u.fi] = mp[v] + u.se;
      dfs(u.fi);
    } else if(mp[u.fi] != mp[v] + u.se) {
      cout << "No\n";
      exit(0);
    }
  }
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<pair<pii, int>> in(m);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    g[l].push_back({r, d});
    g[r].push_back({l, -d});
    in[i] = {{l, r}, d};
  }
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      mp[i] = 0;
      dfs(i);
    }
  }
  cout << "Yes\n";
}



Measured memory_bytes: 29056
#include <bits/stdc++.h>
    #define INF (1<<30)
    #define MOD 1000000007
    #define l_ength size
    using ll = long long;
    using namespace std;
     
    int main(){
    	 int n; cin >> n;
    	 vector<ll> a(n);
    	 for( auto &k : a ) cin >> k;
    	 bitset<4000005> x;
    	 x.set(0);
    	 for( int i = 0; i < n; ++i ){
    		 x |= ( x << a[i] );
    	 }
    	 int sum = accumulate( a.begin(), a.end(), 0 );
    	 int bound = (sum+1)/2;
    	 for( int i = bound; i <= sum; ++i ){
    		 if( x.test(i) ){
    			 cout << i << endl;
    			 break;
    		 }
    	 } 
    	return 0;
    }

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

int main () {
  long long int N;
  vector<long long int> A;
  long long int sum = 0;

  cin >> N;
  for (long long int i = 0; i < N; i++) {
    long long int n;
    cin >> n;
    A.push_back(n);
    sum += n;
  }
  sort(A.begin(), A.end());
  cout << A.front() << ' ' << A.back() << ' ' << sum << endl;
}

Measured memory_bytes: 3160
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Varied
            var s = Console.ReadLine();

            if (IsAllDifferent(s))
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }
        }

        static bool IsAllDifferent(string s)
        {
            var chars = new List<char>();

            foreach (var c in s)
            {
                if (!chars.Contains(c))
                {
                    chars.Add(c);
                }
                else
                {
                    return false;
                }
            }

            return true;
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
//data types useful short forms
typedef long long ll;
typedef pair <ll, ll> pll;
// templates for printing out data structures in a signal line
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v) {os << v.first << " " << v.second <<"\n"; return os; } 
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v) {for(auto it : v)os << it.first << " : " << it.second << "\n";return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T>& v) { os << "["; for (auto it : v) { os << it; if (it != *v.rbegin()) os << ", "; } os << "]\n";return os;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){ for (int i = 0; i < v.size(); ++i) { os << v[i];if (i != v.size() - 1)os << " ";} os << "\n";return os; }
// convenient definitions and functions
#define pb                 push_back
#define sorting(c)         sort((c).begin(),(c).end())
#define FIO                ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sz(a)              long((a).size())
#define REP(x,l,u)         for(ll x = l;x<=u;x++)
#define loop(x,l,u)        for(ll x=  l;x<u;x++)
const   ll mod = 1e9+7;
// modular exponentiation :
ll fast(ll a,ll b){ll ans = 1;while(b){if(b&1){b--;ans = ans * a % mod;}else{a = a * a % mod;b/=2;}}return ans%mod;}

int main()
{
	FIO;
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=LLONG_MAX;
	if((b-a)%2==0)
		ans=(b-a)/2;
	else
	{
		ll steps;
		//b is closer to n , than a is to 1 
		if(n-b <= a-1)
			steps=n-b+1;
		else
			steps=a;
		ans=steps + (b-a-1)/2; 
	}

	ans=min({b-1,n-a,ans});
	
	cout<<ans<<endl;
}

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

task=[]
for _ in range(N):
    A,B=map(int,input().split())
    task.append([B,A])
task.sort()

S=0
ans="Yes"
for i in range(N):
    S+=task[i][1]
    if S>task[i][0]:
        ans="No"
        break
print(ans)

Measured memory_bytes: 35608
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n;
    string s, t;
    cin >> n;
    cin >> s >> t;
    bool isAns = false;
    int ans = s.length() + t.length();
    for (int i=0; i<n; ++i){
        if(isAns){
            break;
        }
        for (int j=0; j<n-i; ++j){
            if(s[i+j] != t[j]){
                break;
            }
            else if(s[i+j] == t[j] && j == n-i-1){
                ans = i + n;
                isAns = true;
                break;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n, k;
string s;

int acc[MAX_N];

int ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);
  cin >> s;

  if (s[0] == '0') {
    acc[0] = 1;
  }

  for (int i = 1; i < n; ++i) {
    if (s[i - 1] == '1' && s[i] == '0') {
      acc[i] = 1;
    }
  }

  for (int i = 1; i < n; ++i) {
    acc[i] += acc[i - 1];
  }

  acc[n] = acc[n - 1] + 1;

  if (acc[n - 1] <= k) {
    printf("%d\n", n);
    return 0;
  }

  ans = -1;

  for (int i = 0; i < n; ++i) {
    int buff = (s[i] == '0') ? k - 1 : k;

    int end = upper_bound(acc + i, acc + n + 1, acc[i] + buff) - acc;

    if ((acc[end] - acc[i]) != buff + 1) continue;

    ans = max(ans, end - i);
  }

  printf("%d\n", ans);

  return 0;
}


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

using namespace std;

long long inf=1000000007;
int h,w;
vector<string> maze(20);
int ans=-1;

void bfs(int sx,int sy){
	if(maze.at(sy).at(sx)=='#') return;

	vector<vector<int>> dist(h,vector<int>(w,-1));
	dist.at(sy).at(sx)=0;
	queue<pair<int,int>> que;
	que.push(make_pair(sx,sy));

	while(!que.empty()){
		int x=que.front().first;
		int y=que.front().second;
		que.pop();

		vector<int> dx={1,0,0,-1},dy={0,-1,1,0};

		for(int i=0;i<4;i++){
			int px=x+dx.at(i);
			int py=y+dy.at(i);
			if(px<0 || px>=w || py<0 || py>=h || maze.at(py).at(px)=='#' || dist.at(py).at(px)!=-1) continue;

			dist.at(py).at(px)=dist.at(y).at(x)+1;
			que.push(make_pair(px,py));
			ans=max(ans,dist.at(py).at(px));
		}
	}
}

int main(){
	cin>>h>>w;

	for(int i=0;i<h;i++){
		cin>>maze.at(i);
	}

	for(int sx=0;sx<w;sx++){
		for(int sy=0;sy<h;sy++){
			bfs(sx,sy);
		}
	}

	cout<<ans<<endl;

	return 0;
}


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


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

int sa=0;
int frag2=0;
vector<int> num(n);
  for(int i=0;i<n;i++)
{
    cin>>num.at(i);

}
for (int i = 0; i < 100; i++)
{
int frag=0;
int frag2=0;
    for (int j = 0; j < n; j++)
    {

        if (num.at(j)==x+i)
        {

         frag++;
         frag2=1;
        }
  if (num.at(j)==x-i)
  {

    frag++;
    frag2=2;
  }

  
    
    }
    if (frag>1)
    {

        sa++;
    }
    else
    {


        if (frag2<2)
        {
            cout<<x-sa<<endl;
        }
        else{
            cout<<x+sa<<endl;
        }
        break;
    }
  
    
}

}

Measured memory_bytes: 3460
use std::io::Read;
use std::collections::BTreeSet;

fn dfs(v: usize, par: usize, acc: i32, g: &[BTreeSet<usize>], counts: &[i32], result: &mut [i32]) {
    result[v] = counts[v] + acc;
    for &c in g[v].iter() {
        if c != par {
            dfs(c, v, result[v], g, counts, result)
        }
    }
}

fn solve(n: usize, _q: usize, ab: &[(usize, usize)], px: &[(usize, i32)]) -> Vec<i32> {
    let mut g = vec![BTreeSet::new(); n];
    for &(a, b) in ab {
        g[a - 1].insert(b - 1);
        g[b - 1].insert(a - 1);
    }
    let mut counts = vec![0; n];
    for &(p, x) in px {
        counts[p - 1] += x;
    }
    let mut result = vec![0; n];
    dfs(0, std::usize::MAX, 0, &g, &counts, &mut result);
    result
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let q: usize = iter.next().unwrap().parse().unwrap();
    let ab: Vec<(usize, usize)> = (0..n-1)
        .map(|_| {
            let a: usize = iter.next().unwrap().parse().unwrap();
            let b: usize = iter.next().unwrap().parse().unwrap();
            (a, b)
        })
        .collect();
    let px: Vec<(usize, i32)> = (0..q)
        .map(|_| {
            let p: usize = iter.next().unwrap().parse().unwrap();
            let x: i32 = iter.next().unwrap().parse().unwrap();
            (p, x)
        })
        .collect();
    let r = solve(n, q, &ab, &px);
    println!("{}", r.iter().map(i32::to_string).collect::<Vec<_>>().join(" "));
}


Measured memory_bytes: 91040
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

int main(void){
char num_str[1002];
int num;
long long int sum =0;
int i;
char tmp;

    while(1){
    fgets(num_str,1002,stdin);
    if(num_str[0]=='0') break;
    for(i=0;i<strlen(num_str)-1;i++){
        tmp = num_str[i];
        num = atoi(&tmp);
        sum = sum + num;
    }

    printf("%lld\n",sum);
    sum = 0;
    memset(num_str,1002,0);
}
return 0;}

Measured memory_bytes: 532
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int dif=0, res=0, len=1;
    rep(i, n-1){
        if(s[i]!=s[i+1]){
            dif++;
            res += len - 1;
            len=1;
        }else{
            len++;
        }
    }
    res += len - 1;
    if(dif%2){
        if(dif/2>=k){
            cout << res + 2 * k << endl;
        }else{
            cout << res + 2 * (dif / 2) + 1 << endl;
        }
    }else{
        cout << res + 2 * min(dif/2, k) << endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n, m;
    cin >> n >> m;

    vector<int> a(n);
    int sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }

    int cnt = m;
    rep(i, n){
        if(a[i] * 4 * m >= sum){
            cnt--;
        }
    }

    if(cnt <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main() {
	double x[22], y[22], ans = 0;
	int n = 0;
	while (~scanf("%lf,%lf", &x[n], &y[n])) {
		n++;
	}
	double s;
	for (int i = 1; i < n; i++) {
		s = (x[i] - x[0])*(y[(i + 1)%n] - y[0]) - (x[(i + 1)%n] - x[0])*(y[i] - y[0]);
		if (s < 0)s = -s;
		ans += s;
	}
	printf("%.8lf", ans/2.0);
}


Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  deque<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  deque<long long> d;
  long long ans = 0;
  bool flag = true;
  while(a.size() > 1) {
    if (flag) {
      long long k = a.front(); a.pop_front();
      d.push_front(k);
      k = a.back(); a.pop_back();
      d.push_back(k);
    } else {
      long long k = a.front(); a.pop_front();
      d.push_back(k);
      k = a.back(); a.pop_back();
      d.push_front(k);
    }
    flag = !flag;
  }
  if (!a.empty()) {
    long long k = a.front();
    if (abs(k-d.front()) > abs(k-d.back())) {
      d.push_front(k);
    } else {
      d.push_back(k);
    }
  }
  for (int i = 1; i < n; i++) {
    //cout << d[i-1] << " ";
    ans += abs(d[i] - d[i-1]);
  }
  //cout << d[n-1] << endl;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>

using namespace std;

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

  if (a == b) {
    cout << "Draw" << '\n';
  } else {
    if (a == 1) {
      cout << "Alice" << '\n';
    } else if (b == 1) {
      cout << "Bob" << '\n';
    } else {
      if (a > b) {
        cout << "Alice" << '\n';
      } else {
        cout << "Bob" << '\n';
      }
    }
  }
  return 0;
}

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

// 比較演算では、pairの第一要素の比較結果が返される。第一要素が同じ値だった場合は、第二要素の比較結果が返される。

int main() {
  int n, q;
  int a, v;
  priority_queue<pair<int,int> > PQ;
  
  cin >> n >> q;
  vector<int> fish(n+1);
  for(int i = 0; i < q; i++) {
    cin >> a >> v;
    fish[a] += v;
    PQ.push(make_pair(fish[a], -a));
    for(;;) {
      int A = (PQ.top()).first;
      int B = -(PQ.top()).second;
      if(fish[B] == A) {
	cout << B << " " << A << endl;
	break;
      }
      PQ.pop(); // データに変化があった情報はPQから消す
    }
  }
  
  return 0;
}

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

using namespace std;
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

string s;
int gnum, pnum;

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

    cin >> s;
    int sum = 0;
    for(int i = 0; i < s.length(); ++i) {
        if(s[i] == 'p') {
            if(pnum < gnum) pnum ++;
            else sum --, gnum ++;
        } else {
            if(pnum < gnum) pnum ++, sum ++;
            else gnum ++;
        }
    }
    cout << sum;
}


Measured memory_bytes: 512
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M=map(int, input().split())
uf = UnionFind(N)
for i in range(M):
  A,B=map(int, input().split())
  uf.union(A-1,B-1)
print(uf.group_count()-1)

Measured memory_bytes: 12944
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,t,ans=0;
  scanf("%d%d%d",&n,&a,&b);
  for (int i=0; i<n; ++i){
    scanf("%d",&t);
    if (t<a||t>=b)ans++;
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int find(int x){
    if(a[x]!=x) 
	    a[x]=find(a[x]);
	return a[x]; 
}
int main(){
	int n,x,y,total=0,m;
	cin>>n>>m; 
	for(int i=1;i<=n;i++){
	   a[i]=i; 
	} 
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		int fx,fy;
		fx=find(x),fy=find(y);
		if(fx!=fy){
			a[fy]=fx;
		}
	}
	for(int i=1;i<=n;i++){
		if(a[i]==i){
			total++;
		} 
	}
	cout<<total-1<<endl;
	return 0;
}

Measured memory_bytes: 4008
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		s.next();
		long min = Integer.parseInt(s.next()),
		     max = min,
		     sum = min,
		     in;
		while(s.hasNext()) {
			in = Integer.parseInt(s.next());
			min = Math.min(min, in);
			max = Math.max(max, in);
			sum += in;
		}

		System.out.printf("%d %d %d\n",min,max,sum);
	}
}

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

int mincost(int ar[],int n)
{
    int cost[n];

    cost[n-1]=0;
    cost[n-2]=abs(ar[n-2]-ar[n-1]);

    for(int i=n-3; i>=0; i--){
        int a=cost[i+1]+abs(ar[i]-ar[i+1]);
        int b=cost[i+2]+abs(ar[i]-ar[i+2]);
        cost[i] = min(a,b);
    }

    return cost[0];
}

int main()
{
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    cout << mincost(ar,n);
}



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

int main(){
    int n;
    cin>>n;
    int a[n];
    int ans=0;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++){
        if(a[a[i]]==i)ans++;
    }
    cout<<ans/2<<endl;
    return 0;
}

Measured memory_bytes: 3908
#include<iostream>
using namespace std;
int main(){
long i,j,k,n;
while(cin>>n){
if(n/2*2==n)k=1;else k=2;
for(j=n-k;j>=3;j-=2){
for(i=3;i*i<n;i+=2)if(j%i==0)break;
if(i*i>=n){cout<<j;break;}
}
if(j==1)cout<<"2";

for(j=n+k;;j+=2){
for(i=3;i*i<n;i+=2)if(j%i==0)break;
if(i*i>=n){cout<<" "<<j<<endl;break;}
}

}
return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = Integer.parseInt(sc.next());
        }

        int cnt = 0;
        for (int i = 1; i < n-1 ; i++) {
            if ((p[i] - p[i-1])*(p[i] - p[i+1]) < 0) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, bcount = 0, arr[2], v1, v2, v3, flag = 0;
    int k = 0;
    cin >> x;
    int a[x];
    for(int i = 0; i < x; i++)
    {
        cin >> a[i];
    }
    for(int i = 1; i < x; i++)
    {
        if(a[i-1] <= a[i])
        {
            continue;
        }
        else
        {
            flag = 1;
            for(int j = i; j < x; j++)
            {
                if((a[j] + 1 )== a[i-1])
                {
                    if((j+1) < x && a[j+1] < a[i-1])
                    {
                        swap(a[j+1], a[i-1]);
                        break;
                    }
                    swap(a[j], a[i-1]);
                    break;
                }
            }
        }
    }
    if(flag == 0)
    {
        cout << "YES";
        return 0;
    }
    for(int i = 1; i < x; i++)
    {
        if(a[i-1] <= a[i])
        {
            continue;
        }
        else
        {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

int N;
ll X[51],Y[51];

double ret;

void hoge(double x,double y) {
	double r=0;
	int i;
	FOR(i,N) r=max(r,hypot(X[i]-x,Y[i]-y));
	ret=min(ret,r);
}

void solve() {
	int i,j,k,l,r,x,y,z; string s;
	
	cin>>N;
	FOR(i,N) cin>>X[i]>>Y[i];
	ret=1e9;
	
	FOR(z,N) FOR(y,z) {
		double rx=(X[y]+X[z])/2.0;
		double ry=(Y[y]+Y[z])/2.0;
		hoge(rx,ry);
		
		FOR(x,y) {
			double a=hypot(X[y]-X[z],Y[y]-Y[z]);
			double b=hypot(X[z]-X[x],Y[z]-Y[x]);
			double c=hypot(X[x]-X[y],Y[x]-Y[y]);
			
			if(abs(a+b-c)<1e-9) continue;
			if(abs(a+c-b)<1e-9) continue;
			if(abs(c+b-a)<1e-9) continue;
			
			double rx=(a*a*(b*b+c*c-a*a)*X[x]+b*b*(a*a+c*c-b*b)*X[y]+c*c*(b*b+a*a-c*c)*X[z])/(a*a*(b*b+c*c-a*a)+b*b*(a*a+c*c-b*b)+c*c*(b*b+a*a-c*c));
			double ry=(a*a*(b*b+c*c-a*a)*Y[x]+b*b*(a*a+c*c-b*b)*Y[y]+c*c*(b*b+a*a-c*c)*Y[z])/(a*a*(b*b+c*c-a*a)+b*b*(a*a+c*c-b*b)+c*c*(b*b+a*a-c*c));
			hoge(rx,ry);
		}
	}
	_P("%.12lf\n",ret);
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.awt.geom.*;
import static java.util.Arrays.*;

class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		while(true){
			int m = Integer.parseInt(stdIn.next());
			if(m==0){
				break;
			}
			int[] vm = new int[m];
			int vmcount = 0;
			for(int i=0;i<m-1;i++){
				vm[i] = Integer.parseInt(stdIn.next());
				vmcount += vm[i];
			}
			vm[m-1] = 360-vmcount;
			int n = Integer.parseInt(stdIn.next());
			int[] vn = new int[n];
			int vncount = 0;
			for(int i=0;i<n-1;i++){
				vn[i] = Integer.parseInt(stdIn.next());
				vncount += vn[i];
			}
			vn[n-1] = 360 - vncount;
			double marea = 0;
			double narea = 0;
			for(int i=0;i<m;i++){
				marea += Math.sin(Math.toRadians(vm[i]));
			}
			for(int i=0;i<n;i++){
				narea += Math.sin(Math.toRadians(vn[i]));
			}

			if(Math.abs(marea-narea)<Math.pow(10,-8)){
				out.println(0);
			}
			else if(marea<narea){
				out.println(2);
			}
			else{
				out.println(1);
			}
			out.flush();
		}
	}
}

Measured memory_bytes: 20380
import java.util.*;
import java.util.Map;
import java.util.TreeMap;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();

        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
            if(map.containsKey(B[i])){
                map.put(B[i], map.get(B[i]) + A[i]);
            }
            else{
                map.put(B[i], A[i]);
            }
        }
        int sum = 0;
        for(int key : map.keySet()){
            sum += map.get(key);
            if(sum>key){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

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

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using namespace std;


int main (void) 
{

  /* Variable_Proclamation */
  string S;    // input
  char ans;    // output

  int  i;    // subscript
  char char_cnt;
  int  place;


  /* Input, Array_Proclamation */
  cin >> S;
  set<char> alp;


  /* Initialize */
  ans   = ' ';
  place = 0;


  /* Calculation */
  // sort( all(S) ); // sortの有無で計算量が少し変わる
  for(i=0; i<S.size(); i++)
  {
    alp.insert( S.at(i) );
  }

  for(char_cnt = 'a';  char_cnt <= 'z';  char_cnt++)
  {

    // for(i=0; i<alp.size(); i++)
    // {
      if( !(alp.count(char_cnt)) )
      {
        ans = char_cnt;
        goto ENDLOOP;
      }
    // }

  }
  ENDLOOP:
  

  /* Output */
  if(ans != ' ')
  {
    cout << ans << endl;
  }
  else
  {
    cout << "None" << endl;
  }
  


  return 0;

}


Measured memory_bytes: 512
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2,tune=native")

#include <x86intrin.h>
#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int cnt0 = 0, cnt1 = 0;
    for (int i = 0; i < s.length(); i++) (s[i] == '1') ? cnt1++ : cnt0++;
    cout << 2 * min(cnt0, cnt1);
    return 0;
}

Measured memory_bytes: 512
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    std::string s;
    std::cin >> s;
    std::cout << s.front() << s.length()-2 << s.back() << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

std::vector<long long> primearray(long long N){
    std::vector<long long> R;
    std::vector<bool> prime;
    for(int i=0;i<=N;i++){
        prime.push_back(true);
    }
    if(N<2){
        return R;
    }
    prime[0]=false;
    prime[1]=false;
    for(long long i=2;i*i<=N;i++){
        if(!prime[i])continue;
        for(int j=2*i;j<=N;j+=i){
            prime[j]=false;
        }
    }
    for(long long i=0;i<prime.size();i++){
        if(prime[i]){
            R.push_back(i);
        }
    }
    return R;
}

long long inverse(long long b){
    long long r=1,e=MOD-2;
    while(e){
        if(e&1){
            r=(r*b)%MOD;
        }
        b=(b*b)%MOD;
        e >>=1;
    }
    return r;
}

signed main(void){
    int N;
    int A[14514];
    int Amax=0;
    cin >> N;
    REP(i,N){
        cin >> A[i];
        Amax=max(Amax,A[i]);
    }
    vector<int> F = primearray(Amax+1);
    //まず十分な素数を入手する
    map<int,int> mp;
    REP(i,F.size()){
        mp[F[i]]=i;
    }
    vector<int> M;
    //実質的なLCMはこいつ　要素がすべて素数であれば積として表される数は一意に定まる
    //さらに扱いやすいように常にソート済みであるとする
    
    REP(j,N){
        vector<int> P;
        int k = A[j];
        while(k>1){
            bool c=false;
            for(int i=2;i*i<=k;i++){
                if(k%i==0){
                    P.push_back(i);
                    k/=i;
                    c=true;
                    break;
                }
            }
            if(c==false){
                P.push_back(k);
                k=1;
            }
        }
        //Pの素因数分解ができた　Mと同様の方法で数を表現している
        //これからlcm(P,M)を求める
        vector<int> m = M;
        M.clear();
        int mi=0,pi=0;
        while(mi<m.size() && pi<P.size()){
            if(m[mi]==P[pi]){
                M.push_back(m[mi]);
                mi++;pi++;
            }else if(m[mi]<P[pi]){
                M.push_back(m[mi]);
                mi++;
            }else{
                M.push_back(P[pi]);
                pi++;
            }
        }
        while(mi<m.size()){
            M.push_back(m[mi]);
            mi++;
        }
        while(pi<P.size()){
            M.push_back(P[pi]);
            pi++;
        }
        //lcmが求まった
    }
    
    //ここまで来ると素数であることの強みはないのでMODにしちゃう
    int LCM=1;
    REP(i,M.size()){
        LCM*=M[i];
        LCM%=MOD;
    }
    //MOD下でLCMが求まったらウィニングラン
    
    int Ans=0;
    REP(i,N){
        int Ainv = inverse(A[i]);
        int R = Ainv * LCM;
        R%=MOD;
        Ans+=R;
        Ans%=MOD;
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 6008
#include <iostream>
#include <string>

using namespace std;

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

	int sum = 0;
	for (int i = 0; i < 3; ++i) {
		sum += s[i] - 48;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,i,j;
  cin >> n;
  for(i=1;i<10;i++){
    for(j=1;j<10;j++){
    if(n==i*j){
      cout << "Yes" << endl;
      return 0;
    }
    }
  }
 cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <iostream>

#define MAX_WH 100

using namespace std;

void solve();
void dfs(int x, int y);

int W,H,count;
char field[MAX_WH][MAX_WH+1];

int main()
{
    while (1) {
        cin>>H>>W;
        if (W==0&&H==0) break;
        for (int i=0; i<H; i++) cin>>field[i];
        solve();
    }
    return 0;
}

void solve()
{
    count=0;
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (field[i][j]!='.') {
                dfs(i,j);
                count++;
            }
        }
    }
    cout<<count<<endl;
}

void dfs(int x, int y)
{
    char s=field[x][y];
    field[x][y]='.';
    
    if (x-1>=0&&field[x-1][y]==s) dfs(x-1,y);
    if (y-1>=0&&field[x][y-1]==s) dfs(x,y-1);
    if (x+1<H&&field[x+1][y]==s) dfs(x+1,y);
    if (y+1<W&&field[x][y+1]==s) dfs(x,y+1);
}

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

int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (m1 != m2) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int h, w, n, a, j = 0, k;
    cin >> h >> w >> n;
    vector<int> c;
    for(int i = 1; i <= n; i++){
        scanf("%d", &a);
        while(a-- > 0) c.push_back(i);
    }
    for(int i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            k = c[i*w + (i % 2 == 0 ? j : w - 1 - j)];
            printf("%d%c", k, (j != w - 1 ? ' ' : '\n'));
        }
    }
    return 0;
}

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

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

    ll minv = *min_element(a, a + 5);
    ll ans = 5 + (n - 1) / minv;

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


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

#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

struct UnionFind {
	vector<int> p, r;

	UnionFind() {}
	UnionFind(int size) { init(size); }

	void init(int size) {
		p.resize(size);
		r.resize(size);
		for (int i = 0; i < size; ++i) {
			p[i] = i; r[i] = 1;
		}
	}

	int find(int x) {
		if (p[x] == x) return x;
		else return p[x] = find(p[x]);
	}

	void unite(int x, int y) {
		x = find(x); y = find(y);

		if (x == y) return;

		if (r[x] > r[y]) swap(x, y);
		r[x] += r[y];
		p[y] = x;
	}

	bool is_root(int x) {
		return find(x) == x;
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	int element_count(int x) {
		x = find(x);
		return r[x];
	}
};

int main() {
	int n;

	while (cin >> n, n) {
		UnionFind uf(n * n);
		rep(i, n) rep(j, n) {
			int x = in(), y = in();
			
			int u = y * n + x;
			int v = i * n + j;

			uf.unite(u, v);
		}

		int ans = 0;
		bool f[10000] = {false};
		rep(i, n * n) {
			if (f[uf.find(i)]) continue;
			f[uf.find(i)] = true;
			ans++;
		}

		print(ans);
	}
}

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

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

  for (char c='a'; c<='z'; c++) {
    bool flag=true;
    for (const auto &x: s) {
      if (c==x) flag=false;
    }
    if (flag) {
	cout<<c<<endl;
	return 0;
    }
  }
  cout<<"None"<<endl;
  return 0;
}

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

int main(){
  int n,count = 0;
  cin >> n;

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

  for(int i=1; i < n-1; ++i){
    if((p[i-1]<p[i] && p[i] < p[i+1]) || (p[i+1]<p[i] && p[i] < p[i-1]))
    ++count;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
  string s,t;
  int i,j;
  j = 0;
  
  cin >> s >> t;
  
  for(i = 0; i < 3;i++)
  {
    if(s[i] == t[i])
      j++;
  }
  cout << j;
}

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

int main(){
  int n,i,kosuu=0,min=1000000001,max=-1000000001;
  cin >> n;
  long int a[n],kotae=0;
  for(i=0;i<n;i++){
    cin >> a[i];
    kotae+=a[i];
    if(a[i]<0){
      kosuu++;
      kotae-=2*a[i];
      a[i]=(-1)*a[i];
    }
    if(a[i]<min){
      min=a[i];
    }
  }
  kotae=kotae-2*(kosuu%2)*min;
  printf("%ld",kotae);
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <cstdio>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

char a,b,c,d;
char op1,op2,op3;

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

    for(ll bit=0;bit<(1LL<<3);++bit){
        bool x[3];
        fill(x,x+3,false);
        for(ll i=0;i<3;++i){
            if(bit&(1<<i)){
                x[i]=true;
            }
        }

        ll a[4];
        for(ll i=0;i<4;++i){
            a[i]=s[i]-'0';
        }

        ll count=a[0];
        for(ll i=0;i<3;++i){
            if(x[i]){
                count+=a[i+1];
            }else{
                count-=a[i+1];
            }
        }

        if(count==7){
            cout<<a[0];
            for(ll i=0;i<3;++i){
                if(x[i]){
                    cout<<'+';
                }else{
                    cout<<'-';
                }
                cout<<a[i+1];
            }
            cout<<"=7"<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
import queue
n, m = map(int, input().split())
a = [[] for _ in range(n)]
ans = 0
 
for _ in range(m):
    x, y = map(int, input().split())
    a[x-1].append(y-1)
    a[y-1].append(x-1)
 
route = set()
route.add(0)
q = queue.Queue()
q.put(0)
 
for i in range(n):
    if not i in route:
        route.add(i)
        q.put(i)
        ans += 1
    while not q.empty():
        c = q.get()
        for k in a[c]:
            if not k in route:
                q.put(k)
                route.add(k)
    if len(route) == n:
        print(ans)
        break

Measured memory_bytes: 31904
mod = 10**9 + 7
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i+1, N):
        if A[i] > A[j]:
            ans += 1
ans2 = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            ans2 += 1

d = ans2
l = ans + ans2 * (K-1)
print(((2*ans + (K-1)*d)*K//2)%mod)


Measured memory_bytes: 41836
#include<stdio.h>

#define N 1000

int main(){
  int i,heap[N],n;

  for(i=0;i<N;i++) heap[i] = NULL;
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%d",&heap[i]);
  }

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,heap[i]);
    if(heap[i/2] != NULL) printf("parent key = %d, ",heap[i/2]);
    if(2*i <=n && heap[i*2]!=NULL) printf("left key = %d, ",heap[2*i]);
    if(2*i+1<=n && heap[i*2]!=NULL) printf("right key = %d, ",heap[2*i+1]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


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

	vector<pair<char, int>> v;

	char last = s[0];
	int cnt = 1;
	for (int i = 1; i < s.size(); i++) {
		if (s[i] == last) {
			cnt++;
		}
		else {
			v.push_back(make_pair(last, cnt));
			last = s[i];
			cnt = 1;
		}
	}
	v.push_back(make_pair(last, cnt));

	int ans = 0;
	for (int i = 1; i < v.size() - 1; i++) {
		if (v[i - 1].first == 'J' && v[i].first == 'O' && v[i + 1].first == 'I') {
			if (v[i - 1].second >= v[i].second && v[i].second <= v[i + 1].second) {
				ans = max(ans, v[i].second);
			}
		}
	}

	cout << ans << endl;

	return 0;
}



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

int main(){
	int i, N_num_permutation, num_satisfied=0;
	cin >> N_num_permutation;
	vector<int> P_permutation_input(N_num_permutation);
	priority_queue<int> P_permutation_queue;
	
	// まずvectorのみに格納する
	for(i=0;i<N_num_permutation;i++){
		cin >> P_permutation_input.at(i);
	}
	
	// i=0の時は常にPi=Pjなので，1を追加
	num_satisfied++;
	P_permutation_queue.push(-P_permutation_input.at(0));
	for(i=1;i<N_num_permutation;i++){
		// priority_queueにpush
		P_permutation_queue.push(-P_permutation_input.at(i));
		if(P_permutation_input.at(i)==-P_permutation_queue.top()){
			num_satisfied++;
		}
	}
	
	cout << num_satisfied << endl;
	
}

/*
int main(){
	int i, N_num_permutation, num_satisfied=0;
	cin >> N_num_permutation;
	vector<int> P_permutation_input(N_num_permutation),
				P_permutation_input_dummy(N_num_permutation-1);
	priority_queue<int> P_permutation_queue;
	for(i=0;i<N_num_permutation-1;i++){
		cin >> P_permutation_input.at(i);
		P_permutation_queue.push(-P_permutation_input.at(i));
		P_permutation_input_dummy.at(i) = P_permutation_input.at(i);
	}
	cin >> P_permutation_input.at(N_num_permutation-1);
	
	for(i=N_num_permutation-1;i>0;i--){
		if(*min_element(P_permutation_input_dummy.begin(),P_permutation_input_dummy.end())
			>=P_permutation_input.at(i)){
			num_satisfied++;
		}
		P_permutation_input_dummy.erase(P_permutation_input_dummy.begin()+i-1);
	}
	num_satisfied++;
	
	cout << num_satisfied << endl;
	
	return 0;
}
*/


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n), c(n);
  for (int i = 0; i < n; i ++) cin >> v[i];
  for (int i = 0; i < n; i ++) cin >> c[i];
  int sum = 0;
  for (int i = 0; i < n; i ++) {
    if (v[i] > c[i]) {
      sum += v[i] - c[i];
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
d = dict(AC=0, WA=0, TLE=0, RE=0)
for i in range(n):
  s = str(input())
  if s == 'AC':
    d['AC'] += 1
  elif s == 'WA':
    d['WA'] += 1
  elif s == 'TLE':
    d['TLE'] += 1
  elif s == 'RE':
    d['RE'] += 1

print('AC x ' + str(d['AC']))
print('WA x ' + str(d['WA']))
print('TLE x ' + str(d['TLE']))
print('RE x ' + str(d['RE']))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
int main() {
   string s;
   cin >>s;
   int n=0;
   for(int i=0;i<1000000;i++){
       if(s[i]=='L' || s[i]=='D' || s[i]=='U' || s[i]=='R'){
           n++;
       }
       else
       break;
   }
   int f=0;
for(int i=0;i<n;i++){
if(i%2==1 && s[i]=='R')
f=1;
if(i%2==0 && s[i]=='L')
f=1;
}
if(f==1)
cout << "No" << endl;
else
cout << "Yes" << endl;
    return 0;
}


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;
using P = pair<int,int>;
const int INF = 100100100;

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());
    vector<int> d;
    rep(i,x) d.push_back(p[i]);
    rep(i,y) d.push_back(q[i]);
    rep(i,c) d.push_back(r[i]);
    sort(d.rbegin(), d.rend());
    ll ans = 0;
    rep(i, x+y) ans += d[i];

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

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define pi pair<int,int>
using namespace std;
int main(){
	int n ;
	cin>> n ; 
	vector<ll> a(n) ; 
	for(ll & x: a) cin>> x ; 
	vector<ll> dp(n) ;
	dp[0] = 0 ; 
	dp[1] = abs(a[1] -a[0]) ; 
	for(int i = 2 ; i < n ; ++i){
		dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]) ,  dp[i-2] + abs(a[i] - a[i-2])) ; 
	}
	if(n == 2 )
		cout<<a[1] - a[0]<<endl;
		else 
	   cout<<dp[n-1]<<endl;
	   
   }


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

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int N, Q;
string S;
int l[100010], r[100010];
int sum[100010];
void solve() {

	cin >> N >> Q >> S;
	for (int i = 0; i < Q; i++) {
		cin >> l[i] >> r[i];
		l[i]--;
		r[i]--;
	}

	int cnt = 0;
	for (int i = 1; i < N; i++) {
		string tmp = S.substr(i - 1, 2);
		if (tmp == "AC") cnt++;
		sum[i] = cnt;
	}

	for (int i = 0; i < Q; i++) {
		cout << sum[r[i]] - sum[l[i]] << endl;
	}


	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 2256
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#define ll long long
#define MAXN 200005
using namespace std;
ll Sp[MAXN],Ss[MAXN],data[MAXN],Ans=2e9,tmp;
int N;
int main()
{
	int i;
	
	scanf("%d",&N);
	
	for(i=1;i<=N;i++)scanf("%lld",&data[i]);
	for(i=1;i<=N;i++)Sp[i]=Sp[i-1]+data[i];
	for(i=N;i;i--)Ss[i]=Ss[i+1]+data[i];
	
	for(i=1;i<N;i++)
	{
		tmp=Sp[i]>Ss[i+1]?Sp[i]-Ss[i+1]:Ss[i+1]-Sp[i];
		Ans=min(Ans,tmp);
	}
	printf("%lld",Ans);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
const double pi = 3.14159265359;
const double eps = 0.00000001;

bool vis[MAXN];
int color[MAXN];
vector<vector<ii>> g;
int n;

void dfs(int node, int cur) {
    vis[node] = 1;
    color[node] = cur;
    for (ii e : g[node]) {
        if (!vis[e.F]) {
            dfs (e.F, cur ^ e.S);
        }
    }
}

int32_t main() {

    $
    
    cin >> n;

    g.assign(n + 1, vector<ii>());

    int u, v, w;

    forn (1, n) {
        cin >> u >> v >> w;
        w &= 1;
        g[u].push_back({v, w});
        g[v].push_back({u, w});
    }

    dfs(1, 0);

    forn (1, n + 1) {
        cout << color[i] << '\n';
    }
    
}

Measured memory_bytes: 7552