akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N],b[N],c[N],st,ed,o,cnt;long long ans,ans1;
int main(){
    ios::sync_with_stdio(false);cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    sort(a+1,a+1+n);st=1,ed=n;
    int mid=1+n>>1;
    b[++cnt]=a[mid];o=(a[mid]-a[st]>a[ed]-a[mid]);
    while(st<mid||mid<ed){
        if(o&&st<mid){
            b[++cnt]=a[st++];
        }
        if(!o&&mid<ed){
            b[++cnt]=a[ed--];
        }o^=1;
    }
    cnt=0;st=1,ed=n;
    c[++cnt]=a[mid];o=(a[mid]-a[st]<a[ed]-a[mid]);
    while(st<mid||mid<ed){
        if(o&&st<mid){
            c[++cnt]=a[st++];
        }
        if(!o&&mid<ed){
            c[++cnt]=a[ed--];
        }o^=1;
    }
    for(int i=2;i<=n;++i)ans+=abs(b[i]-b[i-1]);
    for(int i=2;i<=n;++i)ans1+=abs(c[i]-c[i-1]);
    cout<<max(ans,ans1)<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int A, B, K;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> A >> B >> K;
  int ans = 0;
  for (int i = min(A, B); i >= 1; --i) {
    if (A % i == 0 && B % i == 0) {
      --K;
    }
    if (K == 0) {
      ans = i;
      break;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

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

    rep(i,N-1) {
        if (A[i] == A[i + 1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;


    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<stack>
#include<iomanip>
#include<map>
using namespace std;
//def lib
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define drep(i,n) for(int i=((int)n)-1;i>-1;i--)
#define Rep(i,n0,n) for(int i=n0;i<((int)n);i++)
#define dRep(i,n0,n) for(int i=((int)n)-1;i>n0-1;i--)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++)
#define W(x) cout<<x<<endl;
#define print(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
#define mod 1000000007
//def end
typedef long long ll;
// lib
int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){if(y>x)return y;else return x;}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
int mfact(int x){int i=1;rep(j,x){i*=(j+1);} return i%mod;}
int modulo(int x){return x%mod;}
long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;}
long long mfact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i%mod;}
long long modulo(long long x){return x%mod;}
int gcd(int x, int y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
ll gcd(ll x, ll y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
void say(bool x){if(x){cout<<"Yes"<<endl;}else {cout<<"No"<<endl;}return;}
//lib end
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1};
int main()
{
    int n;
    cin >> n;
    if(n==1){
        W("Hello World")
    }
    else{
        int a,b;
        cin >> a >>b;
        W(a+b)
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, k, x, y;

int solve() {
    return x * min(n, k) + y * max(0, n-k);
}

void input() {
    cin >> n >> k >> x >> y;
}

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

    input();
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
     int n;
     cin>>n;
     int a[n];
     for(int i=0;i<n;i++)
        cin>>a[i];
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i;j<n;j++)
        {
            if(i==j)
                continue;
            else
                cnt += a[i]*a[j];
        }
    }
    cout<<cnt<<endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / INF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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 gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

//===================================== template =========================================================

vector<vector<int>> tree;
vector<int> c;
vector<bool> h;

void mov(int v) {
    h[v] = true;
    for (auto v2 : tree[v]) {
        if (h[v2]) continue;
        c[v2] += c[v];
        mov(v2);
    }
}

int main()
{
    int N, Q;
    cin >> N >> Q;
    tree.resize(N); c.resize(N); h.resize(N);
    fill_n(c.begin(), N, 0);
    fill_n(h.begin(), N, false);
    REP(i, N-1) {
        int a, b; cin >> a >> b; a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    REP(i, Q) {
        int p, x;  cin >> p >> x; p--;
        c[p] += x;
    }

    mov(0);
    REP(i, N) cout << c[i] << (i == N-1 ? "\n" : " ");
}


Measured memory_bytes: 23552
n, l = gets.chomp.split(' ').map(&:to_i)
before_array = (1..n).to_a
after_array = before_array.map { |item| item = item + l - 1 }
abs_array = after_array.map(&:abs)
# abs_array = after_array.map(&:abs)
# min = abs_array.min
after_after_array = after_array.delete_if { |item| item.abs == abs_array.min }
p after_after_array.inject(:+)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void ok() { cerr << "ok" << endl; }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    double s;
    cin >> s;
    double r = s / 3;
    cout << fixed << setprecision(12) << r * r * r << endl;
}

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

int main(){
    int N,Y;
    cin>>N>>Y;
    int value[3] = {10000,5000,1000};
    int coins[3];
    fill(coins,coins + 3,-1);

    for(int i=0;i<=N;i++){
        for(int j =0; j<=N-i; j++){
            int sum = ( (i*value[0]) + (j*value[1]) ) + (N-i-j)*value[2];
            if(sum == Y){
                coins[0] = i;
                coins[1] = j;
                coins[2] = N-i-j;
                break;
            }
        }
    }
    cout<<coins[0]<<" "<<coins[1]<<" "<<coins[2]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);



//計算
void calc(const vector<string> f)
{
	//variable
	int res = 0;
	bool bodyFloor = true;
	pair<bool, bool> footFloor = { true,true };
	
	//calc
	for (auto s : f) {
		bool left = (s[0] == 'l');
		bool floor = (s[1] == 'd');
		//move
		if (left) {
			footFloor.first = floor;
		}
		else {
			footFloor.second = floor;
		}
		//count
		if (bodyFloor != footFloor.first&&
			bodyFloor != footFloor.second) {
			res++;
			bodyFloor = footFloor.first;
		}
	}


	//output
	cout << res << endl;
}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	while (true) {
		int n;
		vector<string> f;
		cin >> n;
		if (n == 0)break;
		f.resize(n);
		REP(i, n)cin >> f[i];
		calc(f);
	}
	debug();
	
	return 0;
}



Measured memory_bytes: 3200
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
    char x;
    cin>>x;
    if(isupper(x))
        cout<<'A';
    else
        cout<<'a';
        
    return 0;
}


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

void Make_Prime_Number(int * );


int main(void){

        int prime[10000] = {0};
        int k = 0;
        int count = 0;

        for(int i=2; i<=10000; i++){

                for(int j=2; j<i; j++){
                        
                        if(i%j == 0){
                                count = 1;
                                break;
                        }

                }

                if(count == 0){
                        prime[k] = i;
                        k++;
                }
                
              
                count = 0;

        }

        /*for(int i=0; i<10000; i++){
                if(prime[i] != 0){
                        cout << i << ":" << prime[i] << endl;
                }
                }*/

        while(1){
                
                int num = 0;
                int answer = 0;
                cin >> num;

                if(num == 0)break;

                for(int j=0; j<10000; j++){
                        
                        int sum = 0;  
                        for(int i=j; i<10000; i++){
                                
                                sum = sum + prime[i];
                                if(sum > num)break;
                                if(sum == num){
                                        answer++;
                                        break;
                                }
                                
                        }
                        
                                
                                }
                cout << answer << endl;
                
        }

        return 0;
                
}

Measured memory_bytes: 1208
x, y = map(int, input().split())
diff = abs(abs(x)-abs(y))

if abs(x) < abs(y):
  if x < 0:
    diff += 1
  if y < 0:
    diff += 1
else:
  if x > 0:
    diff += 1
  if y > 0:
    diff += 1
print(diff)

Measured memory_bytes: 38256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    s=STR()
    t=STR()
    ls=len(s)
    lt=len(t)
    ans=10**9
    for i in range(ls-(lt-1)):
        temp=0
        for k in range(lt):
            if s[i+k]!=t[k]:
                temp+=1
        ans=min(temp,ans)
    print(ans)
        

if __name__=='__main__':
    do()

Measured memory_bytes: 9144
#include <cstdio>
using namespace std;

int main(){
    int a, b, i, j, k;
    i = 1;
    j = 1;
    k = 1;
    while (k == 1){
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0){
            break;
        } else {
            while (i <= a - 1) {
                while (j <= b)  {
                    printf("#");
                    j += 1;
                }
                j = 1;
                printf("\n");
                i += 1;
            }
            j = 1;
            while(j <= b){
                printf("#");
                j += 1;
            }
            printf("\n");
            printf("\n");
            j = 1;
            i = 1;
        }
        a = 0;
        b = 0;
        
    }
    return 0;
}


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

using namespace std;

int main(){
        int a,b,c;

        cin >> a >> b >> c;

        if (a + b + c >= 22){
                cout << "bust" << endl;
        }
        else if(a + b + c <= 21){
                cout << "win" << endl;
        }
        return 0;
}

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

using namespace std;

const int max_n = 10000;

bool first_is_bigger(string a, string b) {
    if (b == "-") {
        return true;
    }
    if (a.size() > b.size()) {
        return true;
    } else if (a.size() == b.size() && a >= b) {
        return true;
    } else {
        return false;
    }
}

int main() {
    
    map<int, int> costs;
    
    costs[1] = 2;
    costs[2] = 5;
    costs[3] = 5;
    costs[4] = 4;
    costs[5] = 5;
    costs[6] = 6;
    costs[7] = 3;
    costs[8] = 7;
    costs[9] = 6;
    
    vector<string> dp(max_n, "-");
    dp[0] = "";
    
    int n,m;
    cin >> n >> m;
    
    vector<int> a(m, 0);
    vector<int> cost(m, 0);
    
    for (int j=0; j<m; j++) {
        cin >> a[j];
        cost[j] = costs.at(a[j]);
        //cout << cost[j] << " ";
    }
    //cout << endl;
    
    for (int i=1; i<=n; i++) {
        for (int j=0; j<m; j++) {
            if (i-cost[j] >= 0 && dp[i-cost[j]] != "-" && first_is_bigger(dp[i-cost[j]] + to_string(a[j]), dp[i])) {
                dp[i] = dp[i-cost[j]] + to_string(a[j]);
            }
        }
        //cout << i << " : " << dp[i] << endl;
    }
    
    cout << dp[n] << endl;
    
    return 0;
    
}

Measured memory_bytes: 28160
def counting_sort(a, b, k):
    c = [0 for _ in range(k + 1)]
    for i in range(len(a)):
        c[a[i]] += 1
    for i in range(1, len(c)):
        c[i] += c[i -1]
    for i in range(len(a) - 1, -1, -1):
        b[c[a[i]] - 1] = a[i]
        c[a[i]] -= 1

n = input()
a = list(map(int, input().split()))
b = [0 for _ in range(len(a))]
counting_sort(a, b, max(a))
print(*b)



Measured memory_bytes: 224608
import sys
X, K, D = map(int, input().split())
X = abs(X)
if K*D <= X:
    print(X-K*D)
else:
    num1 = X%D
    num2 = D - num1
    if ((X-num1)//D)%2 == K%2:
        print(num1)
    else:
        print(num2)

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

int main() {
    string w;
    cin >> w;
    int cnt[26] {};
    for (char c : w) cnt[c-'a']++;
    for (int x : cnt) {
        if (x % 2 != 0) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>
#include<bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n";
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) {
            for (auto vvv : vv) cout << vvv << " ";
            cout << endl;
        }
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class BATCoder {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string s;
	    in >> s;

	    int cnt = 0;
	    int res = 0;
	    int len = s.length();
	    set<char> st = {'A', 'C', 'G', 'T'};
	    for(int i=0; i<len; i++){
	        if(st.find(s[i]) != st.end()) cnt++;
	        else {
	            chmax(res, cnt);
	            cnt = 0;
	        }
	    }
	    chmax(res, cnt);

	    out << res << endl;
	}
};


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	BATCoder solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

#define MOD 1000000007
#define INT_MAX

int main()
{
	int h, w;
	cin >> h >> w;
	
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		cout << s << endl;
		cout << s << endl;
	}
	return (0);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main() {
  int n, m, result;
  if (scanf("%d %d", &n, &m) <= 0) {
    printf("fail");
  }
  int s[m], c[m], num[n];
  int i = 0;
  while(i < m) {
    if (scanf("%d %d", &s[i], &c[i]) <= 0) {
      printf("fail");
    }
    i++;
  }
  i = 0;
  while(i < n) {
    num[i] = -1;
    i++;
  }

  i = 0;
  result = 0;
  while(i < m) {
    if (num[s[i] - 1] != -1 && num[s[i] - 1] != c[i]) {
      result = -1;
      break;
    } else if (s[i] > n) {
      result = -1;
      break;
    } else {
      num[s[i] - 1] = c[i];
    }
    i++;
  }

  if (n != 1 && num[0] == 0) {
    result = -1;
  }

  if (num[0] == -1 && n != 1) {
    num[0] = 1;
  }

  i = 0;
  while(i < n) {
    if(num[i] == -1) {
      num[i] = 0;
    }
    i++;
  }

  if (result != -1) {
    int tmp;
    tmp = n - 1;
    i = 0;
    while(i < n) {
      result = result + num[i] * pow(10, tmp);
      i++;
      tmp--;
    }
  }

  printf("%d", result);

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll ;

const ll inf = 1e9 + 10;
const int maxn = 3e5 + 30;
const int maxq = 1e5 + 10;
const int alf = 26;
const ll dlm = 1e9+7;
const ll del = 179425601 ;
const int eps = 1e-7 ;
string O[]={"YES","NO","Yes","No"};

int main()
{
    ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    string s;
    cin>>s;
    int ans = 0;
    for(int i=0;i<s.size();i++){
        int v = s[i]-'0';
        ans+=v;
    }
    if(ans==1)ans*=10;
    cout<<ans;
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<P> items(N);
    rep(i, N) cin >> items[i].second >> items[i].first;
    sort(items.begin(), items.end());
    ll last = 0;
    rep(i, N) {
        P p = items[i];
        if (p.first >= last + p.second) {
            last = last + p.second;
        } else {
            cout << "No" << '\n';
            return;
        }
    }
    cout << "Yes" << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a == b){
    cout << 2 * a << endl;
  } else {
    int mx = max(a,b);
    cout << 2 * mx - 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    string a,b;
    REP(i,n / 2){
        a.push_back(s[i]);
    }
    for(int i = n / 2; i < n; i++){
        b.push_back(s[i]);
    }
    if(a == b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main()
{
  int N;
  bool B=0;
  cin >> N;
  vector<int> T(N+1), X(N+1), Y(N+1);
  T.at(0)=0;
  X.at(0)=0;
  Y.at(0)=0;
  for(int i=1; i<=N; i++){
    cin >> T.at(i) >> X.at(i) >> Y.at(i);
    if(T.at(i)-T.at(i-1)-(X.at(i)-X.at(i-1)+Y.at(i)-Y.at(i-1))<0 | (T.at(i)-T.at(i-1)-(X.at(i)-X.at(i-1)+Y.at(i)-Y.at(i-1)))%2!=0){
      B=1;
      break;
    }
  }
  if(B==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second

ll r, c, rs, cs, rf, cf;

int main() {
	cin>>r>>c>>rs>>cs>>rf>>cf;
	char s[r+1][c+1];
	for (int i=1; i<=r; i++) {
		for (int j=1; j<=c; j++) {
			cin>>s[i][j];
		}
	}
	priority_queue < pair<ll, pair<ll,ll> > > pq;
	pq.push(make_pair(0, make_pair(rs, cs)));
	ll m[r+1][c+1];
	memset(m, -1, sizeof(m));
	m[rs][cs]=0;
	while (!pq.empty()) {
		ll rx=pq.top().se.fi, cx=pq.top().se.se, magic=-pq.top().fi;
		pq.pop();
		if (m[rx][cx]!=magic) continue;
		if (rx-1>0) {
			if ((m[rx-1][cx]>magic||m[rx-1][cx]==-1)&&s[rx-1][cx]=='.') {
				m[rx-1][cx]=magic;
				pq.push(make_pair(-magic, make_pair(rx-1, cx)));
			}
		}
		if (rx+1<=r) {
			if ((m[rx+1][cx]>magic||m[rx+1][cx]==-1)&&s[rx+1][cx]=='.') {
				m[rx+1][cx]=magic;
				pq.push(make_pair(-magic, make_pair(rx+1, cx)));
			}
		}
		if (cx-1>0) {
			if ((m[rx][cx-1]>magic||m[rx][cx-1]==-1)&&s[rx][cx-1]=='.') {
				m[rx][cx-1]=magic;
				pq.push(make_pair(-magic, make_pair(rx, cx-1)));
			}
		}
		if (cx+1<=c) {
			if ((m[rx][cx+1]>magic||m[rx][cx+1]==-1)&&s[rx][cx+1]=='.') {
				m[rx][cx+1]=magic;
				pq.push(make_pair(-magic, make_pair(rx, cx+1)));
			}
		}
		ll atas=max(1LL, rx-2), bawah=min(r, rx+2), kiri=max(1LL, cx-2), kanan=min(c, cx+2);
		for (int i=atas; i<=bawah; i++) {
			for (int j=kiri; j<=kanan; j++) {
				if ((m[i][j]>magic+1||m[i][j]==-1)&&s[i][j]=='.') {
					m[i][j]=magic+1;
					pq.push(make_pair(-magic-1, make_pair(i, j)));
				}
			}
		}
	}
	cout<<m[rf][cf]<<endl;
}

Measured memory_bytes: 12648
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;

void swap(int &a, int &b) {
    a ^= b;
    b ^= a;
    a ^= b;
}

uint tzcnt(uint x) {
    x = ~x & (x - 1);
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int c[100000 + 1];
int c2[100000 + 1];

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

    int N;
    cin >> N;

    int sum = 0;

    int prev1 = 0;
    int prev2 = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;

        c[i] = abs(a - prev1);
        c2[i] = abs(a - prev2);

        prev2 = prev1;
        prev1 = a;

        sum += c[i];
    }

    c[N] = abs(prev1);
    c2[N] = abs(prev2);

    sum += c[N];

    for (int i = 0; i < N; ++i) {
        out(sum - c[i] - c[i + 1] + c2[i + 1]);
    }

    int aaa;
    cin >> aaa;
}


Measured memory_bytes: 2048
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <random>
#include <set>
#include <map>
#include <queue>
#include <bitset>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

vector<int> G[100002],a,b;



int main(){
	int N;
	cin >> N;
	a.resize(N);
	b.resize(N);
	map< pair<int,int>,int > ans;
	FOR(i,0,N-1){
		cin >> a[i] >> b[i];
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	int maxc = 0;

	vector<int> pa_c(N+1,0),did(N+1,0);
	did[1] = 1;
	queue<int> q;
	q.push(1);

	while(q.size()){
		int x = q.front();
		q.pop();
		int k = 1;
		for(auto y:G[x]){
			if(did[y])continue;
			if(k==pa_c[x])k++;
			ans[ make_pair(min(x,y),max(x,y)) ] = k;
			pa_c[y] = k;
			maxc = max(maxc,k);
			q.push(y);
			did[y] = 1;
			k++;
		}
	}

	cout << maxc << endl;
	FOR(i,0,N-1){
		cout << ans[make_pair(a[i],b[i])] << endl;
	}

}


Measured memory_bytes: 13824
#include<stdio.h>
int main(void)
{
	int t[4],n[4],i,s[4];
	for(i=1;i<=4;i++){
		scanf("%d",&t[i]);
		scanf("%d",&n[i]);
	}
	for(i=1;i<=4;i++){
		if(t[i]==1){
			s[i]=n[i]*6000;
		}
		if(t[i]==2){
			s[i]=n[i]*4000;
		}
		if(t[i]==3){
			s[i]=n[i]*3000;
		}
		if(t[i]==4){
			s[i]=n[i]*2000;
		}
	}
	for(i=1;i<=4;i++){
		printf("%d\n",s[i]);
	}
	return 0;
}


Measured memory_bytes: 2080
#!/usr/bin python3
# -*- coding: utf-8 -*-

n, m = map(int, input().split())
s = input()
s = s[::-1]
INF = 2*n

if '1'*m in s:
    print(-1)
    exit()

dp = [-1] * (n+1)
nw = 0
st = 0
nst = 0
ret = []
while nw < (n+1):
    if s[nw]=='1':
        dp[nw] = INF
    else:
        dp[nw] = dp[st] + 1
        nst = nw
    nw += 1
    if nw == n+1:
        ret.append(nst-st)
    elif nw > st + m:
        ret.append(nst-st)
        st = nst
print(' '.join(map(str,ret[::-1])))

Measured memory_bytes: 21484
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll a,b,x;
  cin>>a>>b>>x;
  if(a%x==0) {
cout<<b/x-a/x+1<<endl;
  }
  else {
cout<<b/x-a/x<<endl;
  }
}
  
  

Measured memory_bytes: 3636
import bisect
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
 
N = int(input())
A = tuple(map(int, input().split()))
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = map(int, input().split())
    graph[x].append(y)
    graph[y].append(x)
 
ans = [-1] * (N + 1)
inf = 10**18
LIS = [inf] * (N + 1)
 
def DFS(s, parent=0):
    a = A[s - 1]
    i = bisect.bisect_left(LIS, a)
    v = LIS[i]
    LIS[i] = a
    ans[s] = bisect.bisect_left(LIS, inf)
    for t in graph[s]:
        if t == parent:
            continue
        DFS(t, s)
    LIS[i] = v
    return
 
DFS(1)
print(*ans[1:], sep="\n")

Measured memory_bytes: 271252
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll mod = 1000000007;

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

  int n;
  cin >> n;

  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);

  rep(i, n) cin >> a[i] >> b[i] >> c[i];

  vector<vector<int>> dp(3, vector<int>(n+1, 0));
  dp[0][0] = dp[1][0] = dp[2][0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      if (j == 0) {
        chmax(dp[1][i+1], dp[0][i] + b[i]);
        chmax(dp[2][i+1], dp[0][i] + c[i]);
      } else if (j == 1) {
        chmax(dp[0][i+1], dp[1][i] + a[i]);
        chmax(dp[2][i+1], dp[1][i] + c[i]);
      } else if (j == 2) {
        chmax(dp[0][i+1], dp[2][i] + a[i]);
        chmax(dp[1][i+1], dp[2][i] + b[i]);
      }
    }
  }

  cout << max(dp[0][n], max(dp[1][n], dp[2][n])) << endl;

  return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define inf (int)(1e18)

int min(int a, int b){
	return a <= b ? a : b;
}

signed main(){
	int N, s, t, i, j, k, ans = 0;
	scanf("%lld", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	int *b = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &a[i]);
	}
	for(i = 0; i < N; i++){
		scanf("%lld", &b[i]);
	}
	int **dis = (int **)malloc(sizeof(int *) * 51);
	for(i = 0; i <= 50; i++){
		dis[i] = (int *)malloc(sizeof(int) * 51);
	}

	for(i = 0; i <= 50; i++){
		dis[i] = (int *)malloc(sizeof(int) * 51);
		for(j = 0; j <= 50; j++){
			dis[i][j] = i == j ? 0 : inf;
		}
	}
	for(i = 0; i <= 50; i++){
		for(j = 1; j <= 50; j++){
			dis[i][i % j] = min(dis[i][i % j], (int)1 << j);
		}
	}
	for(k = 0; k <= 50; k++){
		for(i = 0; i <= 50; i++){
			for(j = 0; j <= 50; j++){
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	for(i = 0; i < N; i++){
		if(dis[a[i]][b[i]] == inf){
			printf("-1\n");
			return 0;
		}
	}

	for(s = 50; s >= 0; s--){
		for(t = 0; t <= s; t++){

			for(i = 0; i <= 50; i++){
				for(j = 0; j <= 50; j++){
					dis[i][j] = i == j ? 1 : 0;
				}
			}
			for(i = 0; i <= 50; i++){
				for(j = 1; j <= 50; j++){
					if((ans & ((int)1 << j)) != 0 || j <= t){
						dis[i][i % j] = 1;
					}
				}
			}
			for(k = 0; k <= 50; k++){
				for(i = 0; i <= 50; i++){
					for(j = 0; j <= 50; j++){
						dis[i][j] = dis[i][j] | (dis[i][k] & dis[k][j]);
					}
				}
			}
			int f = 1;
			for(i = 0; i < N; i++){
				if(dis[a[i]][b[i]] == 0){
					f = 0;
					break;
				}
			}
			if(f == 1){
				ans |= (int)1 << t;
				break;
			}

		}
	}

	printf("%lld\n", ans - 1);
	return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


bool war(int N,int M,int X,int Y,vi& x,vi& y) {
    assert(X < Y);
    sort(ALL(x));
    sort(ALL(y));
    int xmax = x.back(), ymin = y[0];
    for (int z=X+1; z<=Y; ++z) {
        if (xmax < z && z <= ymin) return false;
    }
    return true;
}

int main() {
    int N,M,X,Y; cin >> N >> M >> X >> Y;
    vi x(N), y(M);
    rep(i,N) cin >> x[i];
    rep(i,M) cin >> y[i];
    cout << (war(N,M,X,Y,x,y) ? "War":"No War") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int sum=0;
	int ch;
	
	while((ch = getchar()) != EOF){
		
			
		if(ch == '\n') {
			if(sum == 0) break;
			printf("%d\n",sum);
			sum=0;	
		}
	
		else{
			sum += ch - '0';
		}
	}
	
		return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back

int main()
{
    int n;
    scanf("%i",&n);
    vector<int> niz(n);
    for(int i=0;i<n;i++)
        scanf("%i",&niz[i]);
    sort(niz.begin(),niz.end());
    deque<int> res,nb;
    for(int i=0;i<n;i++)
        nb.pb(niz[i]);
    deque<int> nb2=nb;
    res.push_back(niz[0]);
    nb.pop_front();
    while(!nb.empty())
    {
        res.push_back(nb.back());
        nb.pop_back();
        if(nb.empty())
            break;
        res.push_front(nb.back());
        nb.pop_back();
        if(nb.empty())
            break;
        res.push_back(nb.front());
        nb.pop_front();
        if(nb.empty())
            break;
        res.push_front(nb.front());
        nb.pop_front();
    }
    ll r=0;
    //printf("Resenje1:\n");
    int prev=res.front();
    //printf("%i ",prev);
    res.pop_front();
    for(int i=1;i<n;i++)
    {
        int x=res.front();
        //printf("%i ",x);
        res.pop_front();
        r+=(ll)abs(x-prev);
        prev=x;
    }
    //printf("\n");
    nb=nb2;
    res.clear();
    res.push_back(niz[n-1]);
    nb.pop_back();
    while(!nb.empty())
    {
        res.push_back(nb.front());
        nb.pop_front();
        if(nb.empty())
            break;
        res.push_front(nb.front());
        nb.pop_front();
        if(nb.empty())
            break;
        res.push_back(nb.back());
        nb.pop_back();
        if(nb.empty())
            break;
        res.push_front(nb.back());
        nb.pop_back();
    }
    ll r2=0;
    //printf("Resenje2:\n");
    prev=res.front();
    //printf("%i ",prev);
    res.pop_front();
    for(int i=1;i<n;i++)
    {
        int x=res.front();
        //printf("%i ",x);
        res.pop_front();
        r2+=(ll)abs(x-prev);
        prev=x;
    }
    //printf("\n");
    printf("%lld\n",max(r,r2));
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define sni(x) scanf("%d",&x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for(int i = 0 ; i < n ;i ++)
#define repc(i, n) for(int i = 0 ; i < n ; i ++)
#define FOR(i, x, y) for(int i = x ; i < y ; i ++)
#define DEC(i, x, y) for(int i = x ; i >= y ; i --)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b,c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a+n
using namespace std;
#define ll long long
double pi=3.141592653589793238462643383279;

ll a[100005];
ll n,k;
ll check(ll d)
{
    ll res=0;
    for(ll i=0;i<n-1;i++)
    res+=(a[i+1]-a[i]-1)/d;
    if(res<=k)
    return 1;
    else
    return 0;
}
int main() {
   double r;
   cin>>r;
   cout<<fixed<<setprecision(20);
   cout<<(2.0*pi*r);
}


Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>

using namespace std;

int main(void){

	int n,a,d1,d2,ans,dist;
	
	while(cin >> n,n){
		ans=0,dist=0;
		for(int i=0;i<n;i++){
			cin >> a >> d1 >> d2;
			if(d1+d2>dist)ans=a,dist=d1+d2;
		}
	
		cout << ans <<" "<< dist << endl;
	}
	
return 0;
}

Measured memory_bytes: 1160
S = input()
mae = int(S[:2])
ushiro = int(S[2:])
if 0 < mae < 13:
    if 0 < ushiro < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0 < ushiro < 13:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#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 N = int(S.size());
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += (int(S[i] - '0') == i % 2);
	}
	ans = min(ans, N-ans);
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

int main(){
    double a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f){
        double delta = a*e-b*d;
        double x = round((e*c-b*f)/delta * 1000)/1000;
        double y = round((-d*c+a*f)/delta*1000)/1000;
        if(x==0) x = 0.000;
        if(y==0) y = 0.000;
        printf("%.3lf %.3lf\n", x, y);    
    }
    return 0;
}


Measured memory_bytes: 3220
#include<iostream>

using namespace std;

int main(){
  int x,y;

  while(cin >> x >> y)
    if(x==0&&y==0){
      break;
    }

    else if(x<=y){
      cout << x << " " << y << endl;
    }
    else
      cout << y << " " << x <<endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) ((a>b)?a:b);
#define min(a,b) ((b>a)?a:b);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)                                 //g++ template.cpp -o template.exe
#define zeroes(x) memset(x,0,sizeof(x))                                        //all elements to 0
#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;







bool sortbysec(const pair<int,int> &a,                         //sorting of elements wrt second
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 




int main()
{
	
int a,b;
cin>>a>>b;
if((a-2*b)<0)
	cout<<"0";
else
	cout<<a-2*b;
return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] val = new int[N*3];
    for(int i = 0; i < N*3; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(val);
    
    long ans = 0;
    for(int i = N; i < N*3; i+=2){
      ans += val[i];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 63800
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

const int MAX_SIZE = 1010;

typedef unsigned long long ull;

int to_num(char c){
  if(isupper(c)) return c - 'A';
  if(islower(c)) return 26 + c - 'a';
  if(isdigit(c)) return 52 + c - '0';
  if(c == '+') return 62;
  if(c == '/') return 63;
  assert(false);
}

void input(int H, int W, bool grid[MAX_SIZE][MAX_SIZE]){
  REP(y, H) {
    string s;
    cin >> s;
    REP(bx, s.size()){
      int n = to_num(s[bx]);
      for(int dx = 5; dx >= 0; dx--){
        int x = bx * 6 + dx;
        grid[y][x] = n % 2;
        n /= 2;
      }
    }
  }
}

int W, H, P;
bool image[MAX_SIZE][MAX_SIZE];
bool pattern[MAX_SIZE][MAX_SIZE];
ull hash[MAX_SIZE][MAX_SIZE];
ull tmp[MAX_SIZE][MAX_SIZE];
ull compute_hash(bool a[MAX_SIZE][MAX_SIZE], int W, int H){
  ull B1 = 9973ULL;
  ull B2 = 100000007ULL;

  ull t1 = 1; // B1のP乗
  ull t2 = 1; // B2のP乗
  REP(_, P) t1 *= B1;
  REP(_, P) t2 *= B2;

  // 横方向
  for(int y = 0; y < H; y++){
    ull e = 0;
    REP(x, P) e = e * B1 + a[y][x];
    for(int x = 0; x + P <= W; x++){
      tmp[y][x] = e;
      e = e * B1 - a[y][x] * t1 + a[y][x + P];
    }
  }

  // 縦方向
  for(int x = 0; x < W; x++){
    ull e = 0;
    REP(y, P) e = e * B2 + tmp[y][x];
    for(int y = 0; y + P <= H; y++){
      hash[y][x] = e;
      e = e * B2 - tmp[y][x] * t2 + tmp[y + P][x];
    }
  }
}

void rotate(){
  bool tmp[MAX_SIZE][MAX_SIZE];
  memcpy(tmp, pattern, sizeof tmp);
  for(int y = 0; y < P; y++){
    for(int x = 0; x < P; x++){
      pattern[x][P - 1 - y] = tmp[y][x];
    }
  }
}
void reflect(){
  bool tmp[MAX_SIZE][MAX_SIZE];
  memcpy(tmp, pattern, sizeof tmp);
  for(int y = 0; y < P; y++){
    for(int x = 0; x < P; x++){
      pattern[y][P - 1 - x] = tmp[y][x];
    }
  }
}
int main(){
  while(cin >> W >> H >> P && W){
    input(H, W, image);
    input(P, P, pattern);
    set<ull> hash_set;
    for(int r = 0; r < 8; r++){
      compute_hash(pattern, P, P);
      hash_set.insert(hash[0][0]);

      if(r == 3) reflect();
      else rotate();
    }
    compute_hash(image, W, H);
    int ans = 0;
    for(int y = 0; y + P <= H; y++){
      for(int x = 0; x + P <= W; x++){
        if(hash_set.count(hash[y][x])) ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 19576
#include<iostream>
#include "algorithm"
#include "bits/stdc++.h"
using namespace std ;
long long n,q,m,x,y;
long long sum=0;
long long c[100050];
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>m;
        c[m]++;
        sum+=m;
    }
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>x>>y;
        sum+=c[x]*y;
        sum-=c[x]*x;
        c[y]+=c[x];
        c[x]=0;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 4408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
using namespace std;
static const uint64_t MOD = 1000000007LL; /* 10^9 + 7 */

uint64_t dp[100005][13];
uint64_t x;

void update(int n)
{
    if (x == 0) {
        dp[x + 1][n] = 1;
        return;
    }   
    for (int i = 0; i < 13; i++) {
        dp[x + 1][(i * 10 + n) % 13] += dp[x][i];
        dp[x + 1][(i * 10 + n) % 13] %= MOD;
    }   
}

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

    int len = s.length();

    for (int i = 0; i < len; i++) {
        if (s[i] == '?') {
            for (int i = 0; i < 10; i++) {
                update(i);
            }   
        } else {
            int n = s[i] - '0';
            update(n);
        }   
        x++;
    }   

    cout << dp[len][5] << endl;
}

Measured memory_bytes: 10624
import java.util.Scanner;

class Main {
    private static int dp[];

    private static int cost(int i, int w, int[] a) {
        int result;
        if (i == a.length) {
            result = 0;
        } else if (dp[i] > 0) {
            result = dp[i];
        } else {
            int s = 0;
            int j = i;
            for (; j < a.length && a[j] <= w - s; j++) {
                s += a[j];
            }
            if (s == w) {
                result = cost(j, w, a);
            } else if (j == a.length) {
                result = 0;
            } else {
                result = Math.min(cost(j, w, a) + w - s, cost(j + 1, w, a) + s + a[j] - w);
            }
            dp[i] = result;
        }
        return result;
    }

    private static void solve() {
        final Scanner scanner = new Scanner(System.in);

        for (int i = 1; ; i++) {
            final int n = scanner.nextInt();
            final int w = scanner.nextInt();
            if (n == 0 && w == 0) {
                break;
            }
            final int a[] = new int[n];
            for (int j = 0; j < n; j++) {
                a[j] = scanner.nextInt();
            }
            dp = new int[n];
            System.out.println(String.format("Case %d: %d", i, cost(0, w, a)));
        }
    }

    public static void main(String... args) {
        solve();
    }
}

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

int main() {
  int N;
  cin>>N;
  int div=0;
  int n=N;
  
  while(n>0){
    div+=(n%10);
    n/=10;
  }
  
  if(N%div==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}


Measured memory_bytes: 256