akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i, count) for(int i = 0; i < (count); i++)
#define REPR(i, first, last) for(int i = (first); i < (last); i++)
 
int solve(int n){
 
}
 
 
int main(){
	int n; cin >> n;
	int h[100001]; REP(i, n)cin >> h[i];
	ll cost[100001] = {0, abs(h[0]-h[1])};
	REPR(i, 2, n){
		cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]));	
	}
	cout << cost[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#define PIE 3.14159265358979
#define MAX_N 16
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0;i < (n);i++)
#define show(x) cout<<(#x)<<":"<<x<<" ";
#define showl(x) cout<<(#x)<<":"<<x<<endl;

using namespace std;
typedef long long ll;

template<typename T>
struct ConvexHullTrick{
private:
    vector<pair<T,T> > lines;
public:
    T calc(pair<T,T> p,T x){
        return p.first*x+p.second;
    }
    
    bool dodo(pair<T,T> A,pair<T,T> B,pair<T,T> C){
        bool ret = (B.second-A.second)*(B.first-C.first) >= (C.second-B.second)*(A.first-B.first);
        return ret;
    }
    
    void add(T a,T b){
        lines.pb(mp(a,b));
        int v;
        while((v=lines.size())>=3&&dodo(lines[v-3],lines[v-2],lines[v-1])){
            lines[v-2]=lines[v-1];
            lines.pop_back();
        }
    }
    
    T query(T x){
        int l = 0, r = lines.size();
        while(r-l>1){
            int mid = (l+r)/2;
            if(calc(lines[mid-1],x)>=calc(lines[mid],x))
                l=mid;
            else
                r=mid;
        }
        return calc(lines[l],x);
    }
};

int main(){
    int N;
    ConvexHullTrick<ll> ch;
    ll C;
    cin>>N>>C;
    vector<ll> dp(N,0),h(N);
    rep(i,N){
        cin>>h[i];
    }
    ll val = 0;
    for(int i = 0;i < N;i++){
//        show(i);
        if(i>0){val = ch.query(h[i])+h[i]*h[i];}
//        showl(val);
        ch.add(-2*h[i],val+h[i]*h[i]+C);
    }
    cout<<val<<endl;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] = a[i] - i - 1;
  }
  sort(a.begin(), a.end());
  int b = a[n / 2];
  for (auto x : a) {
    ans += abs(x - b);
  }
  cout << ans << endl;
}

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

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(a*a+b*b==c*c || a*a==b*b+c*c || a*a+c*c==b*b){
			cout<<"YES"<<endl;
		}
		else cout<<"NO"<<endl;
	}
}

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

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

  string s;
  cin>>s;
  int ctr=0;
  for (int i = 0; i < s.size()-1; ++i)
  {
  	if(s[i] != s[i+1])
    ctr++;
  }

  cout<<ctr;
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
 
int main(void)
{
    float x[4];
    float y[4];
    float slope1, slope2;
    int dataset;
    int i;
    scanf("%d", &dataset);
 
    while (dataset> 0){
        dataset--;
        for (i = 0; i < 4; i++){
            scanf("%f %f", &x[i], &y[i]);
        }
         
        slope1 = (y[1] - y[0]) / (x[1] - x[0]);
        slope2 = (y[3] - y[2]) / (x[3] - x[2]);
         
        if (slope1 == slope2){
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }
 
    return 0;
}

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

int main() {
  //int N,K;
  int S;
  cin >> S;
  //vector<int> l(N);

  /*for (int i=0; i<N; i++) {
    cin >> l[i];
  }*/
  
  int l=S/100;
  int r=S%100;
  
  if (l>0 && l<13) {
    if (r>0 && r<13) {
      cout << "AMBIGUOUS" << endl;
    }
    else {
      cout << "MMYY" << endl;
    }
  }
  else {
    if (r>0 && r<13) {
      cout << "YYMM" << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
  
  return 0;
    
      
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    ll h,w;cin>>h>>w;
    string s[h];rep(i,0,h-1)cin>>s[i];
    ll dp[h][w];memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    rep(i,0,h-1){
        rep(j,0,w-1){
            if(i+1<=h-1&&s[i+1][j]=='.')Add(dp[i+1][j],dp[i][j]);
            if(j+1<=w-1&&s[i][j+1]=='.')Add(dp[i][j+1],dp[i][j]);
        }
    }
    cout<<mod(dp[h-1][w-1])<<endl;
    
    return 0;
}



Measured memory_bytes: 9088
import java.util.Scanner;

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

		int n = sc.nextInt();

		int cntEven = 0;
		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			if (tmp % 2 == 0)
				cntEven++;
		}

		int ans = (int) Math.pow(3, n) - (1 << cntEven);

		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 23892
int main(){
  int a,s=0;
  scanf("%d\n",&a);
  char b[50];
  scanf("%s",b);
  for(int i=0;i<a-2;i++){
    if(b[i]=='A'&&b[i+1]=='B'&&b[i+2]=='C') s++;
  }
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 128
import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) throws IOException {
		try (AtCoderReader ar = new AtCoderReader()) {
			ar.nextLine();
			int[] A = ar.nextIntArray();

			List<Point> list = new ArrayList<>();

			int max = Arrays.stream(A).max().getAsInt();
			int min = Arrays.stream(A).min().getAsInt();
			if (min >= 0 || max <= 0) {
				// aが非負整数の場合または、すべて負の整数の場合は何もしない
			} else {
				if (Math.abs(max) >= Math.abs(min)) {
					addAll(A, max, list);
				} else {
					addAll(A, min, list);
				}

				min = Arrays.stream(A).min().getAsInt();
			}

			if (min >= 0) {
				for (int i = 1; i < A.length; i++) {
					while (A[i - 1] > A[i]) {
						A[i] += A[i - 1];
						list.add(new Point(i - 1, i));
					}
				}
			} else {
				for (int i = A.length - 2; i >= 0; i--) {
					while (A[i] > A[i + 1]) {
						A[i] += A[i + 1];
						list.add(new Point(i + 1, i));
					}
				}
			}

			System.out.println(list.size());
			list.stream().map(p -> (p.x + 1) + " " + (p.y + 1)).forEachOrdered(System.out::println);;
		}
	}

	private static void addAll(int[] A, int value, List<Point> list) {
		int valueAt = valueAt(A, value);
		for (int i = 0; i < A.length; i++) {
			if (i != valueAt) {
				A[i] += value;
				list.add(new Point(valueAt, i));
			}
		}
		A[valueAt] += value;
		list.add(new Point(valueAt, valueAt));
	}

	private static int valueAt(int[] A, int value) {
		for (int i = 0; i < A.length; i++) {
			if (A[i] == value) {
				return i;
			}
		}
		throw new IllegalArgumentException("value[" + value + "] was not found arrays");
	}

	public static class AtCoderReader implements AutoCloseable {
		private final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		public final String[] nextStringArray() throws IOException {
			return this.br.readLine().split(" ");
		}

		public final Stream<String> nextStream() throws IOException {
			return Stream.of(this.nextStringArray());
		}

		public final IntStream nextIntStream() throws NumberFormatException, IOException {
			return this.nextStream().mapToInt(Integer::parseInt);
		}

		public final int[] nextIntArray() throws IOException {
			return this.nextIntStream().toArray();
		}

		public final int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(nextLine());
		}

		public final String nextLine() throws IOException {
			return this.br.readLine();
		}

		@Override
		public final void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 29012
#include<iostream>
 using namespace std ;
 int main()
{
short int c=0;
char s[3];

cin>>s;

if(((s[0]=='a')&&(s[1]=='b')&&(s[2])=='c')||
  ((s[0]=='a')&&(s[1]=='c')&&(s[2])=='b')||
  
((s[0]=='b')&&(s[1]=='a')&&(s[2])=='c')||
((s[0]=='b')&&(s[1]=='c')&&(s[2])=='a')||

((s[0]=='c')&&(s[1]=='b')&&(s[2])=='a')||
((s[0]=='c')&&(s[1]=='a')&&(s[2])=='b'))

 cout<<"Yes";
else
cout<<"No";

}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> p(n+1,0);
    for(int i=1;i<=n;i++){
        cin>>p[i];
    }
    vector<double> sum(n+1,0);
    for(int i=1;i<=n;i++){
        sum[i]+=(1+p[i])/2.0+sum[i-1];
    }
    double ans=0;
    for(int i=0;i+k<=n;i++){
        ans=max(ans,sum[k+i]-sum[i]);
    }
    printf("%.6lf\n",ans);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


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

  vector<int> x(N);
  vector<int> y(N);
  vector<int> h(N);

  int tmp;
  REP(i, N){
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] != 0) tmp = i;
  }

  for (int cx = 0; cx <= 100; cx++) {
    for (int cy = 0; cy <= 100; cy++) {
      int H = h[tmp] + abs(cx - x[tmp]) + abs(cy - y[tmp]);
      bool flag = true;
      for (int i = 0; i < N; i++) {
        if (max(H - abs(cx - x[i]) - abs(cy - y[i]), 0) != h[i]) {
          flag = false;
          break;
        }
      }
      if (flag) {
        cout << cx << ' ' << cy << ' ' << H << endl;
      }
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define method(name,res,...) function<res (__VA_ARGS__) > name = [&](__VA_ARGS__) -> res
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  string str = in<string>();
  cout << str.substr(0,3) << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
int main(void){
    
    int W,H,x,y,r;
    scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
    
    if(0 <= x-r&&x+r <= W&&0 <= y-r&&y+r <= H)
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
    
}



Measured memory_bytes: 2104
#from numpy import* #import numpy as np
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) #dijkstra #floyd_warshall
#from scipy.sparse import csr_matrix

from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！


def main():
    n,*a=map(int,open(0).read().split())
    def f(a):
        q=a[:n];s=sum(q);heapify(q);yield s
        for e in a[n:2*n]:
            s+=e-heappushpop(q,e);yield s
    print(max(map(sum,zip(f(a),list(f([-e for e in a[::-1]]))[::-1]))))
if __name__ == '__main__':
    main()

Measured memory_bytes: 41952
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int result = 0;
    
    if(a <= k) {
        result += a;
        k -= a;
    }
    else {
        result += k;
        k = 0;
    }
    
    if(b <= k) {
        k -= b;
    }
    else {
        k = 0;
    }
    
    if(c <= k) {
        result -= c;
        k -= c;
    }
    else {
        result -= k;
    }
    
    cout << result << "\n";
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

int a[200010];
int b[200010];
int main()
{
    int n;
    cin >> n;
    REP(i, n)
        cin >> a[i];
    vector<vector<ll>> v(n+1);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j * j <= i; j++)
        {
            if (i % j==0){
                v[i].push_back(j);
                if (j * j != i)
                    v[i].push_back(i / j);
            }
        }

    }
    ll s = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        b[i] = a[i];
        if(a[i]==1){
        for (auto u:v[i+1]){
            a[u - 1]++;
            a[u - 1] %= 2;
        }
        }
    }
    ll cnt = 0;
    vector<int> w;
    for (int i = 0; i < n; i++)
    {
        if(b[i]==1){
            w.push_back(i + 1);
        }
    }
    if(w.size()==0){
        cout << 0 << endl;
        return 0;
    }
    cout << w.size() << endl;
    for (int i = 0; i < w.size(); i++)
    {
        cout << w[i] << " ";
    }
    cout << endl;

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

    return 0;
}

Measured memory_bytes: 34424
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,sum;
    sum=0;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
        sum += a[i];
    }
    cout << sum-N << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int r {0},D{0};
    int X0 {0};
    int new_x {0};

    cin >> r >> D >> X0;

    for (int i{1}; i <= 10; ++i) {
            new_x = r*X0 - D;
            cout << new_x << endl;
            X0 = new_x;
    }

    return 0;
}


Measured memory_bytes: 888
#!/usr/bin/env python

w, h, n = map(int, input().split())
x = [0 for _ in range(n)]
y = [0 for _ in range(n)]
a = [0 for _ in range(n)]
for i in range(n):
    x[i], y[i], a[i] = map(int, input().split())

masu = [['W' for _ in range(w)] for _ in range(h)]

for i in range(n):
    if 1 == a[i]:
        for j in range(h):
            for k in range(x[i]):
                masu[j][k] = 'B' 
    if 2 == a[i]:
        for j in range(h):
            for k in range(x[i], w): 
                masu[j][k] = 'B' 
    if 3 == a[i]:
        for k in range(y[i]):
            masu[k] = ['B' for _ in range(w)]
    if 4 == a[i]:
        for k in range(y[i], h): 
            masu[k] = ['B' for _ in range(w)]

ans = 0 
for i in range(len(masu)):
    ans += masu[i].count('W')
    # print(masu[i])

print(ans)


Measured memory_bytes: 9260
# -*- coding: utf-8 -*-
n,q = map(int, input().split())
s = input()
td = [input().split() for _ in range(q)]

l = 0
r = n - 1
for i in range(q-1,-1,-1):
    t,d = td[i]

    if n>l>=0:
        if s[l]==t and d=="L":
            l += 1
        elif l>0 and s[l-1]==t and d=="R":
            l -= 1

    if n>r>=0:
        if s[r]==t and d=="R":
            r -= 1
        elif r<n-1 and s[r+1]==t and d=="L":
            r += 1

print(n - l - (n-1-r))


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



 
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.in","w",stdout);
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int i,j,k;
    cin>>k;
    while(k--)cout<<"ACL";
    

   		
 
 
 
 
 
 
 
	return 0;
}

Measured memory_bytes: 3640
# -*- coding: UTF-8 -*-
import sys
import re
import math
import itertools
import collections
import bisect
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.141592653589
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else  a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b/gcd(a,b)
def eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
def pscl(num,l=[1]):
    for i in range(num):
        l = map(lambda x,y:x+y,[0]+l,l+[0])
    return l

class UnionFind:
    def __init__(self, size):
        self.rank=[0]*size
        self.par =range(size)
        self.grp =size

    def find(self, x):
        if x==self.par[x]: return x

        self.par[x]=self.find(self.par[x])
        return self.par[x]

    def same(self, x, y): #2つの頂点が同じグループであるかを判定する
        return self.find(x)==self.find(y)

    def unite(self, x, y): #辺で接続されている2つの頂点を投げて統合する
        x,y=self.find(x),self.find(y)
        if x==y:
            return

        self.grp-=1
        if self.rank[x]<self.rank[y]:
            self.par[x]=y
        else:
            self.par[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def group_num(self):
        return self.grp
    def ra(self):
        return self.par

n,k,l=map(int,raw_input().split())
uf=UnionFind(n)
uf2=UnionFind(n)
ans=[1]*n

for i in range(k):
    a,b=map(int,raw_input().split())
    uf.unite(a-1,b-1)

for i in range(l):
    a,b=map(int,raw_input().split())
    uf2.unite(a-1,b-1)

q1=uf.ra()
q2=uf2.ra()
d={}
for i in range(n):
    while 1:
        if q1[i]!=q1[q1[i]]:
            q1[i]=q1[q1[i]]
        else:
            break
    while 1:
        if q2[i]!=q2[q2[i]]:
            q2[i]=q2[q2[i]]
        else:
            break

for i in range(n):
    if (q1[i],q2[i]) in d:
        d[(q1[i],q2[i])]+=1
    else:
        d[(q1[i],q2[i])]=1
for i in range(n):
    print d[(q1[i],q2[i])],

Measured memory_bytes: 93980
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: i64 = sc.get();
    let mut ans = N - 1;
    for i in (2..).take_while(|i| i * i <= N) {
        if N % i == 0 {
            ans = min(ans, i-1+N/i-1);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void){
    int n,c; cin>>n>>c;
    ll ans = INF;
    vector <vector<int>> d(c ,vector <int>(c ));
    vector <vector<int>> col(n ,vector <int>(n ));
    vector <vector<int>> nc(3 ,vector <int>(c ));  //あまり/カラー
    for(int i=0;i<c;i++){
        for(int j=0;j<c;j++){
            cin>>d[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>col[i][j];
            col[i][j]--;
            nc[(i+j)%3][col[i][j]]++;
        }
    }
    
    for(int i=0;i<c;i++){
        for(int j=0;j<c;j++){
            if(i==j) continue;
            for(int k=0;k<c;k++){
                if(!(i!=j&&j!=k&&i!=k)) continue;
                ll cost = 0;
                for(int l=0;l<c;l++){
                    cost += nc[0][l]*d[l][i];
                }
                
                for(int l=0;l<c;l++){
                    cost += nc[1][l]*d[l][j];
                }
                
                for(int l=0;l<c;l++){
                    cost += nc[2][l]*d[l][k];
                }
                chmin(ans, cost);
                
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
// URDL
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
long long mod = 1e9+7;
//

int main(){
  int n, k; cin >> n >> k;
  if(k == 1) {
    cout << 0 << endl;
    return 0;
  }
  cout << n - k << endl;
  return 0;
}




// EOF


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

int main()
{
    int N;
    cin >> N;
    vector<int> adj[N];
    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int C[N];
    for (int i = 0; i < N; i++) cin >> C[i];
    sort(C, C + N);
    reverse(C, C+N);

    long long M = 0;
    for (int i = 1; i < N; i++) M += C[i]; 

    cout << M << endl;

    // get leaf
    int node;
    for (int i = 0; i < N; i++)
    {
        if (adj[i].size() == 1)
        {
            node = i;
            break;
        }
    }

    int ans[N];
    for (int i = 0; i < N; i++) ans[i] = -1;
    int i = 0;
    // ans[node] = C[i];
    queue<int> que;
    que.push(node);
    while (que.size() > 0)
    {
        node = que.front(); que.pop();
        ans[node] = C[i];
        i++;
        for (auto next_node: adj[node])
        {
            if (ans[next_node] != -1) continue;
            que.push(next_node);
        }
    }
    for (int j = 0; j < N; j++)
        cout << ans[j] << ' ';
    cout << endl;
  	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 100010
#define D 60
ll n,x[N],m,k;
ll dist[N];

typedef struct jun{
	ll p[N];
}jun;
jun merge(jun a,jun b){
	jun c;
	rep(i,n-1)c.p[i]=b.p[a.p[i]];
	return c;
}
jun po[60];

int main(){
	cin>>n;
	rep(i,n)cin>>x[i];
	ll value[N];
	rep(i,n-1)value[i]=i;
	cin>>m>>k;
	rep(i,m){
		ll a; cin>>a; a--;
		swap(value[a-1],value[a]);
	}
	rep(i,n-1)po[0].p[value[i]]=i;
	for(int d=1;d<60;d++){
		po[d]=merge(po[d-1],po[d-1]);
	}
	jun gen;
	rep(i,n-1)gen.p[i]=i;
	for(int d=0;d<60;d++){
		if(k&1)gen=merge(gen,po[d]);
		k>>=1;
	}
	rep(i,n-1)dist[gen.p[i]]=x[i+1]-x[i];
	for(int i=1;i<n;i++)x[i]=x[i-1]+dist[i-1];
	rep(i,n)cout<<x[i]<<endl;
}





Measured memory_bytes: 55936
#include <iostream>
#include <map>

using namespace std;

int main() {
  int n;
  map<string, int> map;
  cin>>n;
  for (int i=0; i<n; i++) {
    string str;
    cin>>str;
    map[str] = 1;
  }
  cout<<map.size()<<endl;
  return 0;
}


Measured memory_bytes: 19204
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w", stdout);
    // #endif
  int n; cin>>n;
  ll sum=0;
  for(int i=1;i<=n;i++){
    if(i%3==0||i%5==0)
      continue;
    sum+=i;
  }
  cout<<sum<<"\n";
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
struct node{
	string ss;
	int num;
};
bool cmpp(struct node x,struct node y)
{
	if(x.num!=y.num)
	{
		return x.num>y.num;
	}
	else
	{
		return x.ss<y.ss;
	}
}
int main()
{
	int n,i;
	cin>>n;
	string s[n+1];
	for(i=1;i<=n;i++)
	{
		cin>>s[i];
	}
	sort(s+1,s+n+1);
/*	for(i=1;i<=n;i++)
	{
		cout<<s[i];
	}*/
	struct node a[n+1];
	a[1].ss=s[1];
	a[1].num=1;
	int k=1;
	for(i=2;i<=n;i++)
	{
		if(s[i]==a[k].ss)
		{
			a[k].num++;
		}
		else
		{
			k++;
			a[k].ss=s[i];
			a[k].num=1;
		}
	}
	sort(a+1,a+k+1,cmpp);
	i=1;
	while(a[i].num==a[1].num&&i<=n)
	{
		i++; 
	}
	i--;
	for(int j=1;j<=i;j++)
	{
		cout<<a[j].ss<<endl;
	}
	return 0;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define f first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
typedef long long ll ;
typedef long double ld ;
typedef long long int lli;

using namespace std;
//reference: geeks
ll mult(ll a,ll b, ll p=mod){	return ((a%p)*(b%p))%p;	}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll sub(ll a, ll b, ll p=mod){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
#define INF 10000000000

ll n,m;
vector<ll>v[100005];
bool vis[100005];
ll dist[100005];
ll dfs(ll cur)
{
	if(vis[cur])	return dist[cur];
	
	vis[cur]=1;
	
	for(auto i:v[cur])
	{
		dist[cur]=max(dist[cur],dfs(i)+1);
	}
	return dist[cur];
}
int main()
{
	ios
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		ll x,y;
		cin>>x>>y;
		v[x].pb(y);
	}
	ll mx=0;
	for(int i=1;i<=n;i++)
		mx=max(mx,dfs(i));		
	cout<<mx;
}



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

using namespace std;

int w, d, n, x[105][105];
long long ans;
priority_queue<pair<pair<int, int>, pair<int, int>>> q;

int main() {
	scanf("%d%d%d", &w, &d, &n);
	for (int i = 1; i <= w; i++)
		for (int j = 1; j <= d; j++) 
			x[i][j] = INT_MIN;
	while (n--) {
		int ta, tb, tc;
		scanf("%d%d%d", &ta, &tb, &tc);
		q.emplace(make_pair(tc, 1), make_pair(ta, tb));
	}
	while (!q.empty()) {
		auto ta = q.top().first;
		auto tb = q.top().second;
		q.pop();
		if (tb.first < 1 || tb.second < 1 || tb.first > w || tb.second > d)
			continue;
		if (x[tb.first][tb.second] == INT_MIN) {
			// printf("%d %d  %d\n", tb.first, tb.second, ta.first);
			ans += ta.first;
			x[tb.first][tb.second] = ta.first;
			q.emplace(make_pair(ta.first - 1, 0), make_pair(tb.first + 1, tb.second));
			q.emplace(make_pair(ta.first - 1, 0), make_pair(tb.first - 1, tb.second));
			q.emplace(make_pair(ta.first - 1, 0), make_pair(tb.first, tb.second + 1));
			q.emplace(make_pair(ta.first - 1, 0), make_pair(tb.first, tb.second - 1));
			continue;
		}
		if (x[tb.first][tb.second] == ta.first)
			continue;
		if (x[tb.first][tb.second] == ta.first + 1 && ta.second == 0)
			continue;
		if (x[tb.first][tb.second] == ta.first + 2 && ta.second == 0)
			continue;
		// printf("%d %d  %d %d\n", tb.first, tb.second, ta.first, ta.second);
		// for (int i = 1; i <= w; i++) for (int j = 1; j <= d; j++) printf("%2d%c", x[i][j], " \n"[j == d]);
		puts("No");
		return 0;
	}
	printf("%lld\n", ans);
}



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

using namespace std;

int main() {
    int l,r,d,s=0;
    cin>>l>>r>>d;
    for(int i=l;i<=r;i++){
        if(i%d==0)
        s++;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3620
import heapq
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1):
    while (j < N) and (X[j][0] <= i):
        heapq.heappush(hq, -X[j][1])
        j += 1
    if len(hq):
        ans -= heapq.heappop(hq)

print(ans)


Measured memory_bytes: 31956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
const ll mod = 1e9 + 7;

const int N = 100 + 1;
const int SN = 100 * 100 + 1;

int a[N];
int dp[SN];

int main() {
  int n;
  cin >> n;
  int nmax = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    nmax += a[i];
  }
  memset(dp, -1, sizeof(dp));
  int ans = 0;
  for (int i = 1; i <= nmax; i++) {
    for (int j = 0; j < n; j++) {
      if (i - a[j] == 0 || ((i - a[j] >= 1) && (dp[i - a[j]] != -1) && (dp[i - a[j]] < j))) {
        dp[i] = j;
        if (i % 10) ans = i;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#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++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int a,b,c,d;cin >> a >> b >> c >> d;
    if(abs(b-a)<=d&&abs(c-b)<=d)cout << "Yes" ;
    else if(abs(c-a)<=d)cout << "Yes";
    else cout << "No" ;
    cout << endl;
}

Measured memory_bytes: 3612
array = []
loop do
  line = gets.split.map {|s| s.to_i}
  x = line[0]
  y = line[1]
  if x == 0 && y == 0 then
    break
  end
  tmp = []
  if x > y then
    tmp << y
    tmp << x
  else 
    tmp << x
    tmp << y
  end
  array << tmp
end

array.each do |line|
  puts "#{line[0]} #{line[1]}"
end

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

int main(){
    
    int N;cin>>N;
    
    queue<long>Lucas;
    
    Lucas.push(2);
    Lucas.push(1);
   
    int counter=0;
    long sml;
    long lrg;
    while(counter<N)
      
    {  sml=Lucas.front();
        Lucas.pop();
        lrg=Lucas.front();
        Lucas.push(sml+lrg);
        counter++;
        
    }
    cout<<Lucas.front()<<endl;
}
   

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

int main(){

    int N, M , xMain, yMain;
    cin >> N;
    cin >> M;
    cin >> xMain;
    cin >> yMain;

    vector<int> x(N);
    vector<int> y(M);
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    for(int i = 0; i < M; i++){
        cin >> y[i];
    }

    int xmax = *max_element(x.begin(), x.end());
    int ymin = *min_element(y.begin(), y.end());

    if(xmax < ymin && xMain <= xmax && yMain >= ymin) cout << "No War" << endl;
    else cout << "War" << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long int ll;
int main()
{
  ll c[3][3],a[4],b[4];
  for(int i=0;i<3;i++)
  for(int j=0;j<3;j++)cin>>c[i][j];

  //a1=0と仮定する
  a[1]=0,b[1]=c[0][0],b[2]=c[0][1],b[3]=c[0][2];
  a[2]=c[1][0]-b[1],a[3]=c[2][0]-b[1];

  bool ans=true;

  for(int i=0;i<3;i++)
  for(int j=0;j<3;j++)
  if(c[i][j]!=a[i+1]+b[j+1])
  {
    ans=false;
    break;
  }

  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
   int n;
   int an[100000];
   int i,ans;

   scanf("%d",&n);
   for(i=0;i<n;++i){
      scanf("%d",an+i);
   }

   for(i=0;i<n;++i){
      an[i]=an[i]-1;
   }

   ans=0;
   for(i=0;i<n;++i){
      if(an[i]>i){
         ans+=((an[an[i]]==i)?1:0);
      }
   }

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

   return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

char s[100005];
int ar[100005];


int32_t main(){
	cin>>s+1;
	int n = strlen(s+1);
	for(int i=1;i<n;i++){
		if(s[i]!=s[i+1]){
			int j = i;
			int l = 0;
			while(s[j]==s[i] && j>0){
				l++;
				j--;
			}
			/*while(s[j]!=s[i] && j>0){
				l++;
				j--;
			}*/
			int k = i+1;
			int r = 0;
			while(s[k]==s[i+1] && k<=n){
				r++;
				k++;
			}
			/*while(s[k]!=s[i+1] && k<=n){
				r++;
				k++;
			}*/
			if((r+l)&1){
				if(l&1){
					ar[i+1]=(r+l)/2;
					ar[i] = (r+l)/2+1;
				}
				else {
					ar[i] = (r+l)/2;
					ar[i+1] = (r+l)/2+1;
				}
			}
			else {
				ar[i] = ar[i+1] = (r+l)/2;
			}
			i=k-1;
		}
	}
	for(int i=1;i<=n;i++){
		cout<<ar[i]<<" ";
	}
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll a,b,k;
    cin>>a>>b>>k;
    if (a>=k)
    {
        cout<<a-k<<" "<<b<<"\n";
    }
    else
    {
        cout<<"0 "<<max((ll)0,b-(k-a))<<"\n";
    }
}


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


int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x3 - (x2 - x1);
    y4 = y3 - (y2 - y1);
    cout << x3 << " " << y3 << " " << x4  << " " << y4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;


int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-a)<=d) {
    cout<<"Yes"<<en
    RE
  } else{
    if(abs(b-a)<=d&&abs(c-b)<=d){
      cout<<"Yes"<<en
      RE
    }
  }
  cout<<"No"<<en
  RE
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string a[15];
 
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for(int i=0;i<n;i++) {
        cin >> a[i];
    }
    int ans =100000000;
    for(int mask=0;mask<(1 << (n - 1));mask++) {
        int cnt = __builtin_popcount(mask);
        int tot = cnt;
        vector<int> cur(cnt + 1, 0);
        for(int j=0;j<m;j++) {
            int p = 0;
            for(int i=0;i<n;i++) {
                cur[p] += (a[i][j] == '1');
                if ((mask >> i) & 1) {
                    p++;
                }
            }
            bool bad = false;
            for(int i=0;i<cur.size();i++) {
                if (cur[i] > k) {
                    bad = true;
                }
            }
            if (bad) {
                tot++;
                fill(cur.begin(), cur.end(), 0);
                int p = 0;
                for(int i=0;i<n;i++) {
                    cur[p] += (a[i][j] == '1');
                    if ((mask >> i) & 1) {
                        p++;
                    }
                }
                bool bad = false;
                for(int i=0;i<cur.size();i++) {
                    if (cur[i] > k) {
                        bad = true;
                    }
                }
                if (bad) {
                    tot = 100000000;
                }
            }
        }
        ans=min(ans, tot);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M;
int DP[1001][1 << 12];

int main() {
	cin >> N >> M;
	for (int i = 0; i <= M; ++i) {
		for (int j = 0; j < (1 << N); ++j) {
			DP[i][j] = mod;
		}
	}
	DP[0][0] = 0;
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		int t = 0;
		while (b--) {
			int c;
			cin >> c;
			t += (1 << c - 1);
		}
		for (int j = 0; j < (1 << N); ++j) {
			DP[i + 1][j] = DP[i][j];
		}
		for (int j = 0; j < (1 << N); ++j) {
			DP[i + 1][t | j] = min(DP[i + 1][t | j], a + DP[i][j]);
		}
	}
	if (DP[M][(1 << N) - 1] == mod) {
		cout << -1 << endl;
	}
	else {
		cout << DP[M][(1 << N) - 1] << endl;
	}
}


Measured memory_bytes: 16256
n,a,b = map(int,input().split())
if a > b:
  print(0)
  exit()
if n == 1:
  if a== b:
    print(1)
    exit()
  else:
    print(0)
    exit()
print(((n-1)*b+a)-((n-1)*a+b)+1)

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

/*
Range Sum Query by FenwickTree(Binary Indexed Tree)

total number: n
queries:
    1. add(i, val): bit[i] += val 
    2. sum(n): sum(bit[0] + ... + bit[n-1])
time complexity: O(log n)
space complexity: O(N)

Self-balancing binary search tree or Segment Tree can do the same, it takes longer to program and complexity also increases.

Thanks: http://hos.ac/slides/20140319_bit.pdf
    
used in ARC031 C, indeednow finalB E, DSL2B(AOJ), ARC033 C, yukicoder No.59
*/

template<typename T> struct RangeSumQuery {
  int N;
  vector<T> dat;

  RangeSumQuery(int N) : N(N) {
    assert(N > 0);
    dat.resize(N, 0);
  }

  void add(int k, T val) {
    assert(0 <= k && k < N);
    for (int x = k; x < N; x |= x + 1) {
      dat[x] += val;
    }
  }

  // [0, k)
  T sum(int k) {
    assert(k >= 0);
    T ret = 0;
    for (int x = k - 1; x >= 0; x = (x & (x + 1)) - 1) {
      ret += dat[x];
    }
    return ret;
  }
  // [l, r)
  T sum(int l, int r) {
    assert(0 <= l && l <= r && r <= N);
    return sum(r) - sum(l);
  }

  T index(int k) {
    assert(0 <= k && k < N);
    return sum(k+1) - sum(k);
  }
};

P idx[200010];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  REP(i, N) {
    int a;
    cin >> a;
    idx[i] = P(a, i);
  }
  RangeSumQuery<int> fwt(N);
  sort(idx, idx + N);

  ll ans = 0;
  REP(i, N) {
    P p = idx[i];
    ans += (ll)(i - fwt.sum(p.second));
    fwt.add(p.second, 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    priority_queue<int> pq;
    int n, m;
    cin >> n >> m;
    rep(i,0, n){
        int a;
        cin >> a;
        pq.push(a);
    }
    while(m--){
        int t = pq.top()/2;
        pq.pop();
        pq.push(t);
    }
    ll res  = 0;
    while (sz(pq)){
        res += pq.top();
        pq.pop();
        
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 1020
from collections import deque

K = int(input())

q = deque([i for i in range(1, 10)])

for _ in range(K):
    v = q.popleft()

    if v % 10 != 0:
        q.append(10 * v + v % 10 - 1)

    q.append(10 * v + v % 10)

    if v % 10 != 9:
        q.append(10 * v + v % 10 + 1)

print(v)

Measured memory_bytes: 40816
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int main()
{
	LL n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);
	LL ans = 0;
	if (n == 1) {
		if (a == b) ans = 1;
		else ans = 0;
	}
	else {
		LL s1 = a + (n - 1) * b;
		LL s2 = (n - 1) * a + b;
		if (a <= b) ans = s1 - s2 + 1;
		else ans = 0;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256