akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] ab = sc.intarr;

            int a = ab[0] % 2;
            int b = ab[1] % 2;

            if(a==1 && b==1)
            {
                wr.wri("Odd");
            }
            else
            {
                wr.wri("Even");
            }
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


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

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            if (input[2] == input[3] && input[4] == input[5]) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


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

int main() {
  int N, A, B;
  cin  >>  N  >>  A  >>  B;
  if (N * A >= B) {
    cout  <<  B  <<  endl;
  }
  else {
    cout  <<  N * A  << endl;
  }
}

Measured memory_bytes: 256
let () =
  let num_card =
    Array.init 3 @@ fun _ ->
      Array.init 3 @@ fun i -> 
        if i = 2 
        then Scanf.scanf " %d\n" Fun.id
        else Scanf.scanf " %d" Fun.id in
  let bingo = Array.make_matrix 3 3 false in
  Scanf.scanf "%d\n" @@ fun n ->
  for i = 0 to n - 1 do
    Scanf.scanf "%d\n" @@ fun b ->
    for i = 0 to 2 do
      for j = 0 to 2 do
        if num_card.(i).(j) = b then bingo.(i).(j) <- true
      done
    done
  done;
  print_endline @@
  if
    bingo.(0) = [| true; true; true |] ||
    bingo.(1) = [| true; true; true |] ||
    bingo.(2) = [| true; true; true |] ||
    Array.init 3 (fun i -> bingo.(i).(0)) = [| true; true; true |] ||
    Array.init 3 (fun i -> bingo.(i).(1)) = [| true; true; true |] ||
    Array.init 3 (fun i -> bingo.(i).(2)) = [| true; true; true |] ||
    Array.init 3 (fun i -> bingo.(i).(i)) = [| true; true; true |] ||
    Array.init 3 (fun i -> bingo.(i).(2-i)) = [| true; true; true |]
  then "Yes"
  else "No"

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  	if ((r * 100 + g * 10 + b) % 4 == 0) {
      cout << "YES" << endl;
    }
  	else {
      cout << "NO" << endl;
    }
}

      
      

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int a[100000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N, K, S;
    cin  >> N >> K >> S;
    if(S == 1e+9){
        for(int i = 0; i < K; i++){
            a[i] = S;   
        }
        for(int i = K; i < N; i++){
            a[i] = 1;
        }
    }else{
        for(int i = 0; i < K; i++){
            a[i] = S;   
        }
        for(int i = K; i < N; i++){
            a[i] = S+1;
        }
    }
    for(int i = 0; i < N-1; i++){
        cout << a[i] << ' ';
    }
    cout << a[N-1] << endl;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
 int q,p,w[1000001],u[1000001],o;
 string a;
 int main()
 {
     cin>>a;
     for (int i=0;i<a.size();i++)
     {
         if (a[i]=='C') 
         {
             p++;
             u[p]=i+1;
         }
         else if (a[i]=='F')
         {
            q++;
             w[q]=i+1;
         }
     }
     if (q>=1 && p>=1)
     {
     for (int i=1;i<=p;i++)
     {
         for (int j=1;j<=q;j++)
         {
             if (u[i]<w[j])
             {
                 o=1;
             }
         }
     }
     if (o==1) cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
     }
     else cout<<"No"<<endl;
 }

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

template<typename W>
struct Edge { 
    int to,rev;
    W cap;
    Edge(int to, int rev, W cap) : to(to), rev(rev), cap(cap) {}
};

template<typename W>
using Graph = vector<vector<Edge<W>>>;

template<typename W>
struct NetWork {
    Graph<W> G;
    NetWork(int V) : G(V) { }
    void add_edge(int from, int to, W cap) {
        G[from].emplace_back(to, (int)G[to].size(), cap);
        G[to].emplace_back(from, (int)G[from].size()-1, 0);
    }
};

// private
template<typename W>
void bfs(int s, Graph<W> &g, vector<int> &level) {
    fill(level.begin(),level.end(), -1);
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()) {
        int v=que.front();que.pop();
        for(auto &e : g[v]) {
            if( e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v]+1;
                que.push(e.to);
            }
        }
    }
}

// private
template<typename W>
W dfs(int v,int t,W f, Graph<W> &g, vector<int> &iter, vector<int> &level) {
    if(v==t) return f;
    for(int &i = iter[v] ; i < g[v].size();i++ ) {
        Edge<W> &e = g[v][i];
        if( e.cap > 0 && level[v]<level[e.to] ) {
            int d = dfs(e.to, t , min(f , e.cap), g, iter, level);
            if( d > 0 ) {
                e.cap-=d;
                g[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// Dinic法
template<typename W>
W max_flow(NetWork<W> &network, int s, int t) {
    W flow = 0;
    // networkのグラフ
    Graph<W> &g = network.G;
    // level[i] : 頂点sから頂点iまでの最短距離
    vector<int> level(g.size(), -1);
    vector<int> iter(g.size(), 0);
    for( ; ; ) {
        bfs(s, g, level);
        // フローを流せるエッジが存在しない.
        if( level[t] < 0 ) return flow;
        fill(iter.begin(),iter.end(),0);
        int f;
        while( (f=dfs(s , t, numeric_limits<W>::max(), g, iter, level)) > 0){
            flow += f;
        }
    }
    return flow;
}

struct BipartiteGraph : NetWork<int> {
    vector<int> used;
    BipartiteGraph(int V) : NetWork<int>::NetWork(V+2) , used(V, false) { }
    void add_edge(int x, int y) {
        NetWork<int>::add_edge(x, y, 1);
        if (!used[x]) {
            NetWork<int>::add_edge(NetWork<int>::G.size()-2, x, 1);
            used[x] = true;
        }
        if (!used[y]) {
            NetWork<int>::add_edge(y, NetWork<int>::G.size()-1, 1);
            used[y] = true;
        }
    }
};

int max_matching(BipartiteGraph &g) {
    return max_flow(g, g.G.size()-2, g.G.size()-1);
}


int main(void) {
    int X, Y, E;
    cin >> X >> Y >> E;
    BipartiteGraph g(X+Y);
    for(int i = 0;i < E;i++) {
        int x,y;
        cin >> x >> y;
        g.add_edge(x,X+y);
    }
    cout << max_matching(g) << endl;
}



Measured memory_bytes: 3208
import java.util.Scanner;

class Main{

	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		// String input = sc.nextLine();
	  // String nums[] = input.split(" ");

	  // long A = Long.parseLong(nums[0]);
	  // long B = Long.parseLong(nums[1]);
	  // long sum = Long.parseLong(nums[2]);

		System.out.println(C + " " + A + " "+ B);
		// System.out.println(S.toString());

	}
}

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


void solve(long long N, std::vector<long long> B){
    vector<ll> A(N);
    rep(i,N-1){
        if(i==0)A[0]=B[0];
        else{
        A[i]=min(B[i-1],B[i]);
        }
    }
    A[N-1]=B[N-2];
    ll ans=0;
    rep(i,N)ans+=A[i];
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::cout<<std::fixed<<std::setprecision(10);//誤差小数10桁まで
    long long N;
    scanf("%lld",&N);
    std::vector<long long> B(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(B));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <sysexits.h>
#include <math.h>
int main(void){
  int a,b,T,sum;
  if(scanf("%d %d %d",&a,&b,&T)!=3){
exit(1);
}

  sum = (T/a)*b;
  printf("%d",sum);
  return 0;
}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String W = sc.next();
        int count = 0;
        while(sc.hasNext()){
            String T = sc.next();
            if(T.equals("END_OF_TEXT")){
                break;
            }
            T = T.toLowerCase();
            if(T.equals(W)){
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26280
import math

a, b, x = map(int, input().split())
flag = False
if x > a*a*b/2:
  x = a*a*b - x
  flag = True
if flag:
    print(math.degrees(math.atan2(x/a/a*2, a)))
else:
    print(math.degrees(math.atan2(b, x/a/b*2)))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

ll Fac(ll N);
ll Exp(ll N, ll x);
ll comb(ll n, ll r);

int main()
{
    ll X, Y;
    cin >> X >> Y;
    ll m = (2 * Y - X) / 3;
    ll n = (2 * X - Y) / 3;
    if (((X + Y) % 3 != 0) || m < 0 || n < 0)
    {
        cout << 0 << endl;
        return 0;
    }
    if (m < n)
    {
        cout << comb(m + n, m) << endl;
    }
    else
    {
        cout << comb(m + n, n) << endl;
    }
}

ll Fac(ll N)
{
    if (N == 0)
    {
        return 1;
    }
    else
    {
        ll M = (N * Fac(N - 1)) % MOD;
        return M;
    }
}

ll Exp(ll N, ll x)
{
    if (N == 0)
    {
        return 1;
    }
    else if (N % 2 == 0)
    {
        ll A = (Exp(N / 2, x) * Exp(N / 2, x)) % MOD;
        return A;
    }
    else
    {
        ll B = (x * Exp(N - 1, x)) % MOD;
        return B;
    }
}

ll comb(ll n, ll r)
{
    ll A = Fac(r);
    ll B = 1;
    for (int i = 1; i <= r; i++)
    {
        B = (B * (n - i + 1)) % MOD;
    }
    return (B * Exp(MOD - 2, A)) % MOD;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  if(a % 2 == 0 ||b % 2 == 0 ||c % 2 == 0)cout << 0;
  else{
    long long ans = a*b;
    ans = min(ans,a*c);
    ans = min(ans,b*c);
    cout << ans;
  }
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  int A, B, C, X;
  std::cin >> A >> B >> C >> X;
  int ans = 0;
  for ( int a = 0; a <= A; a++ ) {
    for ( int b = 0; b <= B; b++ ) {
      int rest = X - (a * 500 + b * 100);
      if ( rest >= 0 && (rest % 50) == 0 && (rest / 50) <= C) {
        ans++;
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<ll> &s, ll a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        if (a % 2 == 1) continue;
        if (a % 3 == 0 || a % 5 == 0) continue;
        cout << "DENIED" << endl;
        return 0;
    }
    cout << "APPROVED" << endl;

}



Measured memory_bytes: 256
import math

N = int(input())
NMAX = 100010
dp = [float('inf')] * NMAX
dp[0] = 0
for i in range(1, N + 1):
    dp[i] = i
    if i >= 6:
        for j in range(1, int(math.log(NMAX, 6)) + 1):
            dp[i] = min(dp[i], dp[i - 6 ** j] + 1)

    if i >= 9:
        for j in range(1, int(math.log(NMAX, 9)) + 1):
            dp[i] = min(dp[i], dp[i - 9 ** j] + 1)
# print(dp)
print(dp[N])


Measured memory_bytes: 3828
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

const int N = 2e5;
std::vector<std::vector<int>> g;
int n, m;
string s;

bool ok[N];

void check(int i) {
  if(!ok[i]) return;
  auto ng = g[i];
  ng.clear();
  int cntA = 0, cntB = 0;
  for(int j : g[i]) {
    if(ok[j]) {
      ng.push_back(j);
      if(s[j] == 'A') cntA++;
      else cntB++;
    }
  }
  g[i] = ng;
  if(!cntA || !cntB) {
    ok[i] = 0;
    for(int j : g[i]) {
      check(j);
    }
  }
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n >> m;
  cin >> s;
  g.resize(n);
  for(int i = 0; i < m; i++) {
    int a, b; std::cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }

  for(int i = 0; i < n; i++) ok[i] = 1;

  for(int i = 0; i < n; i++) {
    check(i);
  }

  bool ans = 0;
  for(int i = 0; i < n; i++) ans |= ok[i];

  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 26320
N = int(input())
S = input()

R = [0] * N
G = [0] * N
B = [0] * N
SR = [0] * N
SG = [0] * N
SB = [0] * N
pr = 0
pg = 0
pb = 0
for i in range(N):
    if S[i] == "R":
        pr += 1
        SR[i] = pr
        R[i] = 1
    elif S[i] == "G":
        pg += 1
        SG[i] = pg
        G[i] = 1
    elif S[i] == "B":
        pb += 1
        SB[i] = pb
        B[i] = 1
        
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        if R[i]:
            if G[j]:
                if j+(j-i) <= N-1 and B[j + (j-i)] == 1:
                    ans += SB[N-1] - SB[j] - 1
                else:
                    ans += SB[N-1] - SB[j]
            if B[j]:
                if j+(j-i) <= N-1 and G[j + (j-i)] == 1:
                    ans += SG[N-1] - SG[j] - 1
                else:
                    ans += SG[N-1] - SG[j]
        if G[i]:
            if B[j]:
                if j+(j-i) <= N-1 and R[j + (j-i)] == 1:
                    ans += SR[N-1] - SR[j] - 1
                else:
                    ans += SR[N-1] - SR[j]
            if R[j]:
                if j+(j-i) <= N-1 and B[j + (j-i)] == 1:
                    ans += SB[N-1] - SB[j] - 1
                else:
                    ans += SB[N-1] - SB[j]
        if B[i]:
            if G[j]:
                if j+(j-i) <= N-1 and R[j + (j-i)] == 1:
                    ans += SR[N-1] - SR[j] - 1
                else:
                    ans += SR[N-1] - SR[j]
            if R[j]:
                if j+(j-i) <= N-1 and G[j + (j-i)] == 1:
                    ans += SG[N-1] - SG[j] - 1
                else:
                    ans += SG[N-1] - SG[j]
print(ans)

Measured memory_bytes: 69284
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  string s;
  cin>>s;
  int n=s.size();
  int64_t ans=0;
  for(int i=0;i<(1<<(n-1));i++){
      int64_t calc=0;
      for(int j=0;j<n-1;j++){
          calc*=10;
          int a=s[j]-'0';
          calc+=a;
          if((i>>j)&1){ans+=calc;calc=0;}
      }
      calc*=10;
      calc+=s[n-1]-'0';
      ans+=calc;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3584
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int[] arr = {a,b,c};
        Arrays.sort(arr);
        System.out.println(arr[0]+arr[1]);
    }
}


Measured memory_bytes: 35576
import sys
n = int(input())
lst = []
for _ in range(n):
    a = int(sys.stdin.readline())
    lst.append([[int(i) for i in sys.stdin.readline().split()] for _ in range(a)])
m = 0
for i in range(2 ** n):
    a = True
    d = 0
    for j in range(n):
        if i >> j & 1:
            d += 1
            for x, y in lst[j]:
                if (i >> (x - 1) & 1) != y:
                    a = False
                    break
    if a:
        m = max(m, d)
print(m)

Measured memory_bytes: 3064
#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()
{
	int N;
	cin >> N;

	map<string, int> map;
	int max_val = 0;

	rep(i, N) {
		string s;
		cin >> s;

		map[s]++;
		max_val = max(max_val, map[s]);
	}

	vector<string> ans;
	for (auto data = map.begin(); data != map.end(); data++) {
		if (data->second == max_val)
			ans.push_back(data->first);
	}

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

	for (auto a : ans)
		cout << a << endl;
}


Measured memory_bytes: 26868
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
int main(){
  vector<int> x(3);
  for(int i=0;i<3;i++)cin>>x.at(i);
  sort(x.begin(),x.end());
  if(x.at(0)==5&&x.at(1)==5&&x.at(2)==7)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include "stdio.h"
#include "cctype"
using namespace std;

int main(int argc, char const *argv[])
{
	char x;
	int sum[26]={0};

	while(cin >> x)
	{
		if(isalpha(x))
		{
			if(isupper(x))
			{
				x += 32;
			}
			sum[x-'a']++;
		}
	}

	for (int i = 0; i < 26; ++i)
	{
		printf("%c : %d\n",i + 'a',sum[i]);
	}
	return 0;
}


Measured memory_bytes: 3204
N = int(input())
T, A = map(int, input().split())
H = [int(_) for _ in input().split()]
ans = [float("INF")] * (N + 1)

for i, h in enumerate(H):
    kion = T - (h * 0.006)
    ans[i + 1] = abs(A - kion)

print(ans.index(min(ans)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n,x;
  cin>>n>>x;
  int a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  int sum=accumulate(a,a+n,0);
  x-=sum;
  int ans=n+ x/a[0];
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3608
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int n, k;
  readf("%s %s\n", &n, &k);
  if (n % k) {
    writeln(1);
  } else {
    writeln(0);
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int count = 0;
        int[] survey = new int[m+1];

        for (int i = 0; i < n; i++) {
            int kinds = sc.nextInt();
            for (int j = 0; j < kinds; j++) {
                if (++survey[sc.nextInt()] == n) count++;
            }
        }
        System.out.println(count);
    }
}

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

#define int long long
int dp[2234][2234];//dp[i][j]:i+1番目で左がj埋まってる
const long long LINF=1e18;
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
typedef pair<int,int> P;
#define fi first
#define se second

signed main(){
  int n;cin>>n;
  vector<P> v(n);
  for(int i=0;i<n;i++){
    int a;cin>>a;
    v[i]=P(a,i);
  }
  sort(v.rbegin(),v.rend());
  for(int i=0;i<n;i++){
    for(int j=0;j<=i+1;j++){
      if(j)chmax(dp[i+1][j],dp[i][j-1]+v[i].fi*abs(v[i].se-(j-1)));
      if(j<=i)chmax(dp[i+1][j],dp[i][j]+v[i].fi*abs(v[i].se-(n-1-(i-j))));
    }
  }
  int ans=0;
  for(int j=0;j<=n;j++)chmax(ans,dp[n][j]);
  cout<<ans<<endl;
}


Measured memory_bytes: 26980
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;


template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int a,b,c,d;
    vector<int> S(4, 0);
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i){
        string s;
        cin >> s;
        if(s == "AC"){
            ++S[0];
        }
        else if(s == "WA"){
            ++S[1];
        }
        else if(s == "TLE"){
            ++S[2];
        }
        else{
            ++S[3];
        }
    }

    cout << "AC x " << S[0] << endl;
    cout << "WA x " << S[1] << endl;
    cout << "TLE x " << S[2] << endl;
    cout << "RE x " << S[3] << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int k;
	cin>>k;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!='1')
		{
			cout<<s[i];
			return 0;
		}
		else if(i==k-1)
		{
			cout<<1;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
<?php
 $s = trim(fgets(STDIN));
 $q = trim(fgets(STDIN));
 $flag = true;
 for($i=0; $i<$q; $i++){
     $que = explode(" ", trim(fgets(STDIN)));
    //  print_r($que);
     if($que[0] == 1){
         $flag = !$flag;
     }else{
         if($que[1] == 1){
             if($flag){
                 $s = $que[2].$s;
             }else{
                 $s = $s.$que[2];
             }
         }else{
             if($flag){
                 $s = $s.$que[2];
             }else{
                 $s = $que[2].$s;
             }
         }
     }
 }
 
 if($flag){
     echo $s;
 }else{
     echo strrev($s);
 }

Measured memory_bytes: 17176
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    H,W=map(int,input().split())
    s=[[] for _ in range(H+2)]
    s[0]=s[H+1]=['#']*(W+2)
    white=-1
    for i in range(1,H+1):
        row=['#']+list(input())+['#']
        s[i]=row
        for cell in row:
            if cell=='.':
                white+=1
    queue=deque()
    queue.append([1,1])
    d=[[INF]*(W+2) for _ in range(H+2)]
    d[1][1]=0
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    while queue:
        cell=queue.popleft()
        for k in range(4):
            if s[cell[0]+dx[k]][cell[1]+dy[k]]=='.' and d[cell[0]+dx[k]][cell[1]+dy[k]]==INF:
                queue.append([cell[0]+dx[k],cell[1]+dy[k]])
                d[cell[0]+dx[k]][cell[1]+dy[k]]=min(d[cell[0]+dx[k]][cell[1]+dy[k]],d[cell[0]][cell[1]]+1)
    if d[H][W]==INF:
        print(-1)
    else:
        print(white-d[H][W])

if __name__ == '__main__':
    main()


Measured memory_bytes: 41328
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  long long int n, sum=0;	cin>>n;
  vector<long long int> A(n, 0);
  vector<long long int> B(n, 0);
  
  for(long long int i=0; i<n; i++)	
  {
    cin>>A[i];
    B[i]=A[i];
    sum += A[i];
  }
  
  for(long long int i=1; i<n; i++)	A[i] += A[i-1];
    
  long long int ans=0;
  for(long long int i=0; i<n; i++)
  {
    ans = (ans + B[i]*((sum-A[i])%1000000007)%1000000007)%1000000007;
  }
  
  cout<<ans;  
}

Measured memory_bytes: 6360
#include <iostream>
#include <queue>
using namespace std;
//queue <pair<int,int> > que;
//int n;
const int INF=100000;
int main()
{
	int n;
	cin>>n;
	vector< int > mp[n+5];
	for(int i=1;i<=n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		mp[x].push_back(y);
		mp[y].push_back(x);
	}
	int a[n+5][2];
	for(int i=1;i<=n;i++)
	{
		a[i][1]=INF;
		a[i][0]=INF;
	}
	bool mark[n+5]={false};
	mark[1]=true;
	mark[n]=true;
	a[1][0]=0;
	a[n][1]=0;
	queue <int> que;
	que.push(1);
	int k=-1;
	while(!que.empty())
	{
		k++;
		int u=que.size();
		for(int i=1;i<=u;i++)
		{
			int v=que.front();
			a[v][0]=k;
			mark[v]=true;
			que.pop();
//			cout<<v<<'k'<<k<<' ';
			for(int j=0;j<mp[v].size();j++)
			{
				if(!mark[mp[v][j]]) que.push(mp[v][j]),mark[mp[v][j]]=true;
			}
		}
	}
	que.push(n);
	k=-1;
//	cout<<endl<<"OK\n";
	for(int i=2;i<=n-1;i++) mark[i]=false;
	while(!que.empty())
	{
		k++;
		int u=que.size();
		for(int i=1;i<=u;i++)
		{
			int v=que.front();
			a[v][1]=k;
			mark[v]=true;
			que.pop();
//			cout<<v<<' ';
			for(int j=0;j<mp[v].size();j++)
			{
				if(!mark[mp[v][j]]) que.push(mp[v][j]),mark[mp[v][j]]=true;
			}
		}
	}
	int ans1=0,ans2=0;
	for(int i=1;i<=n;i++)
	{
//		cout<<i<<':'<<"Fennec:"<<a[i][0]<<"Snuke:"<<a[i][1]<<endl;
		if(a[i][0]<=a[i][1]){
			ans1++;
		}
		else{
			ans2++;
		}
	}
//	cout<<ans1<<' '<<ans2;
	if(ans1>ans2) cout<<"Fennec"; else cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

struct UnionFind{
    vector<ll> par;
    vector<ll> S;

    UnionFind(ll N):par(N),S(N){
        rep(i,N){
            par[i] = i;
            S[i] = 1;
        }
    }

    ll root(ll x){
        while(x != par[x]){
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool same(ll x,ll y){
        return root(x) == root(y);
    }
    
    void unite(ll x,ll y){
        if(root(x) == root(y)) return;
        S[root(x)] += S[root(y)];
        S[root(y)] = S[root(x)];
        if(S[x] >= S[y]){
            par[root(y)] = par[root(x)];
        }else{
            par[root(x)] = par[root(y)];
        }
    }

    ll SIZE(ll x){
        return S[root(x)];
    }
};

ll cnt[100010];
ll Bcnt[100010];

int main(){
    ll N,M,K;
    cin >> N >> M >> K;
    UnionFind UFF(N);
    rep(i,M){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        cnt[a]++;
        cnt[b]++;
        UFF.unite(a,b);
    }
    rep(i,K){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        if(UFF.same(a,b)){
            Bcnt[a]++;
            Bcnt[b]++;
        }
    }
    rep(i,N){
        cout << max(UFF.SIZE(i) - cnt[i] - Bcnt[i] - 1,0LL) << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 3968
#include"bits/stdc++.h"
using namespace std;

#define MAX 200002
#define MOD 1000000007

int n;

vector<int> v;

long long int dp[MAX];

map<int, deque<int> > mp;


int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int c;
		scanf("%d", &c);
		v.push_back(c);
		mp[c].push_back(i);
	}
	dp[0] = 1;
	for (int i = 0; i+1 < n; i++) {
		//leave
		dp[i + 1] += dp[i];
		dp[i + 1] %= MOD;
		//ope
		mp[v[i]].pop_front();
		if (v[i + 1] != v[i]) {
			if (mp[v[i]].size()) {
				int go = mp[v[i]].front();
				dp[go] += dp[i];
				dp[go] %= MOD;
			}
		}
	}
	printf("%lld\n", dp[n - 1]);
	return 0;
}

Measured memory_bytes: 146292
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
ll dp[100100][4];

signed main(){
	//cout << fixed << setprecision(10);
	ll n,k,r,s,p; cin>>n>>k>>r>>s>>p;
	string t; cin>>t;
	ll ans=0;
	vector<bool> ok(n,0);
	rep(i,0,n){
		if(ok[i])continue;
		if(i+k<n && t[i+k] == t[i])ok[i+k] = 1;
		if(t[i]=='r')ans += p;
		if(t[i]=='s')ans += r;
		if(t[i]=='p')ans += s;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3780
#include <stdio.h>

long fact(long n);

int main(void)
{
	long n;
	
	scanf("%ld", &n);
	printf("%ld\n", fact(n));
	
	return (0);
}

long fact(long n){
	if (n == 1) return (1);
	return (n * fact(n - 1));		
}

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

int64_t dp[101][100001], v[100001], w[100001];

int64_t recurse(int i, int j) {
  	if(i < 0 or !j) return 0;
	int64_t& state = dp[i][j];
  	if(state != -1) return state;
  	state = numeric_limits<int64_t>::min();
  	if(j >= w[i]) {
    	state = max(state, recurse(i - 1, j - w[i]) + v[i]);
    }
  	state = max(state, recurse(i - 1, j));
    return state;
}

signed main() {
  	int n, m; scanf("%d %d", &n, &m);
  	memset(dp, -1, sizeof dp);
  	for(int i = 0; i < n; ++i) {
    	scanf("%lld %lld", &w[i], &v[i]);
    }
  	printf("%lld", recurse(n - 1, m));
	return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    int n;
    cin>>n;
    n=2*n;
    int a[2*n];

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }

    sort(a,a+n);

    int s=0;

    for(int i=0; i<n; i=i+2)
    {
        s=s+a[i];
    }

    cout<<s<<endl;




    return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
int main(){
    int i,j;
    char a,b;
    cin>>a>>b;
    string s1,s2;
    for(i='0';i<b;i++)s1+=a;
    for(i='0';i<a;i++)s2+=b;
    if(s1>=s2)cout<<s2;
    else cout<<s1;
	return 0;
}

Measured memory_bytes: 256
object Main {
    import scala.annotation.tailrec

    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)

        drawRectangle(sc)
    }

    @tailrec
    def drawRectangle(scanner: java.util.Scanner): Unit = {
        val h, w = scanner.nextInt

        if( h != 0 || w != 0 ) {
            for( i <- 0 until h ) println("#"*w)
            print("\n")
            drawRectangle(scanner)
        }
    }

}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

char ans[1024][1024];

ll N, M;
void rec(int i, int j, int A, int B) {
  if (A == 0 && B == 0) {
    throw 42;
  }

  if (j == M) { j=0; i++; }
  while (i < N && ans[i][j] != '.') {
    j++;
    if (j == M) {
      i++;
      j = 0;
    }
  }
  if (i >= N) return;
  if (A > 0 && j + 1 < M && ans[i][j+1] == '.') {
    ans[i][j] = '<'; ans[i][j+1] = '>';
    rec(i, j+1, A-1, B);
    ans[i][j] = '.'; ans[i][j+1] = '.';
  }
  if (B > 0 && i + 1 < N && ans[i+1][j] == '.') {
    ans[i][j] = '^'; ans[i+1][j] = 'v';
    rec(i, j+1, A, B-1);
    ans[i][j] = '.'; ans[i+1][j] = '.';
  }
  rec(i, j+1, A, B);
}

int main2() {
  N = nextInt();
  M = nextInt();
  ll A = nextInt();
  ll B = nextInt();

  if (N * M < 2 * (A+B) || N * (M/2) < A || (N/2) * M < B) {
    cout << "NO" << endl;
    return 0;
  }

  REP(i, N) REP(j, M) ans[i][j] = '.';
  if (N % 2) {
    for (int j = 0; j + 2 <= M - 3; j += 2) {
      if (A > 0) {
        ans[N-1][j] = '<';
        ans[N-1][j+1] = '>';
        A--;
      }
    }
  }
  if (M % 2) {
    for (int i = 0; i + 2 <= N - 3; i += 2) {
      if (B > 0) {
        ans[i][M-1] = '^';
        ans[i+1][M-1] = 'v';
        B--;
      }
    }
  }
  bool yes = true;
  for (int i = 0; i + 2 <= (N/2*2); i += 2) {
    for (int j = 0; j + 2 <= (M/2*2); j += 2) {
      if (N - i <= 3 && M - j <= 3) continue;
      if (A >= B && A >= 2) {
        A--; ans[i][j] = '<'; ans[i][j+1] = '>';
        A--; ans[i+1][j] = '<'; ans[i+1][j+1] = '>';
      } else if (A <= B && B >= 2) {
        ans[i][j] = '^';
        ans[i+1][j] = 'v';
        B--;
        ans[i][j+1] = '^';
        ans[i+1][j+1] = 'v';
        B--;
      }
    }
  }
  int dot = 0;
  REP(i, N) REP(j, M) if (ans[i][j] == '.') dot++;
  if (dot < 2*(A+B)) {
    yes = false;
  } else {
    try {
      yes = false;
      rec(0, 0, A, B);
    } catch(int e) {
      yes = true;
    }
  }

  if (yes) {
    cout << "YES" << endl;
    REP(i, N) {
      REP(j, M) printf("%c", ans[i][j]);
      printf("\n");
    }
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 2176
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int a, b;
        String result;
        
        while(scan.hasNext()){
            a=scan.nextInt();
            b=scan.nextInt();
            result=String.valueOf(a+b);
            System.out.println(result.length());
        }
    }
}


Measured memory_bytes: 26220
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long

template <class T>
T mymax(T a,T b){
    if(a>=b) return a;
    return b;
}
template <class T>
T mymin(T a,T b){
    if(a<=b) return a;
    return b;
}

ll gcd(ll a, ll b){
    if(a<b){
        swap(a,b);
    }
    while(b){
        ll r = a%b;
        a=b;
        b=r;
    }
    return a;
}

ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

struct XX{
    long long x;
    long long jun;
    long long z;
    long long ix;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.x) == (riRight.x)){
            return riLeft.ix < riRight.ix;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.x) < (riRight.x);
    }
};

//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}


int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //cin >> x >> y;
    //テスト用
    //ifstream ifs( "1_06.txt" );
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    int d[100];
    for(int i=0;i<N;i++){
        cin >> d[i];
    }
    sort(d,d+N);
    int ans=1;
    for(int i=1;i<N;i++){
        if(d[i]!=d[i-1]){
            ans++;
        }
    }
    cout << ans << endl;
    
    //ここまで
    //cout << "debug" << endl;
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}



Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	static llint dp[2002][2002]={0};
	static llint ep[2002][2002]={0};
	llint i,j,n,K;cin>>n>>K;
	dp[0][n+1-K]=1;
	for(i=0;i<n-K-1;i++){dp[0][n+1-K]*=2;dp[0][n+1-K]%=mod;}
	ep[0][n+1-K]=dp[0][n+1-K];
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			dp[i][j]=(dp[i][j-1]+ep[i-1][j])%mod;
			ep[i][j]=(dp[i][j]+ep[i-1][j+1])%mod;
		}
	}
	cout<<dp[n][1]<<endl;
	return 0;
}

Measured memory_bytes: 62848
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

ll x,y,a,b,c;
ll p[100005],q[100005],r[100005];

void solve() {
    cin>>x>>y>>a>>b>>c;
    rep(i,0,a){
    	cin>>p[i];
    }
    rep(i,0,b){
    	cin>>q[i];
    }
    rep(i,0,c){
    	cin>>r[i];
    }
    sort(p,p+a,greater <ll> ());
    sort(r,r+c,greater <ll> ());
    sort(q,q+b,greater <ll> ());
    vi v;
    rep(i,0,x){
    	v.pb(p[i]);
    }
    rep(i,0,y){
    	v.pb(q[i]);
    }
    rep(i,0,c){
    	v.pb(r[i]);
    }
    ll ans=0;
    sort(all(v),greater <ll> ());
    rep(i,0,x+y)ans+=v[i];
    cout<<ans<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

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

#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 long int ll;
const ll oo = 1e18L;

int main() {    

    int n;
    scanf("%d", &n);
    
    vector<int> a(n);
    
    for(int& x : a) {
        scanf("%d", &x);
    }
    
    vector<vector<ll>> dp(n, vector<ll>(n, -oo));
    vector<vector<ll>> mid(n, vector<ll>(n, -1));
    vector<ll> pref(n, 0);
    
    pref[0] = a[0];
    for(int i = 1; i < n; ++i) {
        pref[i] = pref[i-1] + a[i];
    }
    
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j+i < n; ++j) {
            
            if(i == 0) {
                dp[j][j] = 0;
                mid[j][j] = 0;
                continue;
            } else if(i == 1) {
                dp[j][j+1] = pref[j+1]-(j-1 >= 0 ? pref[j-1]:0);
                mid[j][j+1] = j;
                continue;
            }
            
            dp[j][j+i] = oo;
            
            for(int k = mid[j][j+i-1]; k <= mid[j+1][j+i]; ++k) {
                ll val = dp[j][k] + dp[k+1][j+i] + (pref[j+i]-(j-1 >= 0 ? pref[j-1] : 0));
                if(val < dp[j][j+i]) {
                    mid[j][j+i] = k;
                    dp[j][j+i] = val;
                }
            }
        }
    }
    
    debug() << imie(dp);

    printf("%lld\n", dp[0][n-1]);

    return 0;
}


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

int main(){
  int X, A, B;
  cin >> X >> A >> B;

  //
  if(A-B >= 0) cout << "delicious" << endl;
  else if(A-B < 0 && abs(A-B) <= X) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;

  static class Solution {
    void solve() throws IOException {
      int n = in.nextInt();
      for (int i = 1; ++i <= n;) {
        int x = i;
        if (x % 3 == 0) {
          out.print(" "+i);
        } else {
          do {
            if (x % 10 == 3) {
              out.print(" "+i);
              break;
            } else {
              x /= 10;
            }
          } while (x != 0);
        }
      }
      
      
      out.print("\n");
//    End of solve()
    }
}

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

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

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

Measured memory_bytes: 25796
#include <stdio.h>
#define MAX 100000

typedef struct{
  char name[100];
  int time;
} queue;

void enq(queue);
queue deq(void);

int head=0, tail=0;
queue a[MAX];

main(){
  int n, m, i, sum=0;
  queue b;
  
  scanf("%d%d", &n, &m);
  for(i=0; i<n; i++){
	scanf("%s%d",b.name, &b.time);
	enq(b);
  }

  while(1){
	if(head==tail) break;
	if(a[head].time > m){
	  b = deq();
	  b.time -= m;
	  enq(b);
	  sum += m;
	}
	else{
	  b = deq();
	  printf("%s %d\n", b.name, b.time+sum);
	  sum += b.time;
	}
  }
  return 0;
}


void enq(queue p){
  a[tail] = p;
  if(tail+1 == MAX) tail = 0;
  else tail++;
}


queue deq(){
  queue x;
  x = a[head];
  
  if(head+1 == MAX) head = 0;
  else head++;
  return x;
}

Measured memory_bytes: 10756
N,X,Y = map(int, input().split())
ans = [0]*N
X -= 1
Y -= 1

for i in range(N-1):
  for j in range(i+1,N):
    _ = min(j-i, abs(X-i)+1+abs(Y-j))
    ans[_] += 1

for _ in range(1,N):print(ans[_])

Measured memory_bytes: 3444