akhauriyash/Code-Regression huggingface dataset:
module Main where

import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import           Data.Array.IO
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  s <- getLine
  print $ min (f s $ cycle ['1', '0']) (f s $ cycle ['0', '1'])
  where
    f s l = length . filter (== False) $ zipWith (==) s l


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


using namespace std;

#define fto(i,a,b) for (int i = (a); i <= b; i++)
#define fdw(i,a,b) for (int i = (a); i >= b; i--)
#define rep(i,a) for(int i = 0; i < a; i++) 
#define read(a) cin >> a
#define read2(a, b) cin >> a >> b
#define read3(a, b, c) cin >> a >> b >> c
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define write(a) cout << a << " "
#define writeln(a) cout << a << "\n"

#define PI 3.14159265
#define oo 1000000000
#define debug(a) cout << #a << " = " << a << endl

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define next thongdeptrai
#define prev thongbachuthegioi
#define y1 thongsieucapvutru
#define y0 thongnotgay

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

#define maxn 100005

using namespace std;

int n, a[maxn];
int res, t;
bool isPos;

int main() {
	//#ifndef ONLINE_JUDGE
  //  	freopen("in.inp", "r", stdin);
  //  #endif

    read(n);

    int t = 0;
    for(int i = 1; i <= n; i++) {
    	read(a[i]);

		//code too ambiguous, not clear on each state

    	if (t == 0) {
    		t++;
    		res++;
    	}
    	else if (t == 1) {
    		if (a[i] - a[i - 1] != 0) {
    			if (a[i] - a[i - 1] < 0) isPos = false;
    			else isPos = true;
    			t++;
    		}
    	}
    	else if (t == 2) {
    		if (isPos && a[i] - a[i - 1] < 0) {
    			t = 1;
    			res++;
    		}
    		if (!isPos && a[i] - a[i - 1] > 0) {
    			t = 1;
    			res++;
    		}
    	}

    }

    write(res);

 //	#ifndef ONLINE_JUDGE
 //   	cout << endl;
 //   	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
//	#endif
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
string a, b, c;
int main(void) {
    cin >> a >> b >> c;
    (a[a.size()-1] == b[0] && b[b.size()-1] == c[0] ? cout << "YES" << endl : cout << "NO" << endl);
    return 0;
}

Measured memory_bytes: 3640
N = int(input())
S = list(input())

e_count = S.count('E')
w_count = S.count('W')

# print(e_count)
# print(w_count)


left_w = 0
right_e = e_count
min_cost = len(S)-1

for i in range(len(S)):
    if i > 0:
        if S[i-1] == 'W':
            left_w += 1
    if S[i] == 'E':
        right_e -= 1
    cost = left_w + right_e
    if cost < min_cost:
        min_cost = cost

print(min_cost)


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b;cin>>a>>b;
  if(a>=10||b>=10){
    cout<<-1<<endl;
  }else{
    cout<<a*b<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
	int H, W, N;

	cin >> H;
	cin >> W;
	cin >> N;

	int x = H;
	if(W>H) {
		x = W;
	}

	int r = N % x;

	if(r==0){
		cout << N / x << endl;
	} else {
		cout << (N+(x-r))/x << endl;
	}



	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

std::string s;

int main(int argc, char **argv) {
    std::cin >> s;

    long long cnt = 0;
    long long ret = 0;
    char next;
    next = s.back();

    for (int i = s.size() - 2; 0 <= i; i--) {
        if (s[i] == 'A') {
            if (cnt != 0 && next == 'B') {
                ret += cnt;
            } else {
                next = s[i];
                cnt = 0;
            }
        } else if (s[i] == 'B' && next == 'C') {
            cnt++;
            next = s[i];
        } else if (s[i] == 'C' && next == 'B') {
            next = s[i];
        }  else {
            cnt = 0;
            next = s[i];
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void)
{
    int jewelry_count;
    int* values;
    int* costs;
    int profit_sum = 0;

    cin >> jewelry_count;

    values = new int[jewelry_count];
    costs = new int[jewelry_count];

    for(int i = 0; i < jewelry_count; i++){
        cin >> values[i];
    }
    for(int i = 0; i < jewelry_count; i++){
        cin >> costs[i];
        if(values[i] > costs[i]){
            profit_sum += values[i] - costs[i];
        }
    }
  
    cout << profit_sum << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ok = True
a.sort()
if n%2==0:
    for i in range(n):
        if a[i]!= i-i%2+1:
            ok = False
            break
else:
    for i in range(n):
        if a[i]!= i+i%2:
            ok = False
            break
if ok:
    print(2**(n//2)%(10**9+7))
else:
    print(0)

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    long long sum = 0;
    for(int i = 1; i <= n; i++) {
        if(i%3 && i%5) sum += i;
    }
    
    cout << sum << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<LL, LL> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 16;
const int MOD = INF;


int G[MAX];
int DP[1 << MAX];
int n;
int POP[1 << MAX];



int F(int msk)
{
    if (DP[msk] != -1)return DP[msk];
    
    DP[msk] = 0;
    
    for(int sub = msk; sub; sub = (sub - 1) & msk)
    {
        if ((sub & 3) == 1 || (sub & 3) == 2)continue;
        
       // cout << msk << " " << sub << endl;
        
        int res = 1;
        
        FOR(i, 0, n)
        {
            if ((msk & (1 << i)) && !(sub & (1 << i)))
            {
                int m = G[i] & sub;
                res = res * 1LL * ((1 << POP[m]) - 1) % MOD;
            }
            if (sub & (1 << i))
            {
                
                int m = G[i] & (msk^sub);
                res = res * 1LL * (1 << POP[m]) % MOD;
            }
        }
        
        res = res * 1LL * F(msk ^ sub) % MOD;
        
        DP[msk] += res;
        if (DP[msk] >= MOD)DP[msk] -= MOD;

    }
    
    return DP[msk];
    
    
    
}

int main()
{
    // freopen("in.txt", "r", stdin);
    FOR(i, 0, 1 << MAX)
        POP[i] = POP[i >> 1] + (i & 1);
    
    
    int m;
    cin >> n >> m;
    FOR(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a] |= 1 << b;
    }
    FILL(DP, -1);
    DP[0] = 1;
    int res = 1;
    FOR(i, 0, m)
    {
        res *= 2;
        if (res >= MOD)res -= MOD;
    }
    res -= F((1 << n) - 1);
    
    if (res < 0)res += MOD;
    
    cout << res << endl;
    
    
    
    

    return 0;
}





Measured memory_bytes: 896
def I(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
n,k = MI()
h = LI()
h = h+ [float('INF')]*10000
dp = [float('INF')]*(10**5+1000)
dp[0] = 0
for i in range(n):
  for j in range(1,k+1):
    dp[i+j] = min(dp[i+j],dp[i] + abs(h[i+j] - h[i])) 
print(dp[n-1])

Measured memory_bytes: 58336
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int z=max(a,b);
	if(z==a){
		a--;
	}
	else{
		b--;
	}
	z+=max(a,b);
	cout<<z<<endl;
}

Measured memory_bytes: 256
'use strict';

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var fs = require('fs');

var input = Buffer.alloc(0x10000);
fs.readSync(0, input, 0, 0x10000);

var _input$toString$split = input.toString().split('\n').map(function (n) {
  return parseInt(n);
}),
    _input$toString$split2 = _slicedToArray(_input$toString$split, 3),
    X = _input$toString$split2[0],
    A = _input$toString$split2[1],
    B = _input$toString$split2[2];

console.log((X - A) % B);

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

int main()
{
    int n,x=int('Z'); cin>>n;
    string s;
    cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        if(int(s[i])+n<=x) s[i]=char(int(s[i])+n);
        else s[i]=char(int('A')+(int(s[i])+n)%(x+1));
    }
    cout<<s<<endl;
    return 0;
}


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

bool dfs(char op[3], int i, int sum);
string s;

int main() {
	char op[3];
	cin >> s;
	dfs(op, 0, s[0] - '0');
	for (int i = 0; i < 4; i++) {
		if (i == 3) {
			cout << s[i] << "=7" << endl;
		}
		else {
			cout << s[i] << op[i];
		}
	}
	return 0;
}

bool dfs(char op[3], int i, int sum) {
	if (i == 2) {
		if (sum + s[i + 1] - '0' == 7) {
			op[2] = '+';
			return true;
		}
		else if (sum - (s[i + 1] - '0') == 7) {
			op[2] = '-';
			return true;
		}
		else return false;
	}
	else if (dfs(op, i + 1, sum + s[i + 1] - '0')) {
		op[i] = '+';
		return true;
	}
	else if (dfs(op, i + 1, sum - (s[i + 1] - '0'))) {
		op[i] = '-';
		return true;
	}
	else return false;
}

Measured memory_bytes: 256
s = input()
mod = 10**9 + 7
abc = 0
bc = 0
c = 0
q = 0
for i in s[::-1]:
  if i == "A":
    abc = (abc + bc) % mod
  if i == "B":
    bc = (bc + c) % mod
  if i == "C":
    c = (pow(3,q,mod) + c) % mod
  if i == "?":
    abc = (abc*3 + bc) % mod
    bc = (bc*3 + c) % mod 
    c = (pow(3,q,mod) + c*3) % mod
    q += 1
print(int(abc))


Measured memory_bytes: 3316
#include<iostream>
#include<cmath>
using namespace std;
  
int main(){
  int L, R;
  cin >> L >> R;

  if(R - L > 2019){
    cout << 0;
    return 0;
  }

  int res = 2019;
  int temp = 0;
  for(int i = L; i < R; i++){
    for(int j = i + 1; j < R + 1; j++){
      temp = ((i % 2019) * (j % 2019)) % 2019;
      if (res > temp) {
        res = temp;
      }
    }
  }

  cout << res << endl;
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n; cin >> n;
  ll ans = 1, t;
  rep(i,n){
    cin >> t;
    ans = boost::math::lcm(ans, t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if ( a <= c && c <= b) {
        cout << "Yes" << endl;
    }else if( b <= c && c <= a ) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll N,M;
    cin >> N >> M;
    ll s[M][N];
    rep(i,M){
        rep(j,N) s[i][j] = 0;
    }
    rep(i,M){
        ll k;
        cin >> k;
        ll S;
        rep(j,k){
            cin >> S;
            s[i][S-1]++;
        }
    }
    ll p[M];
    rep(i,M) cin >> p[i];
    ll a[M];
    ll out = 0;
    for (ll bit = 0; bit < (1 << N); ++bit) {
        ll cnt = 0;
        rep(i,M){
            a[i] = 0;
            rep(j,N){
                if (bit & (1 << j)) a[i] += s[i][j];
            }
            if (a[i]%2==p[i]) cnt++;
        }
        if (cnt==M) out++;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int Mod = 998244353;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b){ return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b){ return 1ll * a * b % Mod; }
void Add(int &a, int b){ a = add(a,b); }
void Dec(int &a, int b){ a = dec(a,b); }
void Mul(int &a, int b){ a = mul(a,b); }
int ksm(int a, int b){ int as=1; for(;b;b>>=1,Mul(a,a)) if(b&1) Mul(as,a); return as; }
cs int N = 405;
int n, h[N], len[N];
int f[N][N], g[N][N], pw[N];
int work(int l, int r, int ht = 0){
	if(l > r) return 0; int x = l;
	for(int i = l+1; i <= r; i++)
	if(h[i] < h[x]) x = i;
	int lc = work(l, x-1, h[x]), rc = work(x+1, r, h[x]);
	for(int i = 0; i <= len[lc]; i++)
	for(int j = 0; j <= len[rc]; j++){
		int a = mul(f[lc][i], f[rc][j]);
		int b = add(mul(add(f[lc][i], g[lc][i]), 
		g[rc][j]), mul(g[lc][i], f[rc][j]));
		Add(f[x][i + j], a);
		Dec(f[x][i + j + 1], a);
		Add(g[x][i + j], b);
		Add(g[x][i + j + 1], a); 
	} len[x] = len[lc] + len[rc] + 1;
	for(int i = 0; i <= len[x]; i++){
		Mul(f[x][i], ksm(pw[len[x] - i], h[x] - ht));
		Mul(g[x][i], ksm(pw[len[x] - i] - 1, h[x] - ht));
	} return x;
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d", &n); pw[0] = f[0][0] = 1;
	for(int i=1; i<=n; i++) 
	pw[i] = add(pw[i-1],pw[i-1]);
	for(int i=1; i<=n; i++)
	scanf("%d", &h[i]);
	int rt = work(1,n), ans = 0;
	for(int i = 0; i <= len[rt]; i++)
	Add(ans, add(f[rt][i], g[rt][i]));
	cout << ans; return 0;
}

Measured memory_bytes: 5072
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(max(a, b), c) - min(min(a, b), c) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
int main(){
    int N;
    int a[100001];
    cin>>N;
    int w=0;
    for(int i=0;i<N;i++) scanf("%d",&a[i]);
    for(int k=1;k<N;k++){
        if(a[w]==2){
            cout<<k;
            cout<<endl;
            return 0;
        } 
        w=a[w]-1;
         
    }  
    printf("-1");
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

#define INF -1

struct Node {
    int d;
    int n;
    Node(){}
    Node(int n, int d){
        this->d = d;
        this->n = n;
    }
};

int main(){
    int n; cin >>n;
    vector<int> v;
    vector<vector<int>> edges(n,v);
    rep(i, n) {
        int id; cin >> id;
        int num; cin >> num;
        rep(j, num) {
            int dst;
            cin >> dst;
            dst--;
            edges[i].push_back(dst);
         }
    }
    queue<Node> q;
    vector<int> dst(n,INF);

    q.push(Node(0,0));
    while(!q.empty()) {
        Node node = q.front();
        q.pop();
        if(dst[node.n] == INF) {
            dst[node.n] = node.d;
            // cout << "popped " << node.n << endl;
        } else {
            continue;
        }
        for(auto it = edges[node.n].begin(); it != edges[node.n].end(); it++) {
            // cout << "pushed " << *it << endl;
            q.push(Node(*it, node.d+1));
        }
    }
    rep(i, n) {
        cout << i+1 << " " << dst[i] << endl;
    }
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

ll n;
ll cnt[1005]={0},ans=1;

int main(){
	cin>>n;
	for(ll i=2;i<=n;i++){
		ll now=i;
		for(ll j=2;j<=now;j++){
			while(now>0 && now%j==0){
				cnt[j]++;
				now/=j;
			}
		}
	}
	for(ll i=0;i<=n;i++){
		if(cnt[i]!=0){
			ans*=cnt[i]+1;
			ans%=MOD;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<fstream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<set>
#include<string>
#include<queue>
#include<map>
#include<iomanip>
#include<cassert>
#include<complex>
#include<functional>
#include<list>
#include<cmath>
#include<stack>
#include<assert.h>
#define LL long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define F first
#define S second
using namespace std;
LL n,k,h[210000];
LL sum;
int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>h[i];
    sum+=h[i];
  }
  if(n<=k){
  	puts("0");
  	return 0;
  }
  sort(h,h+n);
  for(int i=n-1;i>n-1-k;i--)
    sum-=h[i];
  cout<<sum<<"\n";
  return 0;
}

Measured memory_bytes: 1792
n = int(input())
pdic= [0]*(101) #素因数分解
for i in range(2,n+1):
    cur = i
    for j in range(2,i+1):
        while cur % j == 0:
            pdic[j] += 1
            cur //= j

def num(m):
    return len(list(filter(lambda x:x>=m-1,pdic)))
print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)//2)

Measured memory_bytes: 38512
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7

using namespace std;

ll m1,m2,d1,d2;

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> m1 >> d1 >> m2 >> d2;

    if(m1!=m2)
        cout << 1;
    else
        cout << 0;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
ll dpa[100002];
ll dpb[100002];
ll dpc[100002];
int main()
{
 
      ios::sync_with_stdio(0);
      cin.tie(0);
 
      ll n;
      cin>>n;
 
      ll a[n+1],b[n+1],c[n+1];
 
      for(ll i=1;i<=n;i++)
      	cin>>a[i]>>b[i]>>c[i];
 
      dpa[1]=a[1];
      dpb[1]=b[1];
      dpc[1]=c[1];
 
      for(ll i=2;i<=n;i++)
      {
 
        dpa[i]=max(a[i]+dpb[i-1],a[i]+dpc[i-1]);
        dpb[i]=max(b[i]+dpa[i-1],b[i]+dpc[i-1]);
        dpc[i]=max(c[i]+dpa[i-1],c[i]+dpb[i-1]);
 
      }
 
   cout<<max(dpa[n],max(dpb[n],dpc[n]));
 
}

Measured memory_bytes: 4992
s = input()
s_list = []
input_list = []

for i in range(len(s)):
    s_list.append(s[i])

for i2 in range(len(s)):
    if s_list[i2] == "0":
        input_list.append("0")
    elif s_list[i2] == "1":
        input_list.append("1")
    elif input_list == []:
      pass
    else:
      input_list.pop(-1)
      

for i3 in range(len(input_list)):
    print(input_list[i3],end="")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define pii <pair<ll,ll>>
using namespace std;

void solve()
{
    ll a,b;
    cin >> a >> b;
    ll avg=(a+b)/2;
    if((a+b)%2 !=0)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
        cout << avg << endl;
}

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

Measured memory_bytes: 256
L = list(input().split())
def is_num(s):
    return s.replace(',', '').replace('.', '').replace('-', '').isnumeric()
stack = []
for l in L:
  if is_num(l):
    stack.append(l)
#    print(l, stack)
  else:
#    print(l, stack)
    ans = eval(str(stack.pop(len(stack)-2)) + l + str(stack.pop(len(stack)-1)))
#    print(ans)
    stack.append(ans)
print(stack[0])


Measured memory_bytes: 5572
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;

class Program
{
	static void Main(string[] args)
	{
		int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int K = intArray[0];
		int X = intArray[1];

		if(K * 500 >= X)
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	}
}

//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();


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

int main()
{
  int n, m; cin >> n>> m;
  if(m >= n){
    cout << "unsafe" << endl;
  }
  else cout << "safe" << endl;
  system("pause");
}

Measured memory_bytes: 3700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Sendame
 */
public class Main {

	static final String Kougekida = "kougekida";
	static final String Tameru = "tameru";
	static final String Mamoru = "mamoru";

	static enum Winner {
		None,
		Isono,
		Nakajima,
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int K = parseInt(br.readLine());

		String[] I = new String[K];
		String[] N = new String[K];
		int pI = 0;
		int pN = 0;

		for (int i = 0; i < K; i++) {
			I[i] = br.readLine();
		}

		for (int i = 0; i < K; i++) {
			N[i] = br.readLine();
		}

		//

		Winner winner = Winner.None;

		for (int i = 0; i < K; i++) {

			switch (I[i]) {
				case Kougekida:
					switch (N[i]) {
						case Kougekida:
							if (pI > pN) winner = Winner.Isono;
							if (pI < pN) winner = Winner.Nakajima;
							pI = pN = 0;
							break;
						case Tameru:
							if (pI == 0) {
								winner = Winner.Nakajima;
							} else {
								winner = Winner.Isono;
							}
							if (pN < 5) pN++;
							pI = 0;
							break;
						case Mamoru:
							if (pI == 0) {
								winner = Winner.Nakajima;
							} else if (pI == 5) {
								winner = Winner.Isono;
							}
							pI = 0;
							break;
					}
					break;
				case Tameru:
					switch (N[i]) {
						case Kougekida:
							if (pN == 0) {
								winner = Winner.Isono;
							} else {
								winner = Winner.Nakajima;
							}
							if (pI < 5) pI++;
							pN = 0;
							break;
						case Tameru:
							if (pI < 5) pI++;
							if (pN < 5) pN++;
							break;
						case Mamoru:
							if (pI < 5) pI++;
							break;
					}
					break;
				case Mamoru:
					switch (N[i]) {
						case Kougekida:
							if (pN == 0) {
								winner = Winner.Isono;
							} else if (pN == 5) {
								winner = Winner.Nakajima;
							}
							pN = 0;
							break;
						case Tameru:
							if (pN < 5) pN++;
							break;
						case Mamoru:
							break;
					}
					break;
			}

			if (winner != Winner.None) break;

		}

		if (winner == Winner.Isono) {
			System.out.println("Isono-kun");
		} else if (winner == Winner.Nakajima) {
			System.out.println("Nakajima-kun");
		} else {
			System.out.println("Hikiwake-kun");
		}

	}
}

Measured memory_bytes: 24504
#include <iostream>
#include <set>
#include <algorithm>
#define mp make_pair
#define pii pair<int, int>
using namespace std;
set<pii> s;
int n;
int a[200010];
int res=0;
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++) scanf("%d",&a[i]);
	sort(a,a+n);
	for (int i=0;i<n;i++) s.insert(mp(a[i],i));
	for (int i=n-1;i>=0;i--)
	{
		if (s.count(mp(a[i],i)))
		{
			s.erase(mp(a[i],i));
			for (int j=0;j<31;j++)
			{
				if ((1<<j)>a[i])
				{
					int t=(1<<j)-a[i];
					set<pii>::iterator tt=s.lower_bound(mp(t,-1));
					if (tt!=s.end() && tt->first==t)
					{
						res++;
						s.erase(tt);
					}
					break;
				}
			}
		}
	}
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int n, m;
V g[51];
ll d[51][51];

int a[1000], b[1000];

void warshall_floyd(int e)
{
    for (int i = 0; i <= 50; i++)
        for (int j = 0; j <= 50; j++)
            d[i][j] = i == j ? 1 : INT_MAX;

    for (int i = 1; i <= n; i++)
    {
        for (int j : g[i])
        {
            if ((a[e] == i && b[e] == j) || (a[e] == j && b[e] == i))
                continue;
            d[i][j] = 1;
        }
    }

    for (int k = 0; k <= 50; k++)
        for (int i = 0; i <= 50; i++)
            for (int j = 0; j <= 50; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

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

    cin >> n >> m;
    REP(i, m)
    {
        cin >> a[i] >> b[i];

        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }

    int res = 0;

    for (int i = 0; i < m; i++)
    {
        warshall_floyd(i);

        bool check = false;

        for (int j = 1; j <= n; j++)
        {
            for (int k = 1; k <= n; k++)
                if (d[j][k] >= INT_MAX)
                    check = true;
        }

        res += check;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
var a,b:int64;
begin
readln(a,b);
if(a>0)and(b>0)then write('Positive')
else if(a<0)and(b<0)and((b-a+1)mod 2=0) then write('Positive')
else if(a<=0)and(b>=0)then write('Zero')
else write('Negative');
writeln;
end.

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			a[i] = sc.nextInt();
		}

		int left = 0;
		int right = w;
		int btm = 0;
		int top = h;

		for(int i=0; i<n; i++) {
			switch(a[i]) {
			case 1:
				left = Math.max(left, x[i]);
				break;
			case 2:
				right = Math.min(right, x[i]);
				break;
			case 3:
				btm = Math.max(btm, y[i]);
				break;
			case 4:
				top = Math.min(top, y[i]);
				break;
			}
		}

		int square = (Math.max(0, right-left))* (Math.max(0, top-btm));

		System.out.println(square);
		sc.close();
	}
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    for(int i = 0; i < n; ++i){
        cin >> w[i] >> v[i];
    }

    vector<vector<ll>> dp(n + 1, vector<ll>(n * 1000 + 1, LLINF));
    dp[0][0] = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = 0; j <= n * 1000; ++j){
            dp[i][j] = dp[i-1][j];
            if(j >= v[i-1]) dp[i][j] = min(dp[i][j], dp[i-1][j-v[i-1]] + w[i-1]);
        }
    }

    for(int i = n * 1000; i >= 0; --i){
        if(dp[n][i] <= W){
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 80256
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
int num[3][3];
int main(){
  ll n;
  cin>>n;
  if(n==1){cout<<"Hello World"<<endl;}
  else{
    int a,b;cin>>a>>b;
    cout<<a+b<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double mo,r;
	int i, n, k;
	
	r = 1.05;
	mo = 100000;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		mo *= r;
		k = mo;
		
		if (k % 1000 != 0){
			k += 1000;
			k -= k % 1000;
		}
		mo = k;
		
	}
	
	printf("%d\n", k);
	
	return (0);
}

Measured memory_bytes: 592
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b,a%b);
}
 
ll lcm(ll a, ll b) {
    ll g = gcd(a,b);
    return a / g * b;   // Be careful not to overflow
}


vector<int> pp;
void preparePrime( int maxp )
{
    int i;
    vector<int> a(maxp+1);
    for(i=2; i<=maxp; i++) {
        int k=i+i;
        while(k<=maxp) {
            a[k]=1;
            k+=i;
        }
    }
    for(i=2; i<=maxp; i++) {
        if(a[i]==0) pp.push_back( i );
    }
    return;
}

void decompositPrime( ll a, vector<pair<ll,ll> >& vv )
{
    int i;
    for(i=0; i<(int)pp.size(); i++) {
        int count = 0;
        while(a % pp[i] == 0 ) {
            a /= pp[i];
            count ++;
        }
        if(count>0) vv.push_back( make_pair( pp[i], count ) );
        if (a==1) break;
    }
    if(a>1) {
        vv.push_back( make_pair( a, 1 ) );
    }

    return;
}


void solve()
{
    preparePrime(1005);

    int n;
    scanf("%d", &n);
    vector<int> a(n);
    map<ll, int> z;
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        vector<pair<ll, ll> > vv;
        decompositPrime(a[i], vv);
        int k;
        for (k = 0; k < (int)vv.size(); k++) {
            ll p = vv[k].first;
            ll q = vv[k].second;
            z[p] = MAX(z[p], (int)q);
        }
    }
    ll ans = 1;
    auto it = z.begin();
    for (; it != z.end(); ++it) {
        ll p = it->first;
        ll num = it->second;
        ans = ans * mpow(p, num) % MOD;
    }

    ll sum = 0;
    for (i = 0; i < n; i++) {
        ll ans0 = ans * minv(a[i]) % MOD;
        sum = (sum + ans0) % MOD;
    }
    printf("%lld\n", sum);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 896
(* O(N log N (N = max n m)) *)
Scanf.scanf "%d %d" @@ fun n m ->
  let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  let bcs = Array.init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun b c -> b, c in
  let cmp (a, c) (a1, c1) = c1 - c in
  Array.sort (-) a_s;
  Array.sort cmp bcs;
  let show_ans () = Printf.printf "%d\n" @@ Array.fold_left (+) 0 a_s in
  let k = ref 0 in
  for j = 0 to m - 1 do
    let a, c = bcs.(j) in
    let changed = ref false in
    for i = !k to min (n - 1) @@ !k + a - 1 do
        if a_s.(i) <= c then (a_s.(i) <- c; k := i + 1; changed := true)
    done;
    if not !changed then (show_ans (); exit 0)
  done;
  show_ans ()

Measured memory_bytes: 7168
# a1 を既知とすると
# c11 = a1 + b1 となり
# b1 = c11 - a1 が定まる
# さらに ci1 = ai + b1 であるから
# a2 = c21 - b1 と
# a3 = c31 - b1 が定まる
# すると b2 =  c12  - a1 と b3  = c13 - a1　も定まる
# よって (a1, a2, a3, b1, b2, b3) = (a1, c21-c11+a1, c31-c11+a1, c11-a1, c12-a1, c13-a1) と定まる
# ここで (a1, a2, a3, b1, b2, b3) = (p1+x, p2+x, p3+x, q1-x, q2-x, q3-x) とおけば
# x を適切に設定する事で a1 = 0 と仮定することができる (aiとbjでxが相殺される)
# 従って (a1, a2, a3, b1, b2, b3) = (0, c21-c11, c31-c11, c11, c12, c13) である

c = []
for _ in range(3):
	c.append(list(map(int,  input().split())))

a1, a2, a3, b1, b2, b3 = 0, c[1][0]-c[0][0], c[2][0]-c[0][0], c[0][0], c[0][1], c[0][2]

# print("(a1, a2, a3, b1, b2, b3) = ({}, {}, {}, {}, {}, {})".format(a1, a2, a3, b1, b2, b3))

if c[0][0] == a1 + b1 and c[0][1] == a1 + b2 and c[0][2] == a1 + b3 \
    and c[1][0] == a2 + b1 and c[1][1] == a2 + b2 and c[1][2] == a2 + b3 \
    and c[2][0] == a3 + b1 and c[2][1] == a3 + b2 and c[2][2] == a3 + b3:

    print("Yes")

else:

    print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD ((ll)1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)
template<class F,class S>void add(map<F,S>&mp,F f,S s){if(mp.find(f)==mp.end())mp[f]=F();mp[f]+=s;}
 
int main(){
    int h,v;
    using data=pair<int,int>;
    
    while(cin>>h>>v, h or v){
        int tv[]={-3,-1,1,3};
        int tc[]={v,h,h,v};
        int p10[]={100000000,10000000,1000000,100000,10000,1000,100,10,1};
        array<int,9> a,b;
        geti(a);
        geti(b);
        int sa=0,sb=0;
        for(auto i:a)sa=sa*10+i;
        for(auto i:b)sb=sb*10+i;
    
        unordered_map<int,int> s;

        priority_queue<data> q;
        q.emplace(0,sa);
        
        while(1){
            int cost=q.top().fs;
            int board=q.top().sc;
            q.pop();
            if(board==sb){
                cout<<-cost<<endl;
                break;
            }
            int index=to_string(board).find('0');
            if(index==-1)index=0;
            rep(i,4){
                int fixed=(index+tv[i]+9)%9;
                int next=board;
                int fx=next/p10[fixed]%10;
                next-=p10[fixed]*fx;
                next+=p10[index]*fx;
                if(s.find(next)==s.end() || (s[next]<cost-tc[i] && cost-tc[i]>-10000)){
                    q.emplace(cost-tc[i], next);
                    s[next]=cost-tc[i];
                }
            }
        }
    }
}



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

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int a = Integer.parseInt(br.readLine());
        if(a<=100){
            int[] num = new int[a];
            String[] str = br.readLine().split(" ");
            for(int i=0; a>0; i++){
                num[i] = Integer.parseInt(str[--a]);
                System.out.print(num[i]);
                if(a != 0){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}

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

int main() {
	string S;

	cin >> S;


	if(S == "Sunny"){
		cout << "Cloudy" << endl;
	}
	else if(S == "Cloudy"){
		cout << "Rainy" << endl;
	}
	else{
		cout << "Sunny" << endl;
	}


}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm> 

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=12e4,mo=1e9+7;

int a[N];
ll jc[N],ny[N];
ll f[202][N],g[N];
int k[N];
int n,x;

inline ll ksm(ll o,ll t)
{
	ll y=1;
	for(;t;t>>=1,o=o*o%mo)
	if(t&1)y=y*o%mo;
	return y;
}

inline ll C(int a,int b)
{return jc[a]*ny[a-b]%mo;}

int main()
{
	cin>>n>>x;
	fo(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	fo(i,1,n/2)swap(a[i],a[n-i+1]);
	jc[0]=ny[0]=1;
	fo(i,1,n)jc[i]=jc[i-1]*i%mo;
	ny[n]=ksm(jc[n],mo-2);
	fd(i,n-1,1)ny[i]=ny[i+1]*(i+1)%mo;
	f[0][x]=1;
	fo(i,0,x)
	fo(p,1,n)if(i>=a[p]){
		k[i]=p; break;
	}
	if(k[x])g[x]=C(n,k[x]-1)*jc[n-k[x]]%mo;
	fo(i,1,n){
		fo(j,a[i],x)f[i][j%a[i]]=(f[i][j%a[i]]+g[j]*ny[n-i])%mo;
		if(n!=i)
		fo(j,0,a[i]-1)if(k[j])
			g[j]=(g[j]+f[i][j]*C(n-i,k[j]-i-1)%mo*jc[n-k[j]])%mo;
	}
	ll ans=0;
	fo(i,0,n)
	fo(j,0,a[n]-1)ans=(ans+f[i][j]*jc[n-i]%mo*j)%mo;
	cout<<ans;
}

Measured memory_bytes: 191872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
    ll n,k,ans=0;cin>>n>>k;
    vector<ll> v(n);
    rep(i,n){
        cin>>v[i];
        if(v[i]>=k)ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */

int main(void){ 
    int s;
    cin >> s;
    ll ans = 1;
    while(s != 4 && s != 2 && s!= 1){ // 2 1 4 2 なら、4 より先に 2が重複するじゃん
    // ずっと 4 しか考えてなかった。
        ans += 1;
        if(s % 2 == 0){
            s = s / 2;
        }
        else{
            s = 3*s + 1;
        }
    }
    cout << ans + 3;
    return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }



ll N;
vector<ll> a;
int main() {

	cin >> N;

	a.resize(N);
	rep(i, N)
		cin >> a[i];


	ll sumkind = 0;

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

	if (a[N - 1] > a[0] + 1) { cout << "No" << endl; return 0; }


	sumkind += a[N-1];


	if (a[0] != a[N - 1]) {
		ll index = 0;
		while (a[index] == a[0]) { sumkind--; index += 1; }

		if (sumkind <= 0 || (N - index) < 2 * (sumkind)) {
			cout << "No" << endl;
			
		}

		else {
			cout << "Yes" << endl;
			
		}

	}

	if (a[0] == a[N - 1]) {

		if (N == sumkind + 1 || N >= 2 * sumkind) {
			cout << "Yes" << endl;
			
		}
		else {
			cout << "No" << endl;
			
		}

	}

	

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main
{ 
    public static void main(String[] args)
    {
       int r, c;
       Scanner sc = new Scanner(System.in);  
       r = sc.nextInt();
       c = sc.nextInt();
       int [] [] arr = new int [r+1] [c+1];
       for(int i =0; i<r;i++)
       {  
          int sumR = 0;
          for(int j = 0; j<c; j++)
          {
              arr[i][j]=sc.nextInt();
              System.out.print(arr[i][j]+" ");
              sumR = sumR + arr[i] [j];
              if(j == c-1)
              {
                 System.out.println(sumR);
                 arr[i][j+1] = sumR;
              }
          }
       }
       for (int i = 0; i<c+1; i++)
       {
           int sumC = 0;
          for(int j = 0; j<r+1; j++)
          {
              sumC = sumC + arr[j][i];
              if(j==r && i!=c)
              {
               System.out.print(sumC+" ");
              }
              if(j==r && i==c)
              {
                 System.out.println(sumC);
              }   
          }
       }
    }
}



Measured memory_bytes: 39688
#include <stdio.h>
int main()
{
  int A,B,C;
  if (scanf("%d %d %d",&A,&B,&C) != 3)
    return (0);
  if ((A == B && B == C) || (A != B && B != C && A != C) )
  {
    printf("No");
  }
  else
  {printf("Yes");
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
#define rep(i, n) for(int i = 0; i < n; i++)
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main(){
    ll n, k; cin >> n >> k;
    ll a[n], b[n];
    ll sum = 0;
    ll ans = 0;
    ll mx = 0;
    ll num[100001] = {0};
    rep(i, n){
        cin >> a[i] >> b[i];
        num[a[i]] += b[i];
        mx = max(mx, a[i]);
    }
    for(int i = 1; i <= mx; i++){
        sum += num[i];
        if(sum >= k){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll x, y, c=0;
  cin >> x >> y;
  while(x <= y){
	x *= 2;
	c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int c;
    std::vector<vector<int>> vec(3,vector<int>(3));
    for (int i=0;i<3;i++) {
        for (int j=0;j<3;j++) {
            cin>>c;
            vec[i][j]=c;
        }
    }
    int flag=0,count=0;
    for (int a1=0;a1<=100;a1++) {
        for (int a2=0;a2<=100;a2++) {
            for (int a3=0;a3<=100;a3++) {
                int b1=vec[0][0]-a1;
                if (b1>=0) {
                    if (vec[1][0]==a2+b1&&vec[2][0]==a3+b1) {
                        count++;
                    }
                }
                int b2=vec[1][1]-a2;
                if (b2>=0) {
                    if (vec[0][1]==a1+b2&&vec[2][1]==a3+b2) {
                        count++;
                    }
                }
                int b3=vec[2][2]-a3;
                if (b3>=0) {
                    if (vec[0][2]==a1+b3&&vec[1][2]==a2+b3) {
                        count++;
                    }
                }
                if (count==3) {
                    flag=1;
                    break;
                } else {
                    count=0;
                }
            }
            if (flag==1) {
                break;
            }
        }
        if (flag==1) {
            break;
        }
    }
    if (flag==0) {
        cout<<"No"<<endl;
    } else {
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256