akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < (n);i++)
#define lint long long
const lint mod=1e9+7;
const lint inf=2.19e15+1;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

signed main(){
    lint x,k,d;
    cin >> x >> k >> d;
    if (x < 0){
        x = -x;
    }
    lint num = x / d;
    if (num > k){
        cout << x - k * d << endl;
    }
    else{
        if (k * d == x){
            cout << 0 << endl;
        }
        else if ((k - num) % 2 == 0){
            cout << x - num * d << endl;
        }
        else { 
            cout << (num + 1) * d - x << endl;
        }
    }
}


Measured memory_bytes: 3624
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

vector<int> prime(int n){
    vector<int> t;
    vector<bool> x(n+1, true);
    t.push_back(2);

    int i;
    for(i = 3; i * i <= n; i += 2){
        if(!x[i]){
            continue;
        }
        t.push_back(i);
        for(int j = i; j <= n; j += i){
            x[j] = false;
        }
    }
    for(; i <= n; i += 2){
        if(x[i]){
            t.push_back(i);
        }
    }
    return t;
}

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

    int n;
    cin >> n;

    vector<int> p = prime(n);
    vector<int> cnt(SZ(p));
    for(int i = 1; i <= n; i++){
        int x = i;
        for(int j = 0; j < SZ(p); j++){
            while(x % p[j] == 0){
                x /= p[j];
                cnt[j]++;
            }
        }
    }

    int ans = 0;

    rep(i, SZ(p)){
        if(cnt[i] >= 74){
            ans++;
        }
        for(int j = i + 1; j < SZ(p); j++){
            if(cnt[i] >= 2 && cnt[j] >= 24){
                ans++;
            }
            if(cnt[i] >= 24 && cnt[j] >= 2){
                ans++;
            }
            if(cnt[i] >= 4 && cnt[j] >= 14){
                ans++;
            }
            if(cnt[i] >= 14 && cnt[j] >= 4){
                ans++;
            }
            for(int k = j + 1; k < SZ(p); k++){
                if(cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4){
                    ans++;
                }
                if(cnt[i] >= 4 && cnt[j] >= 2 && cnt[k] >= 4){
                    ans++;
                }
                if(cnt[i] >= 4 && cnt[j] >= 4 && cnt[k] >= 2){
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string.h>
using namespace std;

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

    string s;
    int sum = 0;

    getline(cin,s);
    int d = s.size();


    for(int i = 0;i < d;i++)
    {
        sum += (s[i]-'0');

    }

    if(sum%9== 0)
    {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}



int main() {
    ll ans = 0;
    ll K;
    cin >> K;
    for (ll a = 1;a<=K;a++) {
        for (ll b = 1;b<=K;b++) {
            for (ll c = 1;c<=K;c++) {
                ans += GCD(a,GCD(b,c));
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	static int n,m;
	static long[][] cake;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		 n = Integer.parseInt(sc.next());
		 m = Integer.parseInt(sc.next());
		
		cake = new long [n][3];
		
		for(int i = 0 ; i < n ;i++) {
			cake[i][0] = Long.parseLong(sc.next());
			cake[i][1] = Long.parseLong(sc.next());
			cake[i][2] = Long.parseLong(sc.next());
		}
		
		long ans = -1;
		
		for(int i = 0 ; i < Math.pow(2, 3) ;i++) {
			int []x = new int [3];
			long []sum = new long [n];
			for(int j = 0 ; j < 3 ; j++) {
				if(((i >> j) & 1) == 1) {
					x[j] = 1;
				}
				else {
					x[j] = -1;
				}
			}
			
			for(int j  = 0 ; j < n ;j++) {
				for(int k = 0 ; k < 3 ;k++) {
					if(x[k] == 1) {
						sum[j] += cake[j][k];
					}
					else {
						sum[j] -= cake[j][k];
					}
				}
			}
			
			Arrays.sort(sum);
			long temp = 0;
			for(int j = n-1 ; j > n-1-m ;j--) {
				temp += sum[j];
				//System.out.println(sum[j]);
			}
			ans = Math.max(temp, ans);
		}
		
		System.out.println(ans);
	}
}



Measured memory_bytes: 26324
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 18;
typedef long long ll;
const int mod = 1e9 + 7;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
inline void reduce(int & x) {
	x += x >> 31 & mod;
}
int n, x, y, z;
int f[41][1 << maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> x >> y >> z;
	int all = (1 << x + y + z) - 1;
	f[0][0] = 1, -- x;
	rep(i, 0, n - 1) {
		rep(j, 0, all) {
			rep(k, 1, 10) {
				int s = (j << k | 1 << k - 1) & all;
				if(!(s >> x & 1) || !(s >> x + y & 1) || !(s >> x + y + z & 1)) {
					reduce(f[i + 1][s] += f[i][j] - mod);
				}
			}
		}
	}
	int ans = pow(10, n);
	rep(j, 0, all) {
		reduce(ans -= f[n][j]);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 40192
#include <iostream>

using namespace std;

int F[50];

int main(void) {
	int n;
	cin >> n;
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= n; i++) {
		F[i] = F[i-1] + F[i-2];
	}
	cout << F[n] << endl;
	
}



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <ll M = MOD> struct modint {
    ll val;
    modint(const ll x = 0) : val(x) {
        val = x;
        while(val < 0) val += M;
        while(val > M) val -= M;
    }

    modint operator+(const modint a) const { return modint(*this) += a; }
    modint operator-(const modint a) const { return modint(*this) -= a; }
    modint operator*(const modint a) const { return modint(*this) *= a; }
    modint operator/(const modint a) const { return modint(*this) /= a; }
    modint operator-() const { return modint(M-val); }
    modint inv() const {
        ll u = 1, v = 0, s = 0, t = 1, m = M, x = val;
        while (x) {ll q = m/x; swap(s -= q*u, u); swap(t -= q*v, v); swap(m -= q*x, x); }
        if(s < 0) s += M;
        return modint(s);
    }
    modint pow(ll n) const {
        ll u = 1, xx = val;
        while (n > 0){ if (n&1) u = u * xx % M; xx = xx * xx % M; n >>= 1; }
        return modint(u);
    }
    modint& operator+=(const modint a){ val += a.val; if(val >= M) val -= M; return *this; }
    modint& operator-=(const modint a){ val -= a.val; if(val < 0) val += M; return *this; }
    modint& operator*=(const modint a){ val = val * a.val % M; return *this; }
    modint& operator/=(const modint a){ val = val * a.inv().val % M; return *this;}

    modint& operator=(const int& x){
        val = x;
        while(val < 0) val += M;
        while(val > M) val -= M;
        return *this;
    }
};

using mint = modint<MOD>;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n, k;
    cin >> n >> k;
    auto dp = make_v(n+1, n*n, mint(0));
    dp[n][0] = 1;
    int m = 0;
    for (int i = n; i >= 1; --i) {
        int mm = m;
        for (int j = 0; j <= m; ++j) {
            for (int l = 0; l <= k; ++l) {
                if(i < l){
                    dp[i-1][j] += dp[i][j];
                }else {
                    dp[i-1][j+(j+l)/i] += dp[i][j];
                    mm = max(mm, j+(j+l)/i);
                }
            }
        }
        m = mm;
    }
    mint ans = mint(n)*mint(k+1).pow(n-1)*mint(k)*mint(k+1)*mint(2).inv();
    for (int i = 0; i <= m; ++i) {
        ans -= dp[0][i]*mint(i);
    }
    cout << ans.val << "\n";
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int C[9];
int INV[200];
typedef long long ll;
int main()
{
    ll X;
    cin >> X;
    ll ans = 0;
    ans += (X/500) * 1000;
    X -= (X/500) * 500;
    ans += (X/5) * 5;
    cout << ans;
    
    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 a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if((b-a) == (c-b)){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>

using namespace std;

const double PI = 3.14159265358979323846;

int main() {
    //cout.precision(16);
    int v[] = {6000, 4000, 3000, 2000};
    int a,b;
    while (cin >> a >> b) {
        cout << (v[a - 1] * b) << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.math.*;
import java.io.*;


public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]) {
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();
        int ans = 0;
        for(int i = 0; i <= n; i++) {
            if(r * i > n) break;
            for(int j = 0; j <= n; j++) {
                if(r * i + g * j > n) break;
                if((n - r * i - g * j ) % b == 0) ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,sum;
  sum=0;
    cin >> A >> B;
  if(A>=B){
    sum+=A;
   A--;
  }
  else{
    sum+=B;
    B--;
  }
  if(A>=B){
    sum+=A;
  }
  else{
    sum+=B;
  }
  cout << sum << endl;
}
  

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


public class Main {
	public static void main(String[] args) throws Exception {
		MScanner sc = new MScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		String days[]= {"MON", "TUE", "WED", "THU", "FRI","SAT","SUN"};
		String in=sc.nextLine();
		int idx=0;
		for(int i=0;i<days.length;i++) {
			if(days[i].equals(in)) {
				idx=i;break;
			}
		}
		int ans=((6-idx+7)%7);
		if(ans==0) {
			pw.println(7);
		}
		else
		pw.println(ans);
		pw.flush();
	}

	static class MScanner {
		StringTokenizer st;
		BufferedReader br;

		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int[] takearr(int n) throws IOException {
			int[] in = new int[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			return in;
		}

		public long[] takearrl(int n) throws IOException {
			long[] in = new long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			return in;
		}

		public Integer[] takearrobj(int n) throws IOException {
			Integer[] in = new Integer[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			return in;
		}

		public Long[] takearrlobj(int n) throws IOException {
			Long[] in = new Long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			return in;
		}

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

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 22100
# -*- coding: utf-8 -*-
from itertools import product
n,a,b,c = map(int, input().split())
ll = [int(input()) for _ in range(n)]

res = 10**10
for t in product([0,1,2,3], repeat=n):
    x = [0,0,0]
    y = [0,0,0]
    for i in range(len(t)):
        if t[i]==3:
            continue
        x[t[i]] += ll[i]
        y[t[i]] += 1
    if min(x)==0:
        continue
    for i in range(3):
        if y[i]>=2:
            y[i] -= 1
        elif y[i]==1:
            y[i] = 0

    x.sort()
    tmp = abs(a-x[2])+abs(b-x[1])+abs(c-x[0])+10*sum(y)
    res = min(res, tmp)

print(res)


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


int main() {
    int a,b;
    cin>>a>>b;
    if((a+b)/2*2==a+b)cout << (a+b)/2 <<endl;else cout << "IMPOSSIBLE" <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K;
  cin >> N >> K;
  vl A(N, 0);
  ll sum = 0;
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
  }

  vl DP(K + 1, 0);
  vl DDP(K + 1, 1);
  // DP[0][0] = 1;
  REP(i, N) {
    REP(j, K + 1) DP[j] = 0;
    REP(j, K + 1) {
      DP[j] += DDP[j];
      DP[j] %= MOD;
      if (j - A[i] - 1 >= 0) {
        DP[j] -= DDP[j - A[i] - 1];
        DP[j] += MOD;
        DP[j] %= MOD;
      }
    }
    // REP(j, K + 1) cout << DP[j] << endl;
    // cout << "---------" << endl;
    DDP[0] = DP[0];
    FOR(j, 1, K + 1) { DDP[j] = (DDP[j - 1] + DP[j]) % MOD; }
  }
  cout << DP[K] << endl;

  return 0;
}


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


int main() {
    string str;
    int nc[26] = {};

    while (getline(cin, str)) {
        for (int i = 0; i < (int)str.length(); i++) {
            if ('a' <= str[i] && str[i] <= 'z') nc[str[i] - 'a']++;
            if ('A' <= str[i] && str[i] <= 'Z') nc[str[i] - 'A']++;
        }
    }
    for (int i = 0; i < 26; i++) {
        cout << (char)('a' + i) << " : " << nc[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3168
// 2020-08-26 21:49:36
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
ll f(ll p1, ll p2, ll q1, ll q2) {
  if (p1 < q1 && p2 <= q2) return p2 * q2;
  if (p1 >= q1 && p2 > q2) return p1 * q1;
  ll s = p1 + q1;
  return (s / 2) * ((s + 1) / 2);
}
bool ok(ll a, ll b, ll x) {
  ll res = 0;
  if (x < a && x < b) {
    chmax(res, f(1, x, x, 1));
  } else if (x >= a && x < b) {
    chmax(res, f(1, a - 1, x, x - (a - 1) + 1));
    chmax(res, f(a + 1, x + 1, x - (a - 1), 1));
  } else if (x < a && x >= b) {
    chmax(res, f(1, x + 1 - b, x + 1, b + 1));
    chmax(res, f(x + 1 - b + 1, x, b - 1, 1));
  } else if (a - 1 == x + 1 - b) {
    ll sz = a - 1, l = 1, r = x + 1;
    chmax(res, f(l, l + sz - 1, r, r - sz + 1));
    l += sz + 1, r -= sz + 1;
    chmax(res, f(l, x + 1, r, 1));
  } else {
    ll sz = min(a - 1, x + 1 - b), l = 1, r = x + 1;
    int lt = a - 1 < x + 1 - b;
    chmax(res, f(l, l + sz - 1, r, r - sz + 1));
    l += sz + lt, r -= sz + !lt, sz = max(a - 1, x + 1 - b) - sz;
    chmax(res, f(l, l + sz - 1, r, r - sz + 1));
    l += sz + !lt, r -= sz + lt;
    chmax(res, f(l, x + 1, r, 1));
  }
  return res < a * b;
}
void answer() {
  ll a, b;
  cin >> a >> b;
  ll l = 0, r = a + b;
  while (l + 1 < r) {
    ll x = (l + r) / 2;
    if (ok(a, b, x)) {
      l = x;
    } else {
      r = x;
    }
  }
  cout << l << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int q;
  cin >> q;
  rep(_, q) answer();
  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#define MAX 500001
#define SENTINEL 2000000000

 int count=0;

 int merge(int S[],int left,int right,int mid){
         int n1,n2,i,L[MAX],R[MAX],j,k;
         n1=mid-left;
         n2=right-mid;
         for(i=0;i<n1;i++){L[i]=S[left+i];}
         for(i=0;i<n2;i++){R[i]=S[mid+i];}
         L[n1]=R[n2]=SENTINEL;
         i=0;
         j=0;
         for(k=left;k<right;k++){
                        count++;
                        if(L[i]<=R[j]){S[k]=L[i];
                                      i++;
                                      }
                        else {S[k]=R[j];
                              j++;
                              }
                        }
          }
                                   
                    

 int mergesort(int S[],int left,int right){
        if(right-left>1){
             int mid=(left+right)/2;
             mergesort(S,left,mid);
             mergesort(S,mid,right);
             merge(S,left,right,mid);
             }
        }

 int main(){
        int i,n;
        
        int S[MAX];
        scanf("%d",&n);
        for(i=0;i<n;i++){
                   scanf("%d",&S[i]);
                   }
        
        mergesort(S,0,n);
        for(i=0;i<n;i++){
                   printf("%d%c",S[i],(i==n-1)?'\n':' ');
                   }
        printf("%d\n",count);
        return 0;
        }




Measured memory_bytes: 5672
L = 100005

n,c = map(int, input().split())

arr = [[0]*L for j in range(c)]
for _ in range(n):
    s,t,col = map(lambda x:int(x)-1, input().split())
    arr[col][s] += 1
    arr[col][t] -= 1

imos = [0]*L

for i in range(c):
    for p in range(L):
        if arr[i][p] == 1: imos[p] += 1
        if arr[i][p] == -1: imos[p+1] -= 1

ans = 0
for i in range(1,L):
    imos[i] += imos[i-1]
    ans = max(ans, imos[i])

print(ans)


Measured memory_bytes: 29428
#include<stdio.h>

int i,j,k,n;
double x[9],y[9];

int main(){
	while(scanf("%lf%lf",&x[0],&y[0])!=EOF){
		for(i=1;i<4;i++)scanf("%lf%lf",&x[i],&y[i]);
		if((x[1]-x[0])*(x[3]-x[2])+(y[1]-y[0])*(y[3]-y[2])==0)printf("YES\n");
		else if(x[1]==x[0] && y[3]==y[2])printf("YES\n");
		else if(y[1]==y[0] && x[3]==x[2])printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(ll i = 0; i<n; i++)
#define rep_s(i, start, n) for(ll i= start;  i<n; i++)
#define rep_down(i, n) for(ll i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(ll i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()
#define print(ans) cout << ans << endl;
#define MOD 1000000007
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
 
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;
 
}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];
 
void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}
 
ll keta_num(ll num){
  ll total = 0;
  while(num){
    num /= 10;
    total++;
  }
}
 
 
ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}
 
bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}
 
ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
 
ll fibonacchi(ll num){
  ll f0 = 0, f1 = 1, f2;
  ll count = 0;
  while(count<num){
    f2 = f0+f1;
    f0 = f1;
    f1 = f2;
    count++;
  }
  return f2;
}
 
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
 
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
 
int main(void){
  ll N, M, A, B, C, D, E, F, G, K,L, W, H, P, Q, R, V, X, Y;
  ll S, T;
  cin >> A >> V >> B >> W >> T;
  if ((V-W)*T>=abs(B-A)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
vector<ll> v1,v2;
ll n;
int solve(int k){
  ll md=(1<<(k+1));
  vector<ll> a,b;
  for(int i=0;i<n;i++) a.push_back(v1[i]%md);
  for(int i=0;i<n;i++) b.push_back(v2[i]%md);
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  ll t=(1<<k);
  ll res=0;
  for(int i=0;i<n;i++) {
    ll pos1=lower_bound(b.begin(),b.end(),t-a[i])-b.begin();
    ll pos2=lower_bound(b.begin(),b.end(),t*2-a[i])-b.begin();
    ll pos3=lower_bound(b.begin(),b.end(),t*3-a[i])-b.begin();
    ll pos4=lower_bound(b.begin(),b.end(),t*4-a[i])-b.begin();
    res+=(pos2-pos1)+(pos4-pos3);
    res%=2;
  }
  return res;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    v1.push_back(a);
  }
  for(int i=0;i<n;i++){
    ll b;
    cin>>b;
    v2.push_back(b);
  }
  ll ans=0;
  for(int i=0;i<30;i++){
    if(solve(i)==1) ans+=(1<<i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 10628
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prinp(p) cout<<p.first<<" "<<p.second<<endl
#define prinv(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7,MAX = 1e6+5;
const ll INF = 1e18+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
///////////////////PnC/////////////////////
vl Fac(MAX),Inv(MAX);
void CalcFac()
{
	Fac[0]=Inv[0]=1;
	for(int i=1;i<MAX;i++)
	{
		Fac[i]=(Fac[i-1]*i)%MOD;
		Inv[i]=powN(Fac[i],MOD-2);
	}
}

ll NCR(int n,int r)
{
	if(r>n) return 0;
	return (((Fac[n]*Inv[r])%MOD)*Inv[n-r])%MOD;
}
///////////////////PnC/////////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vi MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

int main()
{
	int n;
	cin>>n;
	vi A(n);
	take(A,0,n);
	sort(all(A));
	reverse(all(A));
	ll sum=0;
	sum+=A[0];
	int i=1;
	int done=2;
	while(done<n)
	{
		sum+=A[i];
		done++;
		if(done%2==0) i++;
	}
	cout<<sum<<endl;
}	

Measured memory_bytes: 23848
#include <bits/stdc++.h>
using namespace std;
#define N (1<<17)
#define INF 1000000009
#define MOD 1000000007
typedef long long int ll;
#define sd(x) scanf("%lld",&x)
#define sd2(x,y) scanf("%lld%lld",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d",x);
#define pf2(x,y) printf("%d %d\n",x,y);
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z);
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tr(x) cout<<x<< endl;
#define tr2(x,y) cout<<x<<" "<<y<<" " << endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(x,y,z,a) cout<<x<<" "<<y<<" "<<z<<  " " << a << " " << endl;

ll dp[17][N],n;
ll a[22][22],s[N];
int main(){ 
    int i,j,t,x,y,k;
    cin >> n;
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            sd(a[i][j]);
        }
    }
    for(int mask=0; mask<(1<<n); mask++){
        for(i=0; i<n; i++){
            for(j=i+1; j<n; j++){
                if(mask&(1<<i) && mask&(1<<j)){
                    s[mask]+=a[i][j];
                }
            }
        }
    }
    for(i=1; i<=n; i++){
        for(int mask=0; mask<(1<<n); mask++){
            dp[i][mask]=-1000000000000000;
        }
    }
    for(i=1; i<=n; i++){
        for(int mask=1; mask<(1<<n); mask++){
            if(i==1){
                dp[i][mask]=s[mask];
            }
            
            else{
                for(j=mask;  j > 0; j = (j-1) & mask){
                    k=j^mask;
                    dp[i][mask]=max(dp[i][mask],dp[i-1][j]+s[k]);
                }
            }
            // tr3(i,mask,dp[i][mask]);
        }
    }
    ll ans=-1000000000000000;
    for(i=1; i<=n; i++){
        // tr2(i,dp[i][(1<<n)-1]);
        ans=max(ans,dp[i][(1<<n)-1]);
    }
    tr(ans);
    return 0;
}

Measured memory_bytes: 17280
# Aizu Problem 0017: Caesar Cipher
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

def caesar_decrypt(N, cipher):
    text = ""
    for char in cipher:
        if 'a' <= char <= 'z':
            k = (ord(char) - 97 - N) % 26
            text += chr(97 + k)
        else:
            text += char
    return text


for cipher in sys.stdin:
    cipher = cipher.strip()
    for k in range(26):
        decrypted = caesar_decrypt(k, cipher)
        if "this" in decrypted or "the" in decrypted or "that" in decrypted:
            print(decrypted)
            break

Measured memory_bytes: 7576
#include <iostream>
#include <queue>
#include <string>
using namespace std;

int main()
{
	priority_queue<int> PQ;
	string com;
	int n;
	
	while(cin >> com)
	{
		if(com == "end")
		{
			break;
		}
		if(com[0] == 'i')
		{
			cin >> n;
			PQ.push(n);
		}
		else if(com[0] == 'e')
		{
			cout << PQ.top() << endl;
			PQ.pop();
		}
	}
	
	return 0;
} 


Measured memory_bytes: 6948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	int a,b;
	cin >> a >> b;
	if(a>0){
		cout << "Positive" << endl;
	}else{
		if(b>=0)cout << "Zero" << endl;
		else{
			if((b-a+1)&1)cout << "Negative" << endl;
			else cout << "Positive" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
# n = int(sys.stdin.readline())
# a, b = map(int, sys.stdin.readline().split())
# c = list(map(int, sys.stdin.readline().split()))
# s = [list(map(int,list(sys.stdin.readline()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a = 100
# b = 0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋め, 小数点出力桁指定時のときの出力
# 000100-0.987654

import math
import sys
import itertools
import queue
from functools import reduce
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    A, B, C, D = map(int, sys.stdin.readline().split())
    A = A - 1
    c_div = int(B // C)
    d_div = int(B // D)
    cd_div = int(B // lcm(C, D))

    not_div1 = B - (c_div + d_div -cd_div)

    c_div = int(A // C)
    d_div = int(A // D)
    cd_div = int(A // lcm(C, D))

    not_div2 = A - (c_div + d_div -cd_div)

    print(not_div1 - not_div2)



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

int main(void) {
    string s;
    bool d[4] = {};
    cin >> s;
    for (auto c : s) {
        if (c == 'N') d[0] = true;
        else if (c == 'W') d[1] = true;
        else if (c == 'S') d[2] = true;
        else if (c == 'E') d[3] = true;
    }
    cout << (!(d[0] ^ d[2]) && !(d[1] ^ d[3]) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define M_PI 3.14159265358979
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


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

	int ans = 0;

	for (int i = 0; i < (N - 1); ++i) {
		for (int j = i + 1; j < N; ++j) {
			ans += d[i] * d[j];
		}
	}

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


Measured memory_bytes: 3596
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

	 char s;
	 cin>>s;
	 if(s>=65 && s<=90)
	 {
	 	cout << "A";
	 }
	 else
	 {
	 	cout << "a";
	 }




}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case;
    while(test_case--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 3628
import java.math.BigDecimal
fun main(args: Array<String>) {
    var (N,M) = readLine()!!.split(" ").map(String::toInt)
    var dict = (1..N).map{
            readLine()!!.split(" ").map(String::toLong)
            }.sortedBy{it[0]}

    var ans = 0L
    var cnt = M.toLong()
    for(i in 0..N-1){
        if(cnt == 0L) break
        var (a,b) = dict[i]
        ans += a * Math.min(b,cnt)
        cnt = Math.max(cnt-b,0)
    }
    println(ans)
   
}


Measured memory_bytes: 85276
//--- pE ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	List<Num> list;
	Long[][] mem;
	private void run_case() {
		int n = reader.ni();
		list = new ArrayList<>();
		mem = new Long[n][n];
		for (int i=0; i<n; i++) {
			list.add(new Num(reader.ni(), i));
		}
		Collections.sort(list, new ComparatorNum());
		long res = dfs(0, n-1, 0);
		out.println(res);
		return;
	}

	private long dfs(int l, int r, int idx) {
		if (l > r) return 0;
		if (mem[l][r] != null) return mem[l][r];
		long res = 0;
		res = Math.max(res, 1L * Math.abs(list.get(idx).idx - l) * list.get(idx).val + dfs(l + 1, r, idx + 1));
		res = Math.max(res, 1L * Math.abs(list.get(idx).idx - r) * list.get(idx).val + dfs(l, r - 1, idx + 1));
		mem[l][r] = new Long(res);
		return res;
	}
}

class Num {
	public int val, idx;
	public Num(int val, int idx) {
		this.val = val;
		this.idx = idx;
	}
}

class ComparatorNum implements Comparator<Num> {
	public int compare(Num a, Num b) {
		return b.val - a.val;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 110012
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    ll N, T;
    cin >> N >> T;

    ll tcur, tprev;
    ll ans = 0;
    ll diff;
    cin >> tprev;
    for (int i = 1; i < N; ++i) {
        cin >> tcur;
        diff = tcur - tprev;
        if (T <= diff) {
            ans += T;
        } else {
            ans += diff;
        }
        tprev = tcur;
    }

    cout << ans + T << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
if N == 1:
    print(1)
    exit()

x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = list(map(int, input().split()))

l = {}

for i in range(N):
    for j in range(i + 1, N):
        p = x[i] - x[j]
        q = y[i] - y[j]
        if p < 0:
            p = -p
            q = -q
        if p == 0:
            q = abs(q)
        if str([p, q]) in l:
            l[str([p, q])] += 1
        else:
            l[str([p, q])] = 1

print(N - max(l.values()))



Measured memory_bytes: 3188
# coding: utf-8
# Your code here!

s = list(input())
g,s_len=0,len(s)
for i in range(2**(s_len-1)):
    siki = s[0]
    for j in range(s_len-1):
        if i&(1<<j): siki+='+'
        siki+=s[j+1]
    tmp=0
    for j in range(len(siki)):
        if siki[j]!='+':
            tmp = tmp*10+int(siki[j])
        else:
            g+=tmp
            tmp=0
    g+=tmp
print(g)


Measured memory_bytes: 3060
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	var tmp = input[0].split(" ");

	// 1行目
	var N = parseInt(tmp[0], 10);
	var M = parseInt(tmp[1], 10);
	var C = parseInt(tmp[2], 10);

	// 2行目
	var B = input[1].split(" ");

	// 3行目以降
	var count = 0;
	var aryA, numA, numB, sum, j;

	for (var i = 2; i < input.length; i++) {
		// Aをtmpに格納
		aryA = input[i].split(" ");
		sum = 0;
		for (j = 0; j < aryA.length; j++) {
			numA = parseInt(aryA[j], 10);
			numB = parseInt(B[j], 10);
			sum += numA * numB;
		}
		sum += C;

		// 判定
		if (sum > 0) {
			count++;
		}
	}

	//出力
	console.log('%d', count);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
Main(function(input) {
	console.log(input.trim().split(' ').sort(function(a, b) {
		return (b - a);
	}).join(' '));
});

function Main(main) {
	var input = '';

	process.stdin.resume();
	process.stdin.setEncoding('utf8');
	process.stdin.on('data', function(chunk) {
		input += chunk;
	});
	process.stdin.on('end', function() {
		main(input);
	});
};

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll a,b,c,ans=0;
    cin >> a >>b >> c;
    a--;
    ans = b/c;
    ans -= a/c;
    cout << ans << nl;    
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

s1 = set()
s2 = set()
s3 = set()

for s in input():
  if s2:
    for s2_sub in s2:
      s3 |= {s2_sub+s}
  if s1:
    for s1_sub in s1:
      s2 |= {s1_sub+s}
  s1 |= {s}
  
print(len(s3))

Measured memory_bytes: 41964
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def bipartite_or_not(G, s=0):
    n = len(G)
    global color
    color = [0] * n
    color[s] = 1
    dq = deque([s])
    while dq:
        u = dq.popleft()
        for v in G[u]:
            if color[v] == 0:
                color[v] = -color[u]
                dq += [v]
            else:
                if color[u] == color[v]:
                    return False
    return True


n, m = LI()
G = [[] for _ in range(n)]
for a, b in LIR(m):
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]


if bipartite_or_not(G):
    print(color.count(1) * color.count(-1) - m)
else:
    print(n * (n - 1) // 2 - m)

Measured memory_bytes: 69552
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 998244353;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll mult(ll a, ll b) {
    return (a * b) % mod;
}


const int MAXN = 205;
const int MAXK = 20 + 3;

void solve() {

    string s, t;
    cin >> s >> t ;

    int minn= 1e9;

    for (int i = 0; i <= s.size() - t.size(); ++ i) {

        int curr = 0;

        for (int j = 0; j < t.size(); ++ j){
            if (s[i + j] != t[j]) ++curr;
        }

        minn = min(minn, curr);

    }

    cout << minn;

}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE
//    freopen("../input.in", "r", stdin);
#else

#endif
#ifdef multi
//        gen();
    multisolve();
#else
    solve();
//    gen();
#endif


    time_calc();

}


Measured memory_bytes: 3848