akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
    int D, G, p[11], c[11];
    cin >> D >> G;
    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }

    int ans = 1e9;
    for(int mask = 0; mask < (1 << D); ++mask){
        int s = 0, num = 0, rest_max = -1;
        for(int i = 0; i < D; ++i){
            if(mask >> i & 1){
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }else{
                rest_max = i;
            }
        }
        if(s < G){
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if(need > p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


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

  Int H, W, N;
  cin>>H>>W>>N;

  Int a = (N-1) / H + 1;
  Int b = (N-1) / W + 1;
  Int ans = min(a, b);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
s = [ x[i]-x[i-1] for i in range(1,m)]
ans = x[-1]-x[0]
s.sort(reverse=True)
if n>=m:
    print(0)
else:
    for i in range(n-1):
        ans -= s[i]
    print(ans)

Measured memory_bytes: 13968
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,m,k,tmp;
  bool can[1000001]={};
  cin >> n >> m >> k;
  for(ll i=0;i<=n;i++){
    for(ll j=0;j<=m;j++){
      tmp = i*m+j*n;
      tmp -= (i*j)*2;
      can[tmp]=true;
    }
  }
  if(can[k])cout <<"Yes\n";
  else cout <<"No\n";
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[] R = new int[n];
		for(int i = 0 ; i < n ; i++) {
			R[i] = input.nextInt();
		}
		Main test = new Main();
		System.out.println(test.dynMaxProfit(n, R));
	}
	
	int dynMaxProfit(int n, int[] R) { 
		int[] maxProfit = new int[n];
		maxProfit[0] = Integer.MIN_VALUE; 
		int min = R[0];
		for(int i = 1; i < n; i ++)  {
			int sell = R[i] - min;
			int notSell = maxProfit[i-1];
	        if(min > R[i]) {
	        	min = R[i];
	        }
	        maxProfit[i] = Math.max(sell, notSell);
		}
	return maxProfit[n-1];
	}
}


Measured memory_bytes: 101008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  string s;
  cin >> s;
  ll l=0,r=s.size()-1;
  ll count=0;
  while(l<r) {
    if(s[l]==s[r]) {
      l++;
      r--;
    }
    else if(s[l]=='x') {
      count++;
      l++;
    }
    else if(s[r]=='x') {
      count++;
      r--;
    }
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << count << endl;
}

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

int p = 1000000007;

int step(int n){
    if(n == 1) return 1;
    if(n == 2) return 1;
    int a = 1;
    int b = 1;
    int res = 2;
    for(int i =0; i < n - 3; i++){
        a = b;
        b = res;
        res = (a + b)%p;
    }
    return res;
}

int main(){
    int N, M;
    cin >> N >> M;
    int stairs[N + 10] ={0};
    for(int i =0; i < M; i++){ //危ないところは1にする
        int a;
        cin >> a;
        if(stairs[a -1] == 1){
            cout << 0 << endl;
            return 0;
        }
        stairs[a] = 1;
    }
    vector<int> streaks;
    int streak = 0;
    for(int i =0; i <= N; i++){
        if(stairs[i] == 0) streak ++;
        else{
            streaks.push_back(streak);
            //cout << streak << endl;
            streak = 0;
        }
    }
    streaks.push_back(streak);
    //cout << streak << endl;
    int64_t ans = 1;
    for(int i =0; i < streaks.size(); i++){
        ans = ans*step(streaks.at(i))%p;
    }
    cout << ans << endl; 
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
	int i,j,h,w;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0 && w==0) break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if((i+j)%2 ==0)
					printf("#");
				else
					printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int n = in.nextInt();
        int d = n % 10;
        n /= 10;
        int c = n % 10;
        n /= 10;
        int b = n % 10;
        n /= 10;
        int a = n % 10;
        
        char x;
        char y;
        char z;
        if (a + b + c + d == 7) {
            x = '+';
            y = '+';
            z = '+';
        } else if (a + b + c - d == 7) {
            x = '+';
            y = '+';
            z = '-';
        } else if (a + b - c + d == 7) {
            x = '+';
            y = '-';
            z = '+';
        } else if (a + b - c - d == 7) {
            x = '+';
            y = '-';
            z = '-';
        } else if (a - b + c + d == 7) {
            x = '-';
            y = '+';
            z = '+';
        } else if (a - b + c - d == 7) {
            x = '-';
            y = '+';
            z = '-';
        } else if (a - b - c + d == 7) {
            x = '-';
            y = '-';
            z = '+';
        } else {
            x = '-';
            y = '-';
            z = '-';
        }
        System.out.print(a);
        System.out.print(x);
        System.out.print(b);
        System.out.print(y);
        System.out.print(c);
        System.out.print(z);
        System.out.println(d + "=7");
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	set<int>t;
	rep(i,3){
		int k; cin>>k;
		t.insert(k);
	}
	cout<<t.size()<<endl;
	return 0;
}

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

long long int factorial(long long int n){
	if(n==0) return 1;
	
	return n*factorial(n-1);
}

int main(){
	long long int n;
	
	cin >> n;
	
	cout << factorial(n) << endl;
	
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    while(cin>>n){
        ll ans=0, sm=0;
        for(int i=0; i<n; ++i){
            scanf("%d",a+i);
        }
        sort(a, a+n);
        int tmp1=a[0], tmp2=a[n-1];
        for(int i=1; i<n-1; ++i){
            if(a[i]<0){
                tmp2-=a[i];
            }
            else{
                tmp1-=a[i];
            }
        }
        ans=tmp2-tmp1;
        cout<<ans<<endl;
        tmp1=a[0];tmp2=a[n-1];
        for(int i=1; i<n-1; ++i){
            if(a[i]<0){
                cout<<tmp2<<" "<<a[i]<<endl;
                tmp2-=a[i];
            }
            else{
                cout<<tmp1<<" "<<a[i]<<endl;
                tmp1-=a[i];
            }
        }
        cout<<tmp2<<" "<<tmp1<<endl;
    }
  return 0;
}




Measured memory_bytes: 2304
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt(); int k = sc.nextInt();
        TreeSet<Integer> set = new TreeSet<>();
        int [] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = sc.nextInt();
        for (int i = 0; i < k; i++) set.add(a[i]);
        int res = 1;
        for (int i = k; i < n; i++) {
            if (set.first() != a[i - k] || a[i] < set.last()) ++res;
            set.remove(a[i - k]); set.add(a[i]);
        }
        ArrayList<Integer> run = new ArrayList<>();
        int cur = 0; int prev = -1;
        for (int i = 0; i < n; i++) {
            if (a[i] > prev) {
                cur++;
            } else {
                run.add(cur);
                cur = 1;
            }
            prev = a[i];
        }
        run.add(cur);
        boolean ok = false;
        for (Integer i: run) {
            if (i >= k) res--;
            if (i >= k) ok = true;
        }
        if (ok) ++res;
        out.println(res);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

ll euclidean_gcd(ll a, ll b) {
  if (a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll A, B;
  cin >> A >> B;
  print(A * B / euclidean_gcd(A, B));
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

from collections import defaultdict

MOD = 10**9 + 7

primes = defaultdict(int)

for a in A:
    p = 2
    while p * p <= a:
        if a % p == 0:
            cnt = 0
            while a % p == 0:
                cnt += 1
                a //= p
            primes[p] = max(primes[p], cnt)
        p += 1
    if a != 1:
        if a not in primes:
            primes[a] = 1

lcm = 1
for p in primes:
    lcm = lcm * pow(p, primes[p], MOD) % MOD

ans = 0
for a in A:
    ans += lcm * pow(a, MOD-2, MOD) % MOD
    ans %= MOD

print(ans)

Measured memory_bytes: 44508
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)

#n = ip()                                     #入力整数1つ
n,t= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#k = ip()                      #入力セット(整数改行あり)(1/2)
#v=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文

for i in range(n+1):
    for k in range(n-i+1):
        m = n-k-i
        if 10000*i+5000*k+1000*m==t:
            print(i,k,m)
            exit(0)
print(-1,-1,-1)

Measured memory_bytes: 15008
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define MOD 1000000007
#define MAX 1000005
#define loop(i,a,b) for(long long int i=a;i<b;i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
typedef long long int ll;

using namespace std;
//using namespace boost::multiprecision;

int prime[MAX];

ll modular_expo(ll x,ll n)
{
	ll ans = 1;
	while(n)
	{
		if(n&1)
		ans = (ans * x)%MOD;
		x = (x*x)%MOD;
		n = n>>1;
	}
	return ans%MOD;
}

void sieve()
{
	prime[1] = 1;
	for(int i=2;i*i<MAX;i++)
	if(prime[i]==0)
	for(int j=i*i;j<MAX;j+=i)
	prime[j] = 1;
}


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

ll n;
cin>>n;

ll ans = (n*(n+1))/2;

ans -= ((n/3) * (3 + (n/3)*3))/2;
ans -= ((n/5) * (5 + (n/5)*5))/2;
ans += ((n/15) * (15 + (n/15)*15))/2;

cout<<ans<<"\n";


return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr int MOD = 1'000'000'007;

// auto mod int
struct mint {
    LL x;
    mint(LL x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(const LL &t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    LL operator()() const {
        return x;
    }
};

void solve() {
    int n,m;
    cin >> n >> m;
    VI s(n), t(m);
    REP(i,0,n) cin >> s[i];
    REP(i,0,m) cin >> t[i];
    vector<vector<mint>> dp(n+1,vector<mint>(m+1));
    vector<vector<mint>> ru(n+1,vector<mint>(m+1));
    dp[0][0] = 1;
    REP(i,0,n+1) ru[i][0] = 1;
    REP(j,0,m+1) ru[0][j] = 1;
    ru[0][0] = 1;
    REP(i,0,n) REP(j,0,m) {
        ru[i+1][j+1] = ru[i][j+1] + ru[i+1][j] - ru[i][j];
        if (s[i] != t[j]) continue;

        dp[i+1][j+1] = ru[i][j];
        ru[i+1][j+1] += ru[i][j];
    }

    cout << ru[n][m]() << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 62976
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <cmath>


using namespace std;

//  ||
// \

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << s1[0] << s2[1] << s3[2] << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

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

    int ans = 0;
    for(int i = 0; i < len(a); i++) {
        if (a[i] == b[i]) ans++;
    }
    cout << ans << '\n';
    
    return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define what_is(x) cout << #x << " is: " << x << endl;
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define ll long long int

#define vi vector<int>
#define pii pair<int,int>
#define vl vector<ll>
#define pll pair<ll, ll>

template<typename T>
T extgcd(T a, T b, T &x, T &y) { if (b == 0) {x = 1;y = 0;return b;}T x1, y1;T g = extgcd(b, a % b,x1, y1);x = y1; y = x1 - (a/b)*y1;return g;}
template<typename T>
T fast_power(T a, T b){T res = (T)1;while( b ){if( b & 1 ) res = res * a;b >>= 1;a *= a; } return res;}
template<typename T>
T fast_powerModulo( T a, T b, T M){T res = (T)1;a %= M;while( b ){if( b & 1 ) res = (res * a) % M;b >>= 1;a *= a;a %= M; }return res;}
template<typename T>
T LCM(T a, T b){ T gd = __gcd(a, b); T ml = a * b; return ml/ gd;}

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

const int INF = 1<<30;
const ll LINF = 1ll<<60;

int main(){
    FAST
    int n, k, s;
    cin >> n >> k >> s;
    for( int i = 0; i < k; ++i){
        cout << s << " ";
    }
    for(int i = k; i < n; ++i){
        if( s == 1e9){
            cout << s - 1 << " ";
        } else {
            cout << s + 1 << " ";
        } 
    }

    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    vector<int> a(5);
    for (int i = 0; i < 5; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int k;
    cin >> k;
    if (a[4] - a[0] <= k) cout << "Yay!";
    else cout << ":(";
    return 0;
}



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

typedef long long ll;

void solve() {
    int N, A, ans = 0;
    cin >> N;
    vector<int> b(100001, 0);
    rep(i,N) {
        cin >> A;
        if (b[A] == 0) ans++;
        b[A]++;
    }
    cout << (ans - 1) / 2 * 2 + 1 << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 640
x = [int(i) for i in input().split()]
ans = 0
f = [False,False]
for i in range(2):
    if x[i] == 1:
        ans += 300000
        f[i] = True
    elif x[i] == 2:
        ans += 200000
    elif x[i] == 3:
        ans += 100000

if f[0] and f[1]:
    ans += 400000

print(ans)


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }

        static void Solve()
        {
            var NABC = Sarray();
            var N = NABC[0];
            var ABC = new long[] { NABC[1], NABC[2], NABC[3] };
            var Si = new string[N];
            for (var i = 0; i < N; ++i)
                Si[i] = ReadLine();
            var dct = new Dictionary<char, long>() { { 'A', 0 }, { 'B', 1 }, { 'C', 2 } };
            var sel = new char[N];
            for (var i = 0; i < N; ++i)
            {
                var s = Si[i];
                var tg1 = dct[s[0]];
                var tg2 = dct[s[1]];
                if (ABC[tg1] == 1 && ABC[tg2] == 1 && i < N - 1 && s != Si[i + 1])
                {
                    if (s[0] == Si[i + 1][0] || s[0] == Si[i + 1][1])
                    {
                        sel[i] = s[0];
                        ++ABC[tg1]; --ABC[tg2];
                    }
                    else
                    {
                        sel[i] = s[1];
                        --ABC[tg1]; ++ABC[tg2];
                    }
                }
                else
                {
                    if (ABC[tg1] < ABC[tg2])
                    {
                        sel[i] = s[0];
                        ++ABC[tg1]; --ABC[tg2];
                    }
                    else
                    {
                        sel[i] = s[1];
                        --ABC[tg1]; ++ABC[tg2];
                    }
                }
                if(ABC.Any(a=>a<0))
                {
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
            foreach (var s in sel)
                WriteLine(s);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 35008
import           Control.Monad
import qualified Data.Map.Strict as Map

type Graph = [[Int]]
type AdjMatrix = [[Bool]]

main :: IO ()
main = do
  n <- readLn
  gs <- replicateM n $ fmap (map read . words) getLine :: IO [[Int]]
  solve gs

solve :: Graph -> IO ()
--solve gs = print $ breadthFirstSearch (toAdjMatrix gs) 0 0
solve gs = do
  let visits = bfs (toAdjMatrix gs) [0] (Map.singleton 0 0)
  forM_ [0..(length gs - 1)]
        (\i -> let time = Map.findWithDefault (-1) i visits
               in putStrLn $ (show (i + 1)) ++ " " ++ (show time))

bfs :: AdjMatrix -> [Int] -> Map.Map Int Int -> Map.Map Int Int
bfs _ [] vs = vs
bfs gs qs vs = bfs gs (adjs ++ init qs) newvs
  where
    q = last qs
    edges = gs !! q
    adjs = [i | i <- [0..(length gs - 1)], edges !! i, notElem i $ Map.keys vs]
    Just time = Map.lookup q vs
    newvs = foldr (\adj vs -> Map.insert adj (time + 1) vs) vs adjs


toAdjMatrix :: Graph -> AdjMatrix
toAdjMatrix gs = scanColumn gs $ length gs
  where
    scanColumn :: Graph -> Int -> AdjMatrix
    scanColumn [] _ = []
    scanColumn (x:xs) n = (makeRow x n) : (scanColumn xs n)

    makeRow :: [Int] -> Int -> [Bool]
    makeRow (u:k:vs) n = [if x `elem` vs then True else False | x <- [1..n]]



Measured memory_bytes: 4408
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

int main() {
    string c[3];
    cin >> c[0] >> c[1] >> c[2];
    string ans = "";
    for (int i = 0; i < 3; i++) {
        ans += c[i][i];
    }
    cout << ans << endl;
}


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

int int_cmp(const int *a, const int *b){
	if(*a<*b) return 1;
	else if(*a>*b) return -1;
	return 0;
}

int main(void){
	while(1){
		int n, s, i, j;
		int r[20000];
		long ans=0;
		
		scanf(" %d %d", &n, &s);
		if(n==0) break;
	
		for(i=0; i<n; i++)
			scanf(" %d", &r[i]);
	
		qsort(r, n, sizeof(int), (int(*)(const void*, const void*))int_cmp);
	
		for(i=0; i<n-1; i++) {
			if(r[i] > s) ans += n-i-1;
			else{
				for(j=i+1; j<n; j++) {
					if(r[i]+r[j] > s) ++ans;
					else break;
				}
			}
		}
				
		printf("%ld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 724
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int aoi=3018,mod=998244353;
ll dp[aoi][aoi];
int a[aoi];
int main() {
  int i,n,j,k,s;
  read(n),read(s);
  for (i=1;i<=n;++i) a[i]=read();
  for (**dp=i=1;i<=n;++i) {
    for (j=0;j<=s;++j) {
      dp[i][j]=dp[i-1][j]*2%mod;
      if (j>=a[i]) dp[i][j]=(dp[i][j]+dp[i-1][j-a[i]])%mod;
    }
  }
  printf("%lld\n",dp[n][s]);
}

Measured memory_bytes: 74400
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
import math
MOD = 10**9 + 7

n = int(input())
fish = dict() 
azero = 0
bzero = 0
abzero = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        abzero += 1
        continue
    if a == 0:
        azero += 1
        continue
    if b == 0:
        bzero += 1
        continue
    a_abs = abs(a); b_abs = abs(b)
    g = math.gcd(a_abs, b_abs)
    if (a > 0 and b > 0) or (a < 0 and b < 0): 
        key = (a_abs // g, b_abs // g)
    else:
        key = (a_abs // g, -b_abs // g)
    if key not in fish:
        fish[key] = 1
    else:
        fish[key] += 1

ans = 1
for a, b in fish:
    if fish[(a, b)] == 0:
        continue
    if b < 0:
        inv_key = (-b, a)
    else:
        inv_key = (b, -a)
    if inv_key in fish:
        val1 = ans * (pow(2, fish[(a, b)], MOD) - 1)
        val2 = ans * (pow(2, fish[inv_key], MOD) - 1)
        fish[inv_key] = 0
        ans = val1 + val2 + ans
    else:
        val1 = ans * (pow(2, fish[(a, b)], MOD) - 1)
        ans = val1 + ans
    ans %= MOD
# think a == 0 or b == 0
val1 = ans * (pow(2, azero, MOD) - 1)
val2 = ans * (pow(2, bzero, MOD) - 1)
ans = val1 + val2 + ans
ans += abzero
print((ans - 1) % MOD)

Measured memory_bytes: 108128
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;

int N;
int a[9];
int p,q;
int P[9];
int Q[9];

bool checkP(){
    for(int i = 0; i < N; i++){
        if(a[i] != P[i]) return false;
    }
    return true;
}

bool checkQ(){
    for(int i = 0; i < N; i++){
        if(a[i] != Q[i]) return false;
    }
    return true;
}
int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        a[i] = i+1;
    }
    
    for(int i = 0; i < N; i++){
        cin >> P[i];
    }
    for(int i = 0; i < N; i++){
        cin >> Q[i];
    }
    int cnt = 0;
    do{
        if(checkQ()) q = cnt;
        if(checkP()) p = cnt;
        cnt++;
    }while(next_permutation(a,a+N));
    cout << abs(p-q) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>
#include <string.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;
long long int DP[10000];
bool chack[10000];
long long int lucas(int a){
    if(chack[a]){
        return DP[a];
    }
    if(a==0){
        return 2;
    }
    if(a==1){
        return 1;
    }
    long long int ent;
    ent=lucas(a-1)+lucas(a-2);
    DP[a]=ent;
   // printf("%llu %llu\n",ent,DP[a]);
    chack[a]=true;
    return ent;
}
int main(void) {
  /*  int count=0,len;
    char n[100000];
    cin >>n;
    len=(int)strlen(n);
    for(int i=0;i<len+1;i++){
        if(count==2){
            printf("Yes\n");break;
        }
        if(n[i]==n[i-1]){
            count+=1;
        }
        else{
            count=0;
        }
        if(i+1==len+1){
            printf("No\n");
        }
    }
    long long int ans;
    int n;
    cin >>n;
    ans=lucas(n);
    cout<<ans<<endl;*/
    int a[2]={1,-1},b[2]={1,-1},c[3]={1,-1},inte[4],q,w,e,r,ans,che=0;
    char moj[4];
    for(int i=0;i<4;i++){
        cin>>moj[i];
        inte[i]=(int)moj[i]-'0';
    }
   // sort(inte,inte+4);
    q=inte[0];
    w=inte[1];
    e=inte[2];
    r=inte[3];
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                ans=q+w*a[i]+e*b[j]+r*c[k];
                if(ans==7){
                    che=1;
                    for(int v=0;v<4;v++){
                        cout <<inte[v];
                        if(v==3){
                            cout<<"=7"<<endl;break;
                        }
                        if(a[i]==1&&v==0){
                            cout<<"+";
                        }
                        if(a[i]==-1&&v==0){
                            cout<<"-";
                        }
                        if(b[j]==1&&v==1){
                            cout<<"+";
                        }
                        if(b[j]==-1&&v==1){
                            cout<<"-";
                        }
                        if(c[k]==1&&v==2){
                            cout<<"+";
                        }
                        if(c[k]==-1&&v==2){
                            cout<<"-";
                        }
                        }
                    
                    }
                if(che==1){
                    break;
                }
            }
                if(che==1){
                    break;
            }
        }
        if(che==1){
            break;
    }
    }
    return 0;
}

Measured memory_bytes: 256
program sample
    implicit none
   
    integer(8) :: a,b,c
    
  
    read(*,*)a,b,c
    if(b==0)then
        write(*,*)1
    elseif(a==0)then
        write(*,*)b/c+1
    else
        write(*,*)b/c-(a-1)/c
    end if
    stop
end program sample
  



Measured memory_bytes: 2788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;


int main(){
  int N;cin>>N;
  vector<ll>A(1+N);
  vector<ll>B(N);
  rep(i,1+N){cin >>A[i];}
  rep(i,N){cin>>B[i];}
  ll ans=0ll;
  ll a=A[0],b=B[0];
  ll g=max(0ll,b-a);ans+=min(a,b);
  if(A[1]>=g){A[1]-=g;ans+=g;}
  else{ans+=A[1];A[1]=0ll;}
  for(int i=1;i<=N-1;i++){
  	ll a=A[i],b=B[i];
  ll g=max(0ll,b-a);ans+=min(a,b);
  if(A[1+i]>=g){A[i+1]-=g;ans+=g;}
  else{ans+=A[i+1];A[i+1]=0ll;}
  }
  cout<<ans;
}

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

int main(){
    int n;
    cin >> n;
    int cnt=n;
    string s;
    cin >>s;
    rep(i,n-1){
        if(s[i]==s[i+1]) cnt-=1;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
const int maxn = 100100;
int main(){
  int n;
  cin >> n;
  int k = 1;
  while(k * (k + 1) / 2 <= n) k++;
  k--;
  if(k * (k + 1) / 2 == n){
    cout << "Yes" << endl;
    cout << k+1 << endl;
    vector<vector<int> > ans;
    vector<int> h0, h1;
    for(int e = 1; e <= k; e++) h0.push_back(e);
    h1.push_back(1);
    for(int e = k+1; e <= k+k-1; e++) h1.push_back(e);
    ans.push_back(h0);
    ans.push_back(h1);
    int top = k+k;
    for(int e = 2; e <= k; e++){
      int col = e - 2 + 1;
      vector<int> hx;
      for(int f = 0; f < e; f++) hx.push_back(ans[f][col]);
      for(int f = e; f < k; f++) hx.push_back(top++);
      ans.push_back(hx);
    }
    for(int e = 0; e < k+1; e++){
      cout << ans[e].size();
      for(int v : ans[e]) cout << " " << v;
      cout << endl;
    }
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    string s;cin>>s;
    int ans = 1e5;
    rep(i,s.size()-2){
        ans = min(ans,abs(753-stoi(s.substr(i,3))));
    }
    co(ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

import static java.lang.Integer.max;
import static java.lang.Integer.min;
import static java.lang.Math.abs;

public class Main
{
    public static void main(String[] args)
    {
        ABC075B s = new ABC075B();
        s.read();
        s.solve();
    }
}

class ABC075B
{
    int N, K;
    int[] x = new int[200];

    void read()
    {
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        K = in.nextInt();

        for (int i = 0; i < N; i++)
            x[i] = in.nextInt();
    }

    void solve()
    {
        int sum = 0;
        for (int i = 0; i < N; i++)
        {
            int m = abs(x[i]);
            int n = abs(x[i] - K);
            sum += 2 * min(m, n);
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 233333
int n; pii p[SZ];
struct scmp
{
bool operator () (pii a,pii b)
{return pii(a.se,a.fi)<pii(b.se,b.fi);}
};
struct scmp2
{
bool operator () (pii a,pii b)
{return pii(-a.fi,a.se)<pii(-b.fi,b.se);}
};
multiset<pii,scmp> sb;
multiset<pii,scmp2> sa;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d%d",&p[i].fi,&p[i].se),
		sa.insert(p[i]),sb.insert(p[i]);
	int cp=0,cr=1; ll ca=0,oo=0;
	while(sa.size())
	{
		cr^=1; pii s;
		if(!cr)
		{
			s=*sa.begin();
			sa.erase(sa.begin());
			sb.erase(sb.find(s));
		}
		else
		{
			s=*sb.begin();
			sb.erase(sb.begin());
			sa.erase(sa.find(s));
		}
		if(s.fi<=cp&&cp<=s.se);
		else if(cp<s.fi)ca+=s.fi-cp,cp=s.fi;
		else ca+=cp-s.se,cp=s.se;
	}
	ca+=abs(cp);
	oo=ca; cp=0,cr=0,ca=0;
	for(int i=1;i<=n;++i)
		sa.insert(p[i]),sb.insert(p[i]);
	while(sa.size())
	{
		cr^=1; pii s;
		if(!cr)
		{
			s=*sa.begin();
			sa.erase(sa.begin());
			sb.erase(sb.find(s));
		}
		else
		{
			s=*sb.begin();
			sb.erase(sb.begin());
			sa.erase(sa.find(s));
		}
		if(s.fi<=cp&&cp<=s.se);
		else if(cp<s.fi)ca+=s.fi-cp,cp=s.fi;
		else ca+=cp-s.se,cp=s.se;
	}
	ca+=abs(cp);
	cout<<max(ca,oo)<<"\n";
}


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

int main(){
	int n;
	scanf("%d", &n);
	int d = n%10; n /= 10;
	int c = n%10; n /= 10;
	int b = n%10; n /= 10;
	int a = n;
	
	if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n", a, b, c, d);
	else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n", a, b, c, d);
	else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n", a, b, c, d);
	else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n", a, b, c, d);
	else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n", a, b, c, d);
	else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n", a, b, c, d);
	else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n", a, b, c, d);
	else if(a-b-c-d==7) printf("%d-%d-%d-%d=7\n", a, b, c, d);
	return 0;
}


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

using namespace std;

#define LL long long
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    int i,n;
    LL ans=1,a[100005];
    const LL mx=(LL)1e18;
    cin >> n;
    for(i=0;i<n;i++)cin >> a[i];
    sort(a,a+n);
    if(a[0] == 0)
    {
        cout << "0";
        return 0;
    }
    for(i=0;i<n;i++)
    {
        if(ans > mx/a[i])
        {
            cout << "-1";
            return 0;
        }
        ans*=a[i];
    }
    cout << ans;
    return 0;
}


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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library
//

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n; cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; ++i){
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    ll ans = p[n - 1] / 2;
    for(int i = 0; i < n - 1; ++i){
        ans += p[i];
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N; cin>>N;
	string s; cin>>s;
	vector<int> cnt_wht(N+1,0);
	vector<int> cnt_blk(N+1,0);
	rep(i,N)cnt_blk[i+1] = cnt_blk[i] + (s[i] == '#');
	for(int i = N-1; i>=0; --i)cnt_wht[i] = cnt_wht[i+1] + (s[i] == '.');
	int ans = inf;
	rep(i,N+1){
		ans = min(ans, cnt_wht[i] + cnt_blk[i]);
	}
	cout<<ans<<endl;
}

// int main(){
// 	int N; cin>>N;
// 	string s; cin>>s;
// 	int ans_1, ans_2, ans_3 = 0, ans_4 = 0;
// 	int cnt_blk = 0, cnt_wht = 0;
// 	rep(i,N){
// 		if(s[i] == '#') ++cnt_blk;
// 		else ++cnt_wht;
// 	}
// 	ans_1 = cnt_blk;
// 	ans_2 = cnt_wht;
// 	int ch_wht = 0;
// 	rep(i,N){
// 		if(ch_wht == cnt_wht)break;
// 		if(s[i] == '.') ++ch_wht;
// 		else ++ans_3;
// 	}
// 	int ch_blk = 0;
// 	for(int i = N-1; i>=0; --i){
// 		if(ch_blk == cnt_blk)break;
// 		if(s[i] == '#') ++ch_blk;
// 		else ++ans_4;
// 	}
// 	cout<<min({ans_1, ans_2, ans_3, ans_4})<<endl;
// 	return 0;
// }

Measured memory_bytes: 2180
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0008
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.toInt)
      .map {
        case n if n > 9 * 4 => 0
        case n => {
          val ub = math.min(9, n)
          (for (a <- 0 to ub; b <- 0 to ub; c <- 0 to ub; d <- 0 to ub if a + b + c + d == n) yield 1)
            .length
        }
      }
      .foreach(println)
  }
}

Measured memory_bytes: 61516
#include<bits/stdc++.h>
#define u64 uint64_t
#define ll long long
#define endl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    fast
    ll n,m,x,y,i,j,k,p,f=0,tc,cnt=0,sum=0,pro=1,mi=1e18,ma=-1e18;
    string str;
    char ch;
    double db;
    deque<ll>dq;
    map<ll,ll>mp;
    set<ll>st;
    vector<ll>vt;
    //code
    cin>>str;
    for(i=0;i<str.size();i++)
    {
        if(str[i]=='?')
        {
            str[i]='D';
        }
    }
    cout<<str<<endl;




    //code
    return 0;
}


Measured memory_bytes: 3772