akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        _n: usize,
        s: chars,
    }
    let ans = s.windows(2).filter(|xy| xy[0] != xy[1]).count() + 1;
    println!("{}", ans);
}


Measured memory_bytes: 4352
s=input()
n=len(s)
if n%2==0:
    a=n//2-1
    b=n//2
    l=0
    r=0
    for i in range(1,n//2+1):
        if s[b-i]==s[b-i+1]:
            l+=1
            continue
        else:
            break
    for i in range(1,n//2+1):
        if s[a+i]==s[a+i-1]:
            r+=1
            continue
        else:
            break
    ans=n//2+min(l,r)
    print(ans)
else:
    a=n//2
    l=1
    r=1
    for i in range(1,n//2+1):
        if s[a-i]==s[a-i+1]:
            l+=1
            continue
        else:
            break
    for i in range(1,n//2+1):
        if s[a+i]==s[a+i-1]:
            r+=1
            continue
        else:
            break
    ans=n//2+min(l,r)
    print(ans)     

Measured memory_bytes: 39408
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] x = new Integer[m];
        Integer[] y = new Integer[m];
        for (int i = 0; i < m; i++) {
            x[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        int[] ball = new int[n + 1];
        Arrays.fill(ball, 1);
        int[] red = new int[n + 1];
        red[1]++;
        for (int i = 0; i < m; i++) {
            ball[x[i]]--;
            ball[y[i]]++;
            if (0 < red[x[i]]) {
                red[y[i]] = 1;
                if (ball[x[i]] <= 0) {
                    red[x[i]] = 0;
                }
            }
        }
        int result = Arrays.stream(red).sum();

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 64560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, m; cin >> n >> m;
  ll maxg=1;
  ll i = 1;
  while (i*i <= m) {
    if (m % i == 0) {
      if (m/i >= n) maxg = max(maxg, i);
      if (i >= n) maxg = max(maxg, m/i);
    }
    i++;
  }
  cout << maxg << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/integer/common_factor.hpp>
using namespace std;
using namespace boost::integer;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  a=gcd(a,b);
  for(int i=0;i<n-2;++i){
    cin>>b;
    a=gcd(a,b);
  }
  cout<<a;
  return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int N = input();
    i64 X = input();

    vector< i64 > rec(N + 1);
    rec[0] = 1;
    range(i, 1, N + 1) rec[i] = 2 * rec[i - 1] + 3;

    vector< i64 > pat(N + 1);
    pat[0] = 1;
    range(i, 1, N + 1) pat[i] = 2 * pat[i - 1] + 1;

    i64 ans = 0;
    while (X) {
        if (X == rec[N]) {
            ans += pat[N];
            X -= rec[N];
            break;
        }

        X -= 1;

        if (X > rec[N - 1]) {
            ans += pat[N - 1] + 1;
            X -= rec[N - 1] + 1;
        }

        N -= 1;
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
def main():
  A,V = map(int, input().split())
  B,W = map(int, input().split())
  T = int(input())


  if A<=B:
      after_A=A+V*T
      after_B=B+W*T
      if after_B<=after_A:
          print("YES")
      else:
          print("NO")
  else:
      after_A=A-V*T
      after_B=B-W*T
      if after_A<=after_B:
          print("YES")
      else:
          print("NO")

if __name__=='__main__':
  main()


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	ll a, b, n;
	cin >> a >> b >> n;

	// N以下の整数で、Bで割った余りが最も大きい物。
	ll x = min(n,b-1);
	cout << (a*x)/b - a*(x/b) << endl;

}


Measured memory_bytes: 3556
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    x,y,z,n = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    a.sort(reverse=1)
    b.sort(reverse=1)
    c.sort(reverse=1)
    
    def check(p):
        cnt = 0
        for i in range(x):
            for j in range(y):
                for k in range(z):
                    if a[i]+b[j]+c[k] < p:
                        break
                    cnt += 1
                    if cnt==n:
                        return True
        return False

    left = 0
    right = 10**15
    while right-left>1:
        mid = (right+left)//2
        if check(mid):
            left = mid
        else:
            right = mid
    
    res = []
    for i in range(x):
        for j in range(y):
            for k in range(z):
                if a[i]+b[j]+c[k] < left+1:
                    break
                res.append(a[i]+b[j]+c[k])
    res.sort(reverse=1)
    if len(res)<n:
        for i in res:
            print(i)
        for _ in range(n-len(res)):
            print(left)
    else:
        for i in res:
            print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 45916
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int W = in.nextInt();
		int H = in.nextInt();
		int x = in.nextInt();
		int y = in.nextInt();
		int r = in.nextInt();
		
		
		if(x+r<=W && x-r>=0 && y+r<=H && y-r>=0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17328
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>
#include <atcoder/convolution>
#include <atcoder/modint>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
	// printElems(&a[0], &a[n]);　みたいな感じで使う。
	void printElems(const int* begin, const int* end)
	{
		for (const int* p = begin; p != end; ++p) {
			cout << *p << ' ';
		}
		cout << endl;
	}
}

#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<n+1; i++)
#define repr(i,n) for(ll i=n-1; i>=0; i--)
#define repr1(i,n) for(ll i=n; i>0; i--)
#define FOR(i,j,n) for(ll i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(ll i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<ll,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const ll BIG = 1LL<<60;
const string yes = "Yes";
const string no = "No";

//----------------------------------------------

dsu d(200005);


int main(){
	int n,q;
	cin >> n >> q;
	vi ans;
	rep(i,q){
		int t,u,v;
		cin >> t >> u >> v;
		if(t == 0){
			d.merge(u,v);
		}
		else{
			if(d.same(u,v)){
				ans.push_back(1);
			}
			else{
				ans.push_back(0);
			}
		}
	}
	for(int x : ans){
		prints(x);
	}


	return 0;
}




Measured memory_bytes: 4696
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data',function (chunk){
var line =chunk.split(' ');
var a = parseInt(line[0],10);
var b = parseInt(line[1],10);
var menseki = a*b;
var nagasa= 2*a+2*b;
console.log(menseki+' '+nagasa);
});

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

int main(void){
  ll ai,ao,at,aj,al,as,az;
  cin >> ai >> ao >> at >>
    aj >> al >> as >> az;
  ll res = 0;
  res += ao;
  res += (ai/2)*2;
  res += (aj/2)*2;
  res += (al/2)*2;
  if(ai%2 + aj%2 + al%2 == 3)res += 3;
  else if(ai%2 + aj%2 + al%2 == 2){
    if(ai%2 == 0 && ai != 0)res += 1;
    else if(aj%2 == 0 && aj != 0)res += 1;
    else if(al%2 == 0 && al != 0)res += 1;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 384
n,k = map(int,input().split())
alist = list(map(int,input().split()))
memo = []
p = 1
vis = ['.']*n
while vis[p-1] == '.':
    memo.append(p)
    vis[p-1] = 'v'
    p = alist[p-1]
 
loop = memo.index(p)
if k < len(memo):
    print(memo[k])
else:
    print(memo[loop+(k-loop)%(len(memo)-loop)])

Measured memory_bytes: 32312
N = int(input())
T, A = map(int, input().split())
h = list(map(int, input().split()))


min = 10000
mini = 0

for i, x in enumerate(h):
  val = T - x*0.006
  gap = abs(A-val)
  if gap < min:
    min = gap
    mini = i

print(mini+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);

vector<ll> v;

ll counter(ll t){
    ll cnt = 0;
    rep(i, v.size()){
        if(v[i] == t) cnt++;
    }
    return cnt;
}


int main(){
    ll n; cin >> n;
    set<ll> s;
    v.resize(n);
    rep(i, n){
        cin >> v[i];
        s.insert(v[i]);
    }
    if(s.size() == 3){
        ll x = 0;
        vector<ll> nums;
        for(auto p: s){
            x ^= p;
            nums.push_back(p);
        }
        if(x == 0 && counter(nums[0]) == counter(nums[1]) && counter(nums[1]) == counter(nums[2])) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(s.size() == 2){
        sort(all(v));
        if(v[0] == 0 && counter(0) * 3 == n && counter(v[n-1]) == n * 2 / 3) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(s.size() == 1){
        if(v[0] == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

long long int N, T, ans = 1000000000, c, t;
vector<pair<long long, long long>> keiro;

int main(){
    scanf("%lld%lld", &N, &T);
    for(int i = 0; i < N; ++i){
        scanf("%lld%lld", &c, &t);
        if(t <= T){
            ans = min(ans, c);
        }
    }
    if(ans < 10000)printf("%lld\n", ans);
    else puts("TLE");
    return 0;
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        long ans = 0;
        long N = ReadLong();
        long min = long.MaxValue;
        for (int i = 0; i < 5; i++)
        {
            long num = ReadLong();
            min = Math.Min(min, num);
        }
        if (N % min == 0)
        {
            ans = N / min + 4;
        }
        else
        {
            ans = N / min + 5;
        }
        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/

 

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n,a,b;
    std::cin >> n>>a>>b;
    ll ans=modpow(2ll,n,MOD)-1ll;
    ll aa=1ll,bb=1ll;
    
    
    rep(i,a){
        aa*=(n-i);
        aa%=MOD;
    }
    rep(i,a){
        aa=aa*modinv((i+1),MOD)%MOD;
    }
    
    rep(i,b){
        bb*=(n-i);
        bb%=MOD;
    }
    rep(i,b){
        bb=bb*modinv((i+1),MOD)%MOD;
    }
    //std::cout << aa<<bb << std::endl;
    ans-=aa;ans-=bb;
    while(ans<0ll){
        ans+=MOD;
    }
    std::cout << ans << std::endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N, i;
    long long sum = 0;
    scanf("%d", &N);
    for(i = 1;i <= N;i++){
        if(i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

const int INF = 1e9 + 10;

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, c1, c2, c3;
  cin >> n >> m >> c1 >> c2 >> c3;
  vector<int> a(c1);
  for (auto &it : a) {
    cin >> it;
  }
  vector<int> b(c2);
  for (auto &it : b) {
    cin >> it;
  }
  vector<int> c(c3);
  for (auto &it : c) {
    cin >> it;
  }
  sort(all(a));
  sort(all(b));
  sort(all(c));
  vector<int> suf3(c3);
  suf3.back() = c.back();
  for (int i = c3 - 2; i >= 0; i--) {
    suf3[i] = suf3[i + 1] + c[i];
  }
  vector<int> suf2(c2);
  suf2.back() = b.back();
  for (int i = c2 - 2; i >= 0; i--) {
    suf2[i] = suf2[i + 1] + b[i];
  }
  int ptr = c1 - 1, cs = 0, ans = 0;
  for (int cnt1 = 0; cnt1 <= min(c1, n); cnt1++) {
    int take = n - cnt1;
    if (take <= c3 && c2 + c3 - take >= m) {
      int l = 1, r = INF;
      while (r - l > 1) {
        int mid = (l + r) / 2;
        int A = b.end() - lower_bound(all(b), mid), 
        B = max(0ll, (c.end() - lower_bound(all(c), mid)) - take);
        if (A + B >= m) {
          l = mid;
        }
        else {
          r = mid;
        }
      }
      int A = b.end() - lower_bound(all(b), l), 
      B = max(take, int(c.end() - lower_bound(all(c), l)));
      ans = max(ans, cs + suf3[c3 - B] + suf2[c2 - A] - (A + B - take - m) * l);
    }
    if (ptr >= 0) {
      cs += a[ptr--];
    }
  }
  cout << ans << '\n';
} 

Measured memory_bytes: 4224
#include<stdio.h>

int main(){
int n,ans=0,flag[100001],i,a;
scanf("%d",&n);
for(i=0;i<100000;i++)
flag[i]=0;
for(i=0;i<n;i++){
scanf("%d",&a);
if(flag[a-1]==0){
flag[a-1]=1;
ans++;
}
}
if(ans%2==0)
ans--;
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    int N;
    long K;
    long A[100000];
    long X = 0;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i <= 40; i++){
        long n = (long)1 << i;
        if(n > K) break;
        int cnt1 = 0;
        int cnt0 = 0;
        for(int j = 0; j < N; j++){
            if(n&A[j]) cnt1++;
            else cnt0++;
            //cout << n << ' ' << A[i] << endl;
        }
        if(cnt0 > cnt1){
            X = X | n;
        }
    }
    
    //cout << X << endl;
    long long ans = 0;
    long long tmp = 0;
    for(int i = 0; i < N; i++){
        ans += K^A[i];
    }
    if(X <= K){
        for(int i = 0; i < N; i++){
            tmp += (X^A[i]);
        }
    }
    ans = max(tmp, ans);
    for(int j = 0; j <= 40; j++){
        tmp = 0;
        long n = (long)1 << j;
        if(K & n){
            //cout << "j " << j << endl;
            long long X1 = 0;
            for(int k = 0; k < j; k++){
                X1 += X&((long)1 << k);
                //cout << X1 << endl;
            }
            for(int k = j+1; k <= 40; k++){
                //if((1<< k) > K) break;
                //cout << k << endl;
                X1 += K&((long)1 << k);
            }
            for(int i = 0; i < N; i++){
                tmp += (X1^A[i]);
            }
            //cout << X1 << endl;
            ans = max(tmp, ans);
        }
    }
    cout << ans << endl;
}

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

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

  map<int, long long> dp;
  dp[0] = 0;

  rep(i, N) {
    for (auto it = dp.rbegin(); it != dp.rend(); it++) {
      int cost = it->first; long long value = it->second;
      if (cost + w[i] > W) continue;
      dp[cost + w[i]] = max(dp[cost + w[i]], value + v[i]);
    }
  }

  long long ans = 0;
  for (auto x : dp) ans = max(ans, x.second);
  cout << ans << endl;
}

Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n, c, b;
    cin >> n >> c >> b;
    ll a[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    ll ans = 0;
    for(ll i = 0; i < n-1; i++){
        if((a[i+1]-a[i])*c < b) ans+=(a[i+1]-a[i])*c;
        else ans+=b;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
typedef pair<long double, long double> p;
#define X first
#define Y second

p transition(p p0, p p1, p p2){
  p t, t0;
  double theta = atan2(p1.Y-p0.Y,p1.X-p0.X);
  double s = sin(theta), c = cos(theta);
  t0.X = c*(p2.X-p0.X)+s*(p2.Y-p0.Y);
  t0.Y = -s*(p2.X-p0.X)+c*(p2.Y-p0.Y);
  t.X = c*t0.X+s*t0.Y+p0.X;
  t.Y = s*t0.X-c*t0.Y+p0.Y;
  return t;
}

int main(){ _;
  p p0,p1,p2,t;
  int q;
  cin>>p0.X>>p0.Y>>p1.X>>p1.Y>>q;
  REP(i,q){
    cin>>p2.X>>p2.Y;
    t = transition(p0,p1,p2);
    printf("%.10Lf %.10Lf\n", t.X, t.Y);
  }
}

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

typedef long long ll;

template<typename T>
T gcd(T a, T b){
    if (a < b) return gcd(b, a);
    T r = a % b;
    while (r){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

template<typename T>
T lcm(T a, T b){
    return a * b / gcd(a, b);
}

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);

    ll l = 1;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        l = lcm(l, a[i] / 2);
    }

    ll ans;
    if (m < l) ans = 0;
    else ans = 1 + (m - l) / (2 * l);
    for (int i = 0; i < n; i++){
        if ((l / (a[i] / 2)) % 2 == 0) {
            ans = 0;
            break;
        }
    }
    cout << ans << endl;
}


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

#define f(i, q) for(int i = 0; i < q; i++)  

typedef long long ll;

ll X, Y, Z, K, A[1009], B[1009], C[1009];
vector<ll> vec;

int main() {
    cin >> X >> Y >> Z >> K;
    for(int i = 0; i < X; i++) {
        cin >> A[i]; 
    }
    sort(A, A + X, greater<ll>());
    for(int i = 0; i < X; i++) {
        cin >> B[i]; 
    }
    sort(B, B + Y, greater<ll>());
    for(int i = 0; i < Z; i++) {
        cin >> C[i]; sort(C, C + Z, greater<ll>());
    }
    sort(C, C + Z, greater<ll>());

    for(int i = 0; i < X; i++) {
        for(int j = 0; j < Y; j++) {
            for(int k = 0; k < Z; k++) {
                if((i + 1) * (j + 1) * (k + 1) <= K) vec.push_back(A[i] + B[j] + C[k]);
                else break;
            }
        }
    }

    sort(vec.begin(), vec.end(), greater<ll>());
    for(int i = 0; i < K; i++) cout << vec[i] << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for (int i = 0; i < (int)(n); ++i)
#define mod 1000000007
#define bigger(a,b) (a>b?a:b)
#define smaller(a,b) (a<b?a:b)
#define mem(A,g) memset(A,g,sizeof(A))
#define gc getchar_unlocked
#define positive(a) (bigger(a,-a))

const int INF = 1e9 + 5;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int n;
cin>>n;
vector<int>h;
for(int i=0;i<n;i++){
	int input;
	cin>>input;
	h.push_back(input);
}
vector<int>dp(n,INF);
dp[0] = 0;
for(int i=1;i<n;i++){
	dp[i]  = min(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
	if(i-2 >= 0)
	dp[i] = min(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
}
cout<<dp[n-1]<<"\n";

return 0;
}

Measured memory_bytes: 1144
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;

vector<int> Hl, Wl, maxH, maxW;
set<pair<int,int>> B;

int main(){
	int h,w,m;
	int y, x;
	scanf("%d%d%d",&h,&w,&m);
	Hl = vector<int>(h+1, 0);
	Wl = vector<int>(w+1, 0);
	B.clear();
	int maxy = -1, maxx = -1;
	int maxhv = 0, maxwv = 0;
	for(int i=0;i<m;i++){
		scanf("%d%d",&y,&x);
		B.insert(pair<int,int>(y,x));
		Hl[y]++;
		Wl[x]++;
		maxhv = max(maxhv, Hl[y]);
		maxwv = max(maxwv, Wl[x]);
	}
	maxH = vector<int>();
	maxW = vector<int>();
	for(int i=1;i<=h;i++)
		if(Hl[i] == maxhv)
			maxH.push_back(i);
	for(int j=1;j<=w;j++)
		if(Wl[j] == maxwv)
			maxW.push_back(j);
	
	/*printf("maxH: ");
	for(int i=0;i<maxH.size();i++) printf("%d ", maxH[i]);
	puts("");
	printf("maxW: ");
	for(int i=0;i<maxW.size();i++) printf("%d ", maxW[i]);
	puts("");*/
	
	if((long long)maxH.size() * (long long)maxW.size() > (long long)m){
		printf("%d\n", maxhv + maxwv);
	}else{
		for(int i=0;i<maxH.size();i++){
			for(int j=0;j<maxW.size();j++){
				if(!B.count(pair<int,int>(maxH[i], maxW[j]))){
					printf("%d\n", maxhv + maxwv);
					return 0;
				}
			}
		}
		printf("%d\n", maxhv + maxwv - 1);
	}
	
	return 0;
}

Measured memory_bytes: 23400
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)

#define X first
#define Y second

using namespace std; 
typedef pair<int,int> pii;
const int INF = 1e9;

int main(){
	int N, M, H, K;
	while(cin>>N>>M>>H>>K, N|M|H|K){
		vector<pii> edge[105];
		int cost[505], in_h[505], in_r[505];
		int S, T, P, pd[1<<8], pk[1<<8];
		fill(pd, pd+(1<<8), INF);

		rep(i,M){
			int a,b,c,h,r;
			cin >> a >> b >> cost[i] >> in_h[i] >> in_r[i];
			in_r[i]--;
			edge[a].emplace_back(b, i);
			edge[b].emplace_back(a, i);
		}
		cin >> S >> T >> P;
		rep(i,P){
			int l, d, k, s=0;
			cin >> l >> d;
			rep(j,l){
				cin >> k;
				k--;
				s |= (1<<k);
			}
			pk[i] = s;
			pd[i] = d;
		}

		int pass[1<<8];
		fill(pass, pass+(1<<8), INF);
		pass[0] = 0;
		rep(i,1<<K) rep(j,P){
			pass[i | pk[j]] = min( pass[i|pk[j]], pass[i] + pd[j] );
		}
		//rep(i,1<<K) cout << pass[i] << " "; cout << endl;

		int ans = INF;
		rep(k,1<<K){
			if( pass[k] >= ans ) continue;
			int d[105][30];
			fill( d[0], d[0]+105*30, ans - pass[k] );
			priority_queue<pair<int,pii>> que;
			d[S][0] = 0;
			que.push({0,{S,0}});
			while( !que.empty() ){
				int dd = que.top().X;
				int dn = que.top().Y.X;
				int dh = que.top().Y.Y;
				que.pop();
				if( dd > d[dn][dh] ) continue;
				for(auto t: edge[dn]){
					int nx = t.X;
					int nh = dh + in_h[t.Y];
					int ct = d[dn][dh];
					int r  = in_r[t.Y];
					if( !( (1<<r)&k ) ) ct += cost[t.Y];
					if( nh <= H && ct < d[nx][nh] ){
						for(int i=nh; i<=H; i++) d[nx][i] = min(d[nx][i], ct);
						que.push({ct, {nx,nh}});
					}
				}
			}
			int ret = INF;
			rep(h, H+1) ret = min(ret, d[T][h]);
			ans = min(ans, pass[k] + ret);
		}

		cout << (ans==INF ? -1 : ans) << endl;
	}
	return 0;
}

Measured memory_bytes: 3024
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)

N, K = nn()
A = nn()

for i in range(K, N):
    if A[i] > A[i-K]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 98400
def create_dice(nums):
    a, b, c, d, e, f = nums
    vertical = [a, b, f, e]
    horizontal = [b, c, e, d]
    return Dice(vertical, horizontal)


class Dice:
    def __init__(self, v, h):
        self.vertical = v
        self.horizontal = h

    def v2h(self):
        self.horizontal[0] = self.vertical[1]
        self.horizontal[2] = self.vertical[3]

    def h2v(self):
        self.vertical[1] = self.horizontal[0]
        self.vertical[3] = self.horizontal[2]

    def roll(self, direction):
        if direction == 'N':
            tmp1 = self.vertical[0]
            tmp2 = self.vertical[1:]
            self.vertical = tmp2 + [tmp1]
            self.v2h()
        elif direction == 'S':
            tmp1 = self.vertical[-1]
            tmp2 = self.vertical[:-1]
            self.vertical = [tmp1] + tmp2
            self.v2h()
        elif direction == 'E':
            tmp1 = self.horizontal[0]
            tmp2 = self.horizontal[1:]
            self.horizontal = tmp2 + [tmp1]
            self.h2v()
        elif direction == 'W':
            tmp1 = self.horizontal[-1]
            tmp2 = self.horizontal[:-1]
            self.horizontal = [tmp1] + tmp2
            self.h2v()


s1 = map(int, input().split(" "))
d1 = create_dice(s1)

s2 = map(int, input().split(" "))
d2 = create_dice(s2)


def match(l1, l2):
    lenlist = len(l1)
    lenset = len(set(l1))
    if lenlist == lenset:
        return l1[0] == l2[0]
    else:
        diff = 4 - (lenlist - lenset) + 1
        for i in range(diff):
            if l1[i] != l2[i]:
                return False
        return True

r = 0
while d1.vertical != d2.vertical and d1.horizontal != d2.horizontal and r < 4:
    # 強制的に一つ回す
    d2.roll("E")

    v = 0
    while not match(d1.vertical, d2.vertical) and v < 4:
        d2.roll("N")
        v += 1

    h = 0
    while not match(d1.horizontal, d2.horizontal) and v < 4:
        d2.roll("E")
        h += 1

    r += 1

if d1.vertical == d2.vertical and d1.horizontal == d2.horizontal:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5616
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


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


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


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


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    if input().isupper() :
        print("A")
    else:
        print("a")


if __name__ == '__main__':
    main()

Measured memory_bytes: 77908
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	int a = 0;
	string s;
	cin >> s;
	int i;
	
	for(int i = 0; i < s.length(); i++){
	if(s[i] == '+'){
		a++;
	}
	else {
		a--;
	}
	}
	
	cout << a << endl;
	return 0;

}

Measured memory_bytes: 256
/*||>>>> Praveen Ojha <<<<>>>> 20 July 2019 <<<<>>>> 18:02:28 <<<<||*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int n,d;
	cin>>n>>d;
	d*=2;
	d++;
	int ans=ceil((double)n/d);
	cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string b;
  cin>>b;
  if(b=="A"){
    cout<<"T";
  }
  else if(b=="T"){
    cout<<"A";
  }
  else if(b=="G"){
    cout<<"C";
  }
  else if(b=="C"){
    cout<<"G";
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b,ll mod){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n;cin>>n;
    vp v(1,P(0,-1));vi u;
    rep(i,n){
        ll a;cin>>a;
        if(a>v.back().fi)v.pb(a,i);
        else u.pb(a);
    }
    sort(all(u));reverse(all(u));
    reverse(all(v));
    vi ans(n);
    ll num=0,w=0;
    rep(i,v.size()-1){
        num++;
        ans[v[i].se]+=num*(v[i].fi-v[i+1].fi);
        while(w<u.size()){
            if(u[w]<v[i+1].fi)break;
            ans[v[i].se]+=u[w]-v[i+1].fi;
            num++;w++;
        }
    }
    for(ll x:ans)out(x);
    return 0;
}

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

int main(){
  int n,array[200000],m,array2[200000],j=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>array2[i];
  }
  sort(array,array+n);
  sort(array2,array2+m);
  for(int i=0;i<n;i++){
    j+=(array[i]==array2[j]);
    if(j==m){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cctype>

using namespace std;

using ull = unsigned long long;
constexpr ull B = 53173ULL;

vector<ull> rolling_hash(const string& s, int N, vector<ull>& p)
{
    vector<ull> _hash(N + 1);
    p.resize(N + 1);
    p[0] = 1;
    for (int i = 0; i < N; i++) {
        _hash[i + 1] = _hash[i] * B + s[i];
        p[i + 1] = p[i] * B;
    }
    return _hash;
}

bool check(const vector<ull>& v, ull x)
{
    return binary_search(v.begin(), v.end(), x);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S, T;
    cin >> S >> T;

    int s = S.size(), t = T.size();

    vector<ull> p;
    auto ht = rolling_hash(T, t, p);
    
    auto gen_ch = [](int x) -> char {
        if (x < 26) return (char)('a' + x);
        x -= 26;
        return (char)('A' + x);
    };
    
    vector<ull> v;
    for (int i = 0; i < t; i++) {
        for (int j = 0; j < 52; j++) {
            char ch = gen_ch(j);
            if (ch == T[i]) continue;
            auto hv = ht[t] + (ch - T[i]) * p[t - i - 1];
            v.emplace_back(hv);
        }
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    
    auto hs = rolling_hash(S, s, p);
    
    int res = 0;
    for (int i = 0; i <= s - t; i++) {
        
        if (check(v, hs[i + t] - hs[i] * p[t])) {
            ++res;
        }
    }  
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 71584
fun main(args: Array<String>) {
    val (w, h, n) = readLine()!!.split(' ').map { it.toInt() }
    val grid = Array(h) { IntArray(w) { 1 } }
    repeat(n) {
        val (xi, yi, a) = readLine()!!.split(' ').map { it.toInt() }
        when (a) {
            1 -> {
                for (y in 0 until h) {
                    for (x in 0 until xi) {
                        grid[y][x] = 0
                    }
                }
            }
            2 -> {
                for (y in 0 until h) {
                    for (x in xi until w) {
                        grid[y][x] = 0
                    }
                }
            }
            3 -> {
                for (y in 0 until yi) {
                    for (x in 0 until w) {
                        grid[y][x] = 0
                    }
                }
            }
            4 -> {
                for (y in yi until h) {
                    for (x in 0 until w) {
                        grid[y][x] = 0
                    }
                }
            }
            else -> {}
        }
    }
    println(grid.sumBy { it.sum() })
}


Measured memory_bytes: 38848
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;

int main(){
	int n;
	cin>>n;
	while(n--){
		set<string> s;
		string input ,a,b;
		cin>>input;
		for(int m=1;m<input.size();m++){
			a=input.substr(0, m);
			b=input.substr(m,input.size());
			for(int i=0;i<4;i++){
				if(i&1)reverse(a.begin(),a.end());
				else   reverse(b.begin(),b.end());
				s.insert(a+b);
				s.insert(b+a);
			}
		}
		cout<<s.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define lli long long int
#define pb push_back
#define FORA(i,s,e) for(int i = s; i < e; i++)
#define FORB(i,s,e) for(int i = s; i <= e; i++)

using namespace std;


int main(void)
{
	lli n;
	cin >> n;
	vector<lli> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	lli sum = 0;
	vector <lli> ans(n);
	for(int i = 0; i < n; i++)
	{ 
		ans[n - 1 - i] = sum;
		sum = (sum + a[n - 1 - i])%1000000007;
	}

	lli fin = 0;
	for (int i = 0; i < n; i++)
	{
		fin += (a[i] * ans[i]) % 1000000007;
	}

	cout << fin % 1000000007 << endl;
	return 0;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
string s;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    for (int i=0;i<s.size();i++){
        cout<<'x';
    }
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
	return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int func(long long N, std::string S, std::string T)
{
	// cout << fixed << setprecision(8);
	rep(i, N)
	{
		cout << S[i] << T[i];
	}
	cout << endl;

	return 0;
}

int main()
{
	long long N;
	scanf("%lld", &N);
	std::string S;
	std::cin >> S;
	std::string T;
	std::cin >> T;

	func(N, S, T);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int num[9],p[9];

int isUp(int depth){
	int i,j;
	int res;

	for(i=0;i<9;i++){
		if(depth==4){
			if(p[i]==2) return 1;
		}
		if(i+2<9 && p[i] && p[i+1] && p[i+2]){
			p[i]--;
			p[i+1]--;
			p[i+2]--;
			res = isUp(depth+1);
			p[i]++;
			p[i+1]++;
			p[i+2]++;
			if(res) return 1;
		}
		if(p[i]>2){
			p[i]-=3;
			res = isUp(depth+1);
			p[i]+=3;
			if(res) return 1;
		}
	}

	return 0;
}

int main(void){
	int i,j;
	char ch13[15];
	int ans[9];

	for(;scanf("%s",ch13)==1;){
		for(i=0;i<9;i++) ans[i]=0;
		for(i=0;i<9;i++) num[i]=0;
		for(i=0;i<13;i++) num[ch13[i]-'0'-1]++;

		int cur=0;
		for(i=1;i<=9;i++){
			for(j=0;j<9;j++)
				p[j]=num[j];

			if(p[i-1]>=4) continue;
			p[i-1]++;

			if(isUp(0)){
				ans[cur]=i;
				cur++;
			}
		}

		if(cur==0){
			printf("0\n"); 
			continue;
		}

		for(i=0;i<cur;i++){
			printf("%d",ans[i]);
			if(i<cur-1)
				printf(" ");
		}
		puts("");
	}

	return 0;
}

Measured memory_bytes: 0