akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

bool print_if_valid(const vector<int> &ans, const string &s) {
    if (s.front() == 'o') {
        if (ans.front() == 0) {
            if (ans[1] != ans.back())
                return false;
        } else {
            if (ans[1] == ans.back())
                return false;
        }
    } else {
        if (ans.front() == 0) {
            if (ans[1] == ans.back())
                return false;
        } else {
            if (ans[1] != ans.back())
                return false;
        }
    }

    if (s.back() == 'o') {
        if (ans.back() == 0) {
            if (ans[0] != ans[ans.size() - 2])
                return false;
        } else {
            if (ans[0] == ans[ans.size() - 2])
                return false;
        }
    } else {
        if (ans.back() == 0) {
            if (ans[0] == ans[ans.size() - 2])
                return false;
        } else {
            if (ans[0] != ans[ans.size() - 2])
                return false;
        }
    }

    for (int k : ans) {
        cout << (k == 0 ? 'S' : 'W');
    }
    cout << endl;
    return true;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    // 0: 羊 1: 狼
    for (int i = 0; i < 4; ++i) {
        vector<int> ans(n);
        ans[0] = i >> 0 & 1;
        ans[1] = i >> 1 & 1;
        for (int j = 2; j < n; ++j) {
            if ((ans[j - 1] == 0 && s[j - 1] == 'o') || (ans[j - 1] == 1 && s[j - 1] == 'x')) {
                ans[j] = ans[j - 2];
            } else {
                ans[j] = ans[j - 2] ^ 1;
            }
        }
        if (print_if_valid(ans, s))
            return 0;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 1016
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

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

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

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

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

void debug() {
  cerr << endl;
}

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

void print() {
  cout << endl;
}

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

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
	int A,B;
	cin>>A>>B;
	print((B-1+A-2)/(A-1));
  return 0;
}


Measured memory_bytes: 256
R=[]
N,K=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]
for i in range(N-K+1):
    a=abs(x[i])+abs(x[i+K-1]-x[i])
    b=abs(x[i+K-1])+abs(x[i+K-1]-x[i])
    c=min(a,b)
    R.append(c)
print(min(R))

Measured memory_bytes: 14224
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


# 全探索
def main():
    sx, sy, tx, ty = MI()
    out = []
    # 1st loop
    out.append('U' * (ty - sy))
    out.append('R' * (tx - sx))
    out.append('D' * (ty - sy))
    out.append('L' * (tx - sx))
    # 2nd loop
    out.append('L')
    out.append('U' * ((ty - sy) + 1))
    out.append('R' * ((tx - sx) + 1))
    out.append('D')
    out.append('R')
    out.append('D' * ((ty - sy) + 1))
    out.append('L' * ((tx - sx) + 1))
    out.append('U')

    print(''.join(out))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#ifdef ONLINE_JUDGE
  #define debug(x)
  #define debug2(x,y)
  #define debug3(x,y,z)
  #define assert(e) if(!(e)){stod("");}
#else
  #define debug(x) std::cerr<<#x<<": "<<x<<"\n"
  #define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
  #define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"
#endif

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  int x;
  scan(x);
  int ans = lcm(x, 360) / x;
  print(ans);
}

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


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

typedef long long int ll;

using namespace std;

bool isPalindrome(const string& s)
{
    int n = s.length();
    int mid = n / 2;
    
    for (int i = 0; i < mid; ++i)
    {
        if (s[i] != s[n - i - 1])
            return false;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin >> s;
    
    int n = s.length();
    
    string prefix = s.substr(0, (n - 1) / 2);
    string suffix = s.substr((n + 3) / 2 - 1);
    
    if (isPalindrome(s) && isPalindrome(prefix) && isPalindrome(suffix))
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		HashMap<Character, Integer> hm = new HashMap<>();
		char ch=' ';
		for(int i = 0; i < 4; i++) {
			ch = S.charAt(i);
			if(!hm.containsKey(ch)) {
				hm.put(ch, 1);
			}
			else {
				hm.put(ch, hm.get(ch) + 1);
			}
		}
		System.out.println((hm.size() == 2 && hm.get(ch) == 2)?"Yes":"No");
	}
}

Measured memory_bytes: 23508
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int A[1000][1000], B[1000], C[1000];

int main()
{
    int a, b; cin >> a >> b;
    for(int i = 1; i <= a; i++){
        for(int j = 1; j <= b; j++){
            cin >> A[i][j];
        }
    }
    for(int i = 1; i <= b; i++) cin >> B[i];
    for(int i = 1; i <= a; i++){
        for(int j = 1; j <= b; j++){
            C[i] += A[i][j] * B[j];
        }
    }
    for(int i = 1; i <= a; i++) cout << C[i] << '\n';
    
    return 0;
    
}






Measured memory_bytes: 3496
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = -1;
		if(N == 1 | N == 7)
			ans = 1;
		else if(N % 2 != 0 && N % 5 != 0) {
			long x = 7 % N, y = 7 % N;
			for(int i = 1; i < N; i++) {
				x = x * 10 % N;
				y = (y + x) % N;
				if (y == 0) {
					ans = i + 1;
					break;
				}
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 35708
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	rep(i, n) {
		if(i % 2 == 0 && s[i] == 'p') ans--;
		if(i % 2 == 1 && s[i] == 'g') ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=200000+10;
ll n,m;
ll gcd(ll x,ll y){
    if(x%y==0) return y;
    return gcd(y,x%y);
}
int main() {
    while(~scanf("%lld%lld",&n,&m)){
        if(n%m==0){
            printf("-1\n");
        }
        else {
            ll x=n/(gcd(n,m));
            printf("%lld\n",x*n);

        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*
2019/05/25
*/
int main(){
  int a,b;
  cin>>a>>b;
  int ans;
  if(a<=5)ans==0;
  else if(6<=a&&a<=12)ans=b/2;
  else ans=b;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int i, j, flag, n, c, count, A[101];
    flag = 1;
    i = 0;
    count = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> A[i];
    while(flag){
        flag = 0;
        for(j = n - 1; j >= 1; j--){
            if(A[j - 1] > A[j]){
                c = A[j];
                A[j] = A[j-1];
                A[j-1] = c;
                count++;
                flag = 1;
            }
        }
        i++;
    }
              
    for(int i = 0; i < n; i++){
        if(i != n-1)cout << A[i]  << " ";
        else cout << A[i];
    }
    cout << endl << count << endl;
    
    
    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<complex>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
using namespace std;

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> l(q), r(q);
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }

  vector<int> sum(n+1, 0);
  for (int i = 0; i < n; i++) {
    if (i+1 < n and s[i] == 'A' and s[i+1] == 'C') {
      sum[i+1] = sum[i] + 1;
    } else {
      sum[i+1] = sum[i];
    }
  }

  for (int i = 0; i < q; i++) {
    r[i]--;
    l[i]--;
    cout << sum[r[i]] - sum[l[i]] << endl;
  }
}


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

MIN=0
MAX=10**9
while MAX-MIN>1:
    mid=(MAX+MIN)//2
    tmp=0
    for i in range(N):
        tmp+=(A[i]-1)//mid
    if tmp>K:
        MIN=mid
    else:
        MAX=mid
print(MAX)

Measured memory_bytes: 30812
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int M;
	scanf("%d",&M);

	printf("%d\n",48-M);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

int main(void)
{
	ll n;
	cin >> n;
	vec<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0;
	rep(i, n) {
		if (i && a[i] && a[i - 1]) {
			ans++;
			a[i]--;
		}
		ans += a[i] / 2;
		a[i] %= 2;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N, K;
  cin >> N >> K;
  auto a = vector<ll>(N, 0);
  auto d = vector<ll>(N, 0);
  REP(i, N) {
    cin >> a[i];
    if(i >= 1) {
      if(a[i] > 0) {
        d[i] += d[i - 1] + a[i];
      } else {
        d[i] = d[i - 1];
      }
    } else {
      if(a[i] > 0) {
        d[i] = a[i];
      } else {
        d[i] = 0;
      }
    }
  }

  ll ans = 0;
  REP(i, N - K + 1) {
    ll sum = 0;
    if(i == 0) {
      sum += d[N - 1] - d[i + K - 1];
    } else if(i == N - K) {
      sum += d[i - 1];
    } else {
      sum += d[i - 1] + d[N - 1] - d[i + K - 1];
    }
    ll k_sum = 0;
    REPS(j, i, i + K) { k_sum += a[j]; }
    if(k_sum >= 0) {
      sum += k_sum;
    }
    ans = max(ans, sum);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>
#include <stdlib.h>
# include <map>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a*b%2 == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int z_algorithm(const string &s, const int &n) {
	vector<int> Z(n);
	Z[0] = s.size();
	int i = 1, j = 0;
	while(i < n) {
		while(j + i < n && s[j] == s[i+j]) j++;
		Z[i] = j;

		if(j == 0) {
			i++;
			continue;
		}

		int k = 1;
		while(k < j && k + Z[k] < j) {
			Z[i+k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}
	int ret = 0;
	for(int i=1;i<n;i++) ret = max(ret, min(Z[i], i));
	return ret;
}

int main() {
	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	for(int i=0;i<N;i++) {
		ans = max(ans, z_algorithm(S.substr(i) ,N-i));
	}
	cout << ans << endl;
}

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

int main(){
    string st;
    cin >> st;
    if(st == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(st == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)


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

  vector<int> a(N);

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

  vector<bool> b(8,false);
  
  int c=0,ans=0;

  rep(i,N){
    int x=a[i],y=x/400;
    if(y>=8) c++;

    else b[y]=true;
  }

  bool color=true;

  rep(i,8){
    if(b[i]==true) ans++;
    color=color&&!b[i];
  }

  if(c>0&&color) cout << 1 << ' ' << c << endl;

  else cout << ans << ' ' << ans+c << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    int A[n][m];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) cin >> A[i][j];
    int ok = n, ng = 0;
    while (ok - ng > 1) {
        int mid = (ok + ng) / 2;
        int idx[n] = {};
        bool removed[m+1] = {};
        while (*max_element(idx, idx+n) < m) {
            int cnt[m+1] = {};
            for (int i = 0; i < n; i++) {
                cnt[A[i][idx[i]]]++;
            }
            bool upd = false;
            for (int j = 1; j <= m; j++)
                if (cnt[j] > mid) removed[j] = true, upd = true;
            if (!upd) break;
            for (int i = 0; i < n; i++) {
                while (idx[i] < m && removed[A[i][idx[i]]]) idx[i]++;
            }  
        }
        if (*max_element(idx, idx+n) < m) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
    bool card[4][14];
    char ch, mark;
    int x, n;
    
    for (int s = 0; s < 4; s++)
        for (int r = 1; r <= 13; r++)
            card[s][r] = 0;
            
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> ch >> x;
        if (ch == 'S') { card[0][x] = 1;}
        else if (ch == 'H') { card[1][x] = 1;} 
        else if (ch == 'C') { card[2][x] = 1;} 
        else if (ch == 'D') { card[3][x] = 1;}
    }
    for (int s = 0; s < 4; s++){
        for (int r = 1; r <= 13; r++){
            if (!card[s][r]) {
                if (s == 0)  mark = 'S';
                else if (s == 1) mark = 'H';
                else if (s == 2) mark = 'C';
                else if (s == 3) mark = 'D';
                cout << mark << " " << r << endl;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N;

int main()
{
    cin >> N;
    vector<int> p(N);
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    for (int i = 0; i + 2 < N; i++)
    {
        if (p[i] < p[i + 1] && p[i + 1] < p[i + 2])
            ans++;
        if (p[i] > p[i + 1] && p[i + 1] > p[i + 2])
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	ll x; cin >>x;
	ll sum=0;
	for(int i=1;i<1e9;i++){
		sum+=i;
		if(x<=sum){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N = readInts()[0]
  A = readInts()

  ans = 1
  for a in A:
    ans *= a
  den = 0
  for a in A:
    den += ans // a
  print(ans / den)

if __name__ == "__main__":
  main()


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

using namespace std;


typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)

int main() {
    int n, m;
    cin >> n;
    bool flag = true;
    std::vector<int> v;
    for(int i = 0; i < n; i++){
        cin >> m;
        if(m % 2 == 0) v.push_back(m);
    }
    for(int i = 0; i < v.size(); i++){
        if((v[i] % 3 == 0) || (v[i] % 5 == 0)){
            continue;
        }
        else flag = false;
        break;
    }
    if(flag) cout << "APPROVED";
    else cout <<"DENIED";

    return 0;
}
/*
         ,--"""",--.__,---[],-------._
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________

*/


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

using namespace std;

typedef long long LL;



int main(){
	int n,alt=0,ans=0;
	char s;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s=='I'){
			alt++;
		}
		if(s=='D'){
			alt--;
		}
		ans=max(ans,alt);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,dr[19][190][190][190],td[190][190],nw;
char mp[200][200];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%s",mp[i]+1);
	for(int i=n;i>=1;--i)for(int j=m;j>=1;--j)td[i][j]=(mp[i][j]==mp[i+1][j]?td[i+1][j]:i);
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j){
		nw=1e6;
		for(int k=j;k<=m;++k){
			if(mp[i][k]!=mp[i][j])nw=i-1;
			nw=min(nw,td[i][k]);
			dr[0][i][j][k]=nw;
		}
	}
	if(dr[0][1][1][m]==n)return puts("0"),0;
	for(int t=1;;++t){
		for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)for(int k=j;k<=m;++k)dr[t][i][j][k]=max(dr[t-1][i][j][k],dr[t-1][dr[t-1][i][j][k]+1][j][k]);
		for(int i=1;i<=n;++i)for(int j=1;j<=m;++j){
			nw=j;
			for(int k=j+1;k<=m;++k){
				while(nw<k&&dr[t-1][i][j][nw]>=dr[t-1][i][nw+1][k])++nw;
				dr[t][i][j][k]=max(dr[t][i][j][k],max(min(dr[t-1][i][j][nw-1],dr[t-1][i][nw][k]),min(dr[t-1][i][j][nw],dr[t-1][i][nw+1][k])));
			}
		}
		if(dr[t][1][1][m]==n)return printf("%d",t),0;
	}
	return 0;
}

Measured memory_bytes: 447360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0LL;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define IT ::iterator
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);

int main()
{
    ll n;
    cin >> n;
    ll m=n/1000LL;
    if(n%1000LL)m++;
    m*=1000LL;
    cout << m-n;
}


Measured memory_bytes: 3668
#include<iostream>

using namespace std;

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

int main() {
  string pass;
  cin >> pass;
  bool flag = false;
  if (pass.size() < 6u) goto fail;
  rep (i, pass.size()) if (isdigit(pass[i])) flag = true;
  if (!flag) goto fail;
  flag = false;
  rep (i, pass.size()) if (isupper(pass[i])) flag = true;
  if (!flag) goto fail;
  flag = false;
  rep (i, pass.size()) if (islower(pass[i])) flag = true;
  if (!flag) goto fail;
  cout << "VALID" << endl;
  return 0;
 fail:;
  cout << "INVALID" << endl;
}

Measured memory_bytes: 1180
//Tonight's the night and it is going to happen again and again.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define T ll t; cin>>t; while(t--)
#define mod 1000000007
#define inf 1000000000000000000
#define mem(name,val) memset(name,val,sizeof(name))
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define endl "\n"
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}
int vis[1000007];
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
   int n;cin>>n;int a[n];
   f(n){cin>>a[i];}
   ll res=a[0];
   rep(i,1,n){res=gcd(a[i],res);if(res==1){break;}}
   if(res>1){cout<<"not coprime";}
   else
   {
    int c=0;
    rep(i,0,n)
    {
      for(int j=2;j*j<=a[i];j++)
      {
        if(a[i]%j==0)
        {
          if(vis[j]==1){c=1;goto sos;}
          vis[j]=1;
          while(a[i]%j==0){a[i]/=j;}
        }
      }
      if(a[i]!=1){if(vis[a[i]]==1){c=1;goto sos;}vis[a[i]]=1;}
    }
    sos:
    if(c==1){cout<<"setwise coprime";}
    else{cout<<"pairwise coprime";}
   } 
}

Measured memory_bytes: 7812
#include <stack>
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
	int m;
	string str;
	string s1, s2, s3, s4;
	cin >> m;
	for (int z = 0; z < m; z++) {
		cin >> str;
		set<string> s;
		for (int i = 0; i < str.size(); i++) {
			s1 = str.substr(0, i + 1);
			s2 = str.substr(i + 1, str.size()-i-1);
			s3 = s1;
			s4 = s2;
			reverse(s1.begin(),s1.end());
			 reverse(s2.begin(), s2.end());
			s.insert(s1 + s2);
			s.insert(s1 + s4);
			s.insert(s3 + s2);
			s.insert(s3 + s4);
			s.insert(s2 + s1);
			s.insert(s2 + s3);
			s.insert(s4 + s1);
			s.insert(s4 + s3);
		}
		cout << s.size() << endl;
	}
    return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    while(a!=-1 || b!=-1 || c!= -1){
        if(a == -1 || b == -1 ) cout << "F" << endl;
        else if(a+b >= 80) cout << "A" << endl;
        else if(a+b >= 65) cout << "B" << endl;
        else if(a+b >= 50) cout << "C" << endl;
        else if(a+b >= 30){
            if (c >= 50) cout << "C" << endl;
            else cout << "D" << endl;
        }
        else cout << "F" << endl;
        
        cin >> a >> b >> c;
    }
    return 0;
}


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

struct flower{
    ll h; //height
    ll b; //beauty
};
// any element is inserted and deleted atmost once so time complexity is O(NlogN)
ll solve(vector<flower>& v,ll n){
	vector<ll> dp(n+1);
	dp[1]=v[1].b;
	map<ll,ll> meaningful; //to store meaningful indices which can extend further
	meaningful[v[1].h]=v[1].b;
	ll ans=dp[1];
	for(int i=2;i<=n;++i){
	    dp[i]=v[i].b; // first option
	    // 2nd option 
	    auto it=meaningful.lower_bound(v[i].h+1);
	    if(it!=meaningful.begin()){
	        it--;
	        dp[i]+=it->second;
	    }
	    meaningful[v[i].h]=dp[i]; //insert into map
	    //delete all unnecessary heights which cant be extended in the future
	    it=meaningful.upper_bound(v[i].h);
	    while(it!=meaningful.end() and it->second<=dp[i]){
	        auto temp=it;
	        temp++;
	        meaningful.erase(it);
	        it=temp;
	    }
	    ans=max(ans,dp[i]);
	}
	return ans;
}

int main()
{
	ll n=0;cin>>n;
    vector<flower> v(n+1);
    for(int i=1;i<=n;++i)
        cin>>v[i].h;
    for(int i=1;i<=n;++i)
        cin>>v[i].b;
    cout<<solve(v,n)<<'\n';
	return 0;
}

Measured memory_bytes: 17408
n = int(input())
a = list(map(int, input().split()))

def check(mid):
    if a[n - 1] >= mid and (a[n - 2] >= mid or a[n] >= mid):
        return True
    elif a[n - 1] < mid and (a[n - 2] < mid or a[n] < mid):
        return False
    
    l = n - 1
    while l > 0:
        if (a[l] < mid) ^ (a[l - 1] < mid):
            l -= 1
        else:
            break
    
    r = n - 1
    while r < n * 2 - 2:
        if (a[r] < mid) ^ (a[r + 1] < mid):
            r += 1
        else:
            break
    
    if l == 0 and r == n * 2 - 1:
        return bool((n & 1) ^ (a[n - 1] < mid))
    
    if abs(n - 1 - l) < abs(n - 1 - r):
        return a[l] >= mid
    else:
        return a[r] >= mid

ok = 0
ng = n * 2

while ng - ok > 1:
    mid = (ok + ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 25780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC061_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var cities = int.Parse(input[0]);
            var roads = int.Parse(input[1]);
            var toCityRoads = new int[cities];
            for (int i = 0; i < cities; i++)
            {
                toCityRoads[i] = 0;
            }

            for (int i = 0; i < roads; i++)
            {
                var inputRoads = Console.ReadLine().Split(' ');
                var city1 = int.Parse(inputRoads[0]);
                var city2 = int.Parse(inputRoads[1]);

                toCityRoads[city1 - 1]++;
                toCityRoads[city2 - 1]++;
            }

            for (int i = 0; i < cities; i++)
            {
                Console.WriteLine(toCityRoads[i]);
            }
        }
    }
}


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

using namespace std;

int arr[41];
int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  long long int k,t;
  vector <long long int> v;
  
  cin >> n >> k;
  
  for(int i=0;i<n;i++)
  {
    cin >> t;
    v.push_back(t);
  }
  
  memset(arr,0,sizeof(arr));
  
  for(int i=0;i<n;i++)
  {
    t = v[i];
    for(int j=0;j<41;j++)
    {
      if(t==0)
      {
        break;
      }
      
      if(t%2==1)
      {
        arr[j]++;
      }
      t/=2;
    }
  }
  
  long long int temp=0;
  for(int i=40;i>=0;i--)
  {
    if(n-arr[i]>arr[i])
    {
      if(temp+(1LL<<i)<=k)
      {
        temp+=(1LL<<i);
      }
    }
  }
  
  long long int res = 0;
  for(int i=0;i<n;i++)
  {
    res+=(v[i]^temp);
  }
  
  cout << res << endl;
  
  return 0;
  
}


Measured memory_bytes: 1400
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#include <bits/stdc++.h>//atcoderでsqrtを使うときに必要
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	ll N;

	cin >> N ;

	int max = 1;

	for (int i = 1; i <= sqrt(N); i++) {
		if (N%i == 0 && i > max) {
			max = i;
		}
	}


	if (max == 1) {
		ce(N-1)
	}
	else {
		ce(max-2+N/max)
	}


}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

auto solve(vector<int>& A, const unsigned int N) {
    if (A.size() <= N) return 0;
    sort(A.begin(), A.end());
    vector<int> moves;
    for (auto i = 0u; i < A.size() - 1; i++) {
        moves.push_back(A[i+1]-A[i]);
    }
    sort(moves.begin(), moves.end());
    return accumulate(moves.begin(), moves.begin() + (A.size() - N), 0);
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A;
    for (auto i = 0; i < M; i++) {
        int Ai;
        cin >> Ai;
        A.push_back(Ai);
    }
    cout << solve(A, N) << endl;
    return 0;
}

Measured memory_bytes: 1400
using System;
using System.Text;
using System.Linq;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            int[] input;
            char[] board = new char[] {'#', '.'};
            while(((input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray())[0] | input[1]) != 0) {
                for(int i = 0; i < input[0]; ++i){
                    int index = i & 0x01;
                    var output = new StringBuilder(input[1]);
                    for(int l = 0; l < input[1]; ++l, index ^= 1){
                        output.Append(board[index]);
                    }
                    Console.WriteLine(output.ToString());
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 5824
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;



long long int N,M,K,A[200200],sum=0,res=0;

int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>K;
    cout<<min(N%K,K-N%K)<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        string[] strs = new string[n];
        for (int i = 0; i < n; i++)
        {
            strs[i] = sc.Next();
        }

        string answer = "";

        for (int i = 0; i < 26; i++)
        {
            char c = (char)('a' + i);

            int min = int.MaxValue;
            for (int j = 0; j < n; j++)
            {
                string str = strs[j];
                min = Math.Min(min, str.Where(s => s == c).Count());
            }
            for (int j = 0; j < min; j++)
            {
                answer += c.ToString();
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

#define gif(a,b) ((a)/(b)+((a)%(b)?1:0))
#define float long double
#define int long long 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define w(x) cout<<(#x)<<" is "<<(x)<<"\n";
using namespace std;

int32_t main()
{ 
    IOS
        int a, b, c, x, y;
        cin >> a >> b >> c >> x >> y;
        if(a + b < 2*c)
        {
            cout << x*a + y*b ; 
        }
        else
        {
            int ans = min(x, y);
            if(ans == x)
            {
                ans *= 2*c;
                y = y - x;
                if(b > 2*c) 
                    ans += y*2*c;
                else
                    ans += b*y;
            }
            else
            {
                ans *= 2*c;
                x = x - y;
                if(a > 2*c) 
                {
    
                    ans += x*2*c;
                }

                else
                    ans += a*x;
            }
            
            cout << ans ;
        
        }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    rep(i, h) {
        rep(j, w) {
            if ((i < b) ^ (j < a)) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
}


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

public class Main{

	public static void main(String[] args) {

		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		int kosu=0;

		int[] sosu=new int[55];
		sosu[0]=11;
		sosu[1]=31;
		sosu[2]=41;
		sosu[3]=61;
		sosu[4]=71;
		sosu[5]=101;
		sosu[6]=131;
		sosu[7]=151;
		sosu[8]=181;
		sosu[9]=191;
		sosu[10]=211;
		sosu[11]=241;
		sosu[12]=251;
		sosu[13]=271;
		sosu[14]=281;
		sosu[15]=311;
		sosu[16]=331;
		sosu[17]=401;
		sosu[18]=421;
		sosu[19]=431;
		sosu[20]=461;
		sosu[21]=491;
		sosu[22]=521;
		sosu[23]=541;
		sosu[24]=571;
		sosu[25]=601;
		sosu[26]=631;
		sosu[27]=641;
		sosu[28]=661;
		sosu[29]=691;
		sosu[30]=701;
		sosu[31]=751;
		sosu[32]=761;
		sosu[33]=811;
		sosu[34]=821;
		sosu[35]=881;
		sosu[36]=911;
		sosu[37]=941;
		sosu[38]=971;
		sosu[39]=991;
		sosu[40]=1021;
		sosu[41]=1031;
		sosu[42]=1051;
		sosu[43]=1061;
		sosu[44]=1091;
		sosu[45]=1151;
		sosu[46]=1171;
		sosu[47]=1181;
		sosu[48]=1201;
		sosu[49]=1231;
		sosu[50]=1291;
		sosu[51]=1301;
		sosu[52]=1321;
		sosu[53]=1361;
		sosu[54]=1381;

		try {
			str=bfr.readLine();

			if(str.equals("")) {

			}
			else {
				kosu=Integer.parseInt(str);
				String mojirt="";
				for(int i=0; i<kosu; i++) {
					mojirt=mojirt+sosu[i]+" ";
				}

				System.out.println(mojirt);
			}
		}catch(IOException e) {

		}

		catch(NumberFormatException ee) {
			System.exit(0);
		}

		catch(NullPointerException eee) {
			System.exit(0);
		}



	}
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline vi32 plist(i32 n) { vi32 f(n, 1); f[0] = f[1] = 0; repi(i, 2, n) for (int j = i * 2; j < n; j += i) f[j] = 0; return f; }
inline bool isprime(i32 n) { if (n < 2) return 0; for (i32 i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; }
template<class T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<class T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<class T> inline bool amax(T &x, T y) { if (x >= y) return 0; x = y; return 1; }
template<class T> inline bool amin(T &x, T y) { if (x <= y) return 0; x = y; return 1; }
template<class T> inline i64 lbi(vector<T> &v, T e) { return lower_bound(all(v), e) - v.begin(); }
template<class T> inline i64 ubi(vector<T> &v, T e) { return upper_bound(all(v), e) - v.begin(); }
template<class T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }

int x[1010];
vector<int> children[1010];

int rec(int v) {
  if (children[v].size() == 0) {
    return 0;
  }
  i32 sum = 0;
  vi32 dp(x[v] + 1, false);
  dp[0] = true;
  for (auto child : children[v]) {
    int r = rec(child);
    int l = x[child];
    if (r == -1) return -1;
    sum += r + l;
    rrep(i, x[v] + 1) {
      if (!dp[i]) continue;
      dp[i] = false;
      if (i + r <= x[v]) dp[i + r] = true;
      if (i + l <= x[v]) dp[i + l] = true;
    }
  }
  int idx = -1;
  rrep(i, x[v] + 1) {
    if (dp[i]) {
      idx = i;
      break;
    }
  }
  if (idx == -1) return -1;
  return sum - idx;
}

int main() {
  ioinit();
  int n;
  cin >> n;
  vi32 p(n);
  p[0] = -1;
  reps(i, n - 1) {
    cin >> p[i], p[i]--;
    children[p[i]].push_back(i);
  }
  rep(i, n) cin >> x[i];
  if (rec(0) != -1) {
    cout << "POSSIBLE" << '\n';
  } else {
    cout << "IMPOSSIBLE" << '\n';
  }
  return 0;
}


Measured memory_bytes: 5760
import Data.List
import Control.Monad

main :: IO ()
main = print =<< solve . map read . words <$> getLine

solve :: [Integer] -> Integer
solve [n, p] = product . map (\(x, len) -> (x ^ (len`div`n))) . pf $ p 

pf :: Integer -> [(Integer, Integer)]
pf n = map (\xs -> (head xs, (fromIntegral.length) xs)) . group $ pf' n (2:[3,5..(truncate.sqrt.fromIntegral $ n)])
  where
   pf' 1 _ = []
   pf' n [] = [n]
   pf' n (x:xs) = if (n `mod` x) == 0
     then x : pf' (n `div` x) (x:xs)
     else pf' n xs

Measured memory_bytes: 892