akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
case = 1
while True:
    N = int(raw_input())
    if N == 0: break
    mat = [[0 for i in xrange(N)] for j in xrange(N)]
    n = 1
    for i in xrange(N): # upper half
        for j in reversed(xrange(i+1)):
            if i%2==0:
                mat[j][i-j] = n
                n += 1
            elif i%2==1:
                mat[i-j][j] = n
                n += 1
                 
    for i in xrange(N,2*N-1): # lower half
        for j in reversed(xrange(i-N+1,N)):
            if i%2==0:
                mat[j][i-j] = n
                n += 1
            elif i%2==1:
                mat[i-j][j] = n
                n += 1
    print 'Case %d:'%(case); case += 1
    for s in mat:
        print ''.join(map(str,[str(st).rjust(3) for st in s]))
    

Measured memory_bytes: 4268
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int d[60];

int main() {
	int N;
	cin >> N;
	int sum=0, subs=0;
	for(int i=0; i<N; ++i){
	    cin >> d[i];
	    sum += d[i];
	    subs += d[i]*d[i];
	}
	cout << (sum*sum-subs)/2 << endl;
	return 0;
}


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

int main() {
  int T;
  cin >> T;
  while(T--) {
    int n;
    cin >> n;
    int a[n],x=0,y=0;
    for(int i=0; i<n; i++) {
      cin >> a[i];
      if(!i) continue; 
      x=max(x,a[i]-a[i-1]);
      y=max(y,a[i-1]-a[i]);
    }
    cout << x << " " << y << endl;
  }
  return 0;
}


Measured memory_bytes: 1160
import sys
from bisect import bisect
def input():
	return sys.stdin.readline()[:-1]

x = int(input())
k = int(input())
z = [0] + list(map(int, input().split()))
s = [z[i+1] - z[i] for i in range(k)]

lr = [[0, x]]
pq = [[0, x]]

for i in range(k):
	l, r = lr[-1]
	p, q = pq[-1]
	if i%2 == 0:
		lr.append([max(l-s[i], 0), max(r-s[i], 0)])
		pq.append([min(p + max(min(s[i], x)-l, 0), q), q])
	else:
		lr.append([min(l+s[i], x), min(r+s[i], x)])
		pq.append([p, max(q - max(r-max(x-s[i], 0), 0), p)])

q = int(input())
for _ in range(q):
	t, a = map(int, input().split())
	i = bisect(z, t) - 1
	t -= z[i]
	if a <= pq[i][0]:
		y = lr[i][0]
	elif a >= pq[i][1]:
		y = lr[i][1]
	else:
		y = lr[i][0] + a - pq[i][0]

	if i%2 == 0:
		print(max(y-t, 0))
	else:
		print(min(y+t, x))

Measured memory_bytes: 43376
import numpy as np
n = 10
bit_base = 2#bit_base^nの全探査になる. 
def Base_10_to_n(X, n):#10進数をbit_base進数に変換
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
  
def main():
  N = int(input())
  F = []
  for i in range(N):
    F.append(list(map(int, input().split())))
  F = np.array(F)
  P = []
  for i in range(N):
    P.append(list(map(int, input().split())))
  ans = -1*10**9
  for i in range(bit_base**n):
    if i == 0: continue
    s = Base_10_to_n(i, bit_base)
    s = s.zfill(n)
    for num, j in enumerate(s):
      ans_temp = 0
      s = list(s)
      s = np.array([int(i) for i in s])
      C = np.sum(F*s, axis = 1)
      for k,c in enumerate(C):
        ans_temp += (P[k][c])
      ans = max(ans, ans_temp)
  print(ans)
if __name__ == "__main__":
  main()

Measured memory_bytes: 14468
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define oo 1e8
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e6 + 5, M = 2 * N + 5;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
ll inf = 1e18;

ll n, m;
ll a[1010];

int main(){
	while(cin >> n >> m && n > 0 && m > 0){
		ll ans = 0;
		REP(i,0,n){
			cin >> a[i];
		}
		REP(i,0,n){
			REP(j,i+1,n){
				if(a[i] + a[j] <= m){
					ans = max(ans, a[i] + a[j]);
				}
			}
		}
		if(ans > 0) p(ans);
		else p("NONE");
	}

	return 0;
}


Measured memory_bytes: 3084
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

ll a,b,c;

int main(){
	cin.sync_with_stdio(false);
	cin>>a>>b>>c;
	if(a*b*c&1){
		ll h=max(a,max(b,c));
		if(a==h)cout<<b*c<<endl;
		else if(b==h)cout<<a*c<<endl;
		else cout<<a*b<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}





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

int c,n,xo[1000][1000] = {},yo[1000][1000] = {},ans = 0,cnt = 0,cnty = 0;
string field[1000];

int main(){
	cin >> c >> n;
	for(int i = 0;i < n;i++){
		cin >> field[i];
		for(int j = 0;j < n;j++){
			if(field[i][j] == '1'){
				int pos = j;
				if(pos >= n / 2) pos = n - 1 - pos;
				xo[i][pos] ^= 1;
				pos = i;
				if(pos >= n / 2) pos = n - 1 - pos;
				yo[pos][j] ^= 1;
			}
		}
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n / 2;j++) cnt += xo[i][j];
	}
	for(int i = 0;i < n / 2;i++){
		for(int j = 0;j < n;j++) cnty += yo[i][j];
	}
	if(!cnt && !cnty) ans++;
	for(int i = 0;i < c - 1;i++){
		int d;
		cin >> d;
		for(int j = 0;j < d;j++){
			int r,C,x,y;
			cin >> r >> C; r--;C--;
			y = C;
			if(y >= n / 2) y = n - 1 - y;
			if(xo[r][y]){
				xo[r][y] = 0;
				cnt--;
			}else{
				xo[r][y] = 1;
				cnt++;
			}
			x = r;
			if(x >= n / 2) x = n - 1 - x;
			if(yo[x][C]){
				yo[x][C] = 0;
				cnty--;
			}else{
				yo[x][C] = 1;
				cnty++;
			}
		}
		if(!cnt && !cnty) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int k,s,a=0,b=0,c=0,ans=0;
    cin >> k >> s;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            a=i;
            b=j;
            c=s-a-b;
            if(c<=k&&c>=0)ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    string N;
    cin >> N;
    
    string ans = "No";
    rep(i, 3){
        if(N.at(i) == '7'){
            ans = "Yes";
        }
    }

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

Measured memory_bytes: 3628
#include <stdio.h>
int main(){
    int ans = 0;
    int A, B;
    int X;
    scanf("%d %d", &A, &B);
    for(X = A; X <= B; X++){
        int x[5];
        x[0] = X%10;
        x[1] = (X%100)/10;
        x[2] = (X%1000)/100;
        x[3] = (X%10000)/1000;
        x[4] = (X%100000)/10000;
        if(x[0] == x[4] && x[1] == x[3]){
            ans++;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int n, m;

int main()
{
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;     
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int INF = 1001001009;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int n = str.length();
        
        // dp[i][j] = 下からi桁目までで使うお札の枚数
        // j: 繰り上がり中か否か
        int[][] dp = new int[n + 1][2];
        dp[n][1] = INF;
        for (int i = n; i > 0; i--) {
            char c = str.charAt(i - 1);
            int num = c - '0';
            
            // (3←3) -> 3 ([0]→[0]の遷移)
            // (3←7) -> 3 ([1]→[0]の遷移)
            // (7←3) -> 11 - 7 ([0]→[1]の遷移)
            // (7←7) -> 9 - 7 ([1]→[1]の遷移)
            dp[i - 1][0] = Math.min(dp[i][0], dp[i][1]) + num;
            dp[i - 1][1] = Math.min(dp[i][0] + 11 - num, dp[i][1] + 9 - num);
        }
        
        System.out.println(Math.min(dp[0][0], dp[0][1]));
    }
}

Measured memory_bytes: 74764
import math

N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

A.sort()

if N % 2 == 0:
    for i in range(N):
        if A[i] != 2 * (i // 2) + 1:
            print(0)
            exit()
else:
    for i in range(N):
        if A[i] != 2 * math.ceil(i / 2):
            print(0)
            exit()

print(2 ** (N // 2) % MOD)


Measured memory_bytes: 20236
#include <iostream>

using namespace std;

int main()
{
	int x, y;
	cin >> x >> y;
	bool b = false;
	for (int i = 0; i <= x; i++)
	{
		if (i * 2 + (x - i) * 4 == y)
		{
			b = true;
			break;
		}
	}
	if (b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  if(N < 105)
    cout << 0 << endl;
  else if(N < 135)
    cout << 1 << endl;
  else if(N < 165)
    cout << 2 << endl;
  else if(N < 189)
    cout << 3 << endl;
  else if(N < 195)
    cout << 4 << endl;
  else
    cout << 5 << endl;
  return 0;
}

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

const int N = (1e5) + 5;
char s[N];
int ac[N];

int main() { // claudio van
  int n, q;
  scanf("%d %d", &n, &q);
  scanf("%s", s);
  for (int i = 1; i < n; ++i) {
    if (s[i - 1] == 'A' and s[i] == 'C') {
      ac[i] = (i == 0? 0 : ac[i - 1]) + 1;
    } else {
      ac[i] = (i == 0? 0 : ac[i - 1]) + 0;
    }
  }
  for (int i = 0; i < q; ++i) {
    int l, r; scanf("%d %d", &l, &r);
    --l; --r;
    int ans = ac[r] - (l == 0? 0 : ac[l - 1]);
    if (l != 0 and s[l - 1] == 'A' and s[l] == 'C') {
      ans--;
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>

int main(void){
	int A1,A2,A3;
	std::cin >> A1 >> A2 >> A3;
	
	int x=std::abs(A1-A2);
	int y=std::abs(A1-A3);
	int z=std::abs(A2-A3);
	
	std::cout << std::min(x+y,std::min(x+z,y+z)) << '\n';
	
	return 0;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;


int main(){
	int n,z,w; cin >> n >> z>> w;
	
	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >>a[i];
    }
    if(n>1){
    int ans =max(abs(a[n-1]-w), abs(a[n-2]- a[n-1]));
    cout << ans << endl;
    }
    else{
    	cout << abs(a[0]-w) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	if(b%a==0){
		puta(a+b);
	}else puta(b-a);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define ub upper_bound 
#define lb lower_bound 
#define pb push_back
#define s second 
#define f first 
#define ma 1000000007	
#define fr(n) for(i=0;i<n;i++)
struct well {
	ll aa,bb,cc,dd;
};

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	ll i,j,k=0,x=0,y=0,z=0,c=0,mini=0,ans=LLONG_MIN,last,sum=0;
	ll n,a,m=0,b,f,c0,d0;
	cin>>n>>a>>b;
	cout<<(a^b^n);
	
	
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		new Main().run();
	}

	private void run() throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		int n = Integer.parseInt(reader.readLine());
		Node[] T = new Node[n];

		for (int i = 0; i < n; i++) {
			T[i] = new Node();
		}
		int l = 0;
		for (int i = 0; i < n; i++) {
			StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
			int v = Integer.parseInt(tokenizer.nextToken());
			T[v].id = v;
			int d = Integer.parseInt(tokenizer.nextToken());
			for (int j = 0; j < d; j++) {
				int c = Integer.parseInt(tokenizer.nextToken());
				if (j == 0) {
					T[v].l = c;
				} else {
					T[l].r = c;
				}
				l = c;
				T[c].p = v;
			}
		}
		int r = -1;
		for (int i = 0; i < n; i++) {
			if (T[i].p == -1) {
				r = i;
				break;
			}
		}
		int[] D = new int[n];
		rec(r, 0, D, T);
		StringBuilder builder = new StringBuilder();
		for (int i = 0; i < n; i++) {
			print(i, T, D, builder);
		}
		System.out.print(builder);
	}

	private void print(int u, Node[] T, int[] D, StringBuilder builder) {
		builder.append("node ").append(u).append(": parent = ").append(T[u].p)
				.append(", depth = ").append(D[u]).append(", ");
		if (T[u].p == -1)
			builder.append("root, ");
		else if (T[u].l == -1)
			builder.append("leaf, ");
		else
			builder.append("internal node, ");
		builder.append("[");
		boolean flag = false;
		int c = T[u].l;
		while (c != -1) {
			if (flag)
				builder.append(", ");
			builder.append(c);
			c = T[c].r;
			flag = true;
		}
		builder.append("]\n");
	}

	private void rec(int u, int p, int[] D, Node[] T) {
		Deque<Integer> deque = new ArrayDeque<Integer>();
		deque.offer(u);
		while (!deque.isEmpty()) {
			int t = deque.size();
			for (int i = 0; i < t; i++) {
				int c = deque.poll();
				D[c] = p;
				if (T[c].l != -1) {
					c = T[c].l;
					while (c != -1) {
						deque.offer(c);
						c = T[c].r;
					}
				}
			}
			p++;
		}
	}

	class Node {
		int id = -1;
		int p = -1;
		int l = -1;
		int r = -1;
	}
}

Measured memory_bytes: 87596
#include <bits/stdc++.h>
using namespace std;
// type
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r, x)     for (int i = l; i < r; i+=x)
//#define ForE(i, l, r, x)    for (int i = l; i <= r; i+=x)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O 
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define PrintV(a)           Fora(ii, a) cout << ii << ' '; cout << rl;
//#define PrintVl(a)          Fora(ii, a) cout << ii << rl;
//#define PrintA(a, l, r)     for (int ii = l; ii <= r; ii++) cout << a[ii] << ' '; cout << rl;
//#define PrintAl(a, l, r)    for (int ii = l; ii <= r; ii++) cout << a[ii] << rl;
//#define Ptest(x)            return cout << x, 0;
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calc    
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod = 1e9+7;
const int MAXN = 100005, MAX_M = 200010;
// code
//#define int long long
const int X = (1 << 22);
bitset<X> dp;
void Solve() {
    int n, s = 0; cin >> n; dp[0] = 1;
    for (int i = 1, x; i <= n; i++){
      	cin >> x; s += x; dp = dp | (dp << x);
    }
    //cout << s << endl;
  	for (int ans = (s+1)/2; ans <= s; ans ++)
      	if (dp[ans]) {cout << ans; break;}
}

signed main(){
    FAST_IO;
    int TC = 1; 
	//cin >> TC;
    while(TC--) Solve();
    return 0;
}


Measured memory_bytes: 5148
def countAB(s):
    c = 0
    for i in range(0, len(s), 2):
        if i+1 < len(s) and s[i] == 'A' and s[i+1] == 'B':
            c += 1
        elif i-1 >= 0 and s[i-1] == 'A' and s[i] == 'B':
            c += 1
    return c


n = int(input())
s = [input() for _ in range(n)]

head = []
tail = []
con = []
els = []

for i in range(n):
    h = s[i][0]
    t = s[i][-1]
    if h == 'B' and t == 'A':
        con.append(s[i])
    elif h == 'B':
        tail.append(s[i])
    elif t == 'A':
        head.append(s[i])
    else:
        els.append(s[i])

string = ''.join(els)
state = False
while True:
    if not state:
        if len(head) > 0:
            string += head.pop(0)
        elif len(con) > 0:
            string += con.pop(0)
        else: break
        state = True
    elif state:
        if len(con) > 0:
            string += con.pop(0)
        elif len(tail) > 0:
            string += tail.pop(0)
            state = False
        else: break

string = string + ''.join(head+tail+con)

print(countAB(string))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int a,b,c,x,y,p[100005],q[100005],r[300005];
ll ans=0;
int main()
{
	cin>>x>>y>>a>>b>>c;
	rep(i,a) cin>>p[i];sort(p,p+a,greater<int>());
	rep(i,b) cin>>q[i];sort(q,q+b,greater<int>());
	rep(i,c) cin>>r[i];
	rep(i,x) r[i+c]=p[i];
	rep(i,y) r[i+c+x]=q[i];
	sort(r,r+c+x+y,greater<int>());
	rep(i,x+y) ans+=(ll)(r[i]);
	cout<<ans<<endl; 
	return 0;}

Measured memory_bytes: 2176
import math

A, B, H, M = map(int, input().split())
hours = (H * 60 + M) / 60
h_unit = 2 * math.pi / 12
m_unit = 2 * math.pi / 60
a_x = A * math.cos(hours * h_unit)
a_y = A * math.sin(hours * h_unit)
b_x = B * math.cos(M * m_unit)
b_y = B * math.sin(M * m_unit)

print(math.sqrt(math.pow(a_x - b_x, 2) + math.pow(a_y - b_y, 2)))


Measured memory_bytes: 9512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
typedef long double f80;
#define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

multiset<int> s;
const int N = 2e5 + 5;
int a[N];
void solve(){
    int n;
    cin >> n;
    fr(i, 1, n){
        cin >> a[i];
        s.insert(a[i]);
    }
    sort(a + 1, a + n + 1);
    int ans = 0;
    for(int i = n; i >= 1; i--){
        if(s.find(a[i]) == s.end()) continue;
        s.erase(s.find(a[i]));
        ll val = 1;
        while(val <= a[i]) val <<= 1;
        if(s.find(val - a[i]) != s.end())
            ans++, s.erase(s.find(val - a[i]));
    }
    cout << ans << endl;
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        // freopen("out.txt", "w", stdout);
    #endif
    clock_t clk = clock();
    int t = 1;
    // cin >> t;
    fr(i, 1, t)
        solve();
    cerr << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}

Measured memory_bytes: 11264
N, M = map(int,input().split())
like = [0 for i in range(M)]

#人数分の入力
for i in range(N):
    #入力
    I = input().split()
    #好きな食べ物をlikeに加算
    K = int(I[0])
    for j in range(K):
        index = int(I[j+1])
        like[index - 1] += 1
    
#全員が好きと答えた食べ物の種類をカウント
C = like.count(N)

print(C)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
 
using namespace std;
 
typedef pair<int,int>P;
typedef pair<int,ll>pl;
 
const int MAX_N = 40;
 
ll a[MAX_N];
vector<pl> x,y;
 
void solve(int s,int t,vector<pl> &x)
{
    int z = t-s;
    rep(i,1<<z){
        pl p = pl(0,0);
        rep(j,z){
            if(i&(1<<j)){
                p.first++;
                p.second += a[s+j];
            }
        }
        x.push_back(p);
    }
}
 
int main()
{
    int n,k;
    ll l,r;
    cin >> n >> k >> l >> r;
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    solve(0,n/2,x);
    solve(n/2,n,y);
    sort(y.begin(),y.end());
    ll ans = 0;
    rep(i,x.size()){
        ans += upper_bound(y.begin(),y.end(),pl(k-x[i].first,r-x[i].second))-lower_bound(y.begin(),y.end(),pl(k-x[i].first,l-x[i].second));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 43812
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,i;
    cin>>n;
    stack<string> stk;
    string s;
    for(i=0;i<n;i++){
        cin>>s;
        if(s=="A"){
            stk.push(s);
        }else if(s=="Un"&&!stk.empty()){
            stk.pop();
        }else{
            cout<<"NO\n";
            return 0;
        }
    }
    cout<<((stk.empty())?"YES\n":"NO\n");
    return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define ll long long
#define P pair<ll, char>
using namespace std;

int main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    priority_queue<P> que;

    for(int i=0;i<a;i++){
        ll p;
        cin >> p;
        que.push(P(p, 'a'));
    }
    for(int i=0;i<b;i++){
        ll q;
        cin >> q;
        que.push(P(q, 'b'));
    }
    for(int i=0;i<c;i++){
        ll r;
        cin >> r;
        que.push(P(r, 'c'));
    }

    ll ans = 0, sum_a = 0, sum_b = 0, sum = 0;
    while(!que.empty()){
        P p = que.top();
        que.pop();
        if(p.second == 'a' && sum_a < x && sum < x+y){
            ans += p.first;
            sum_a++;
            sum++;
        }else if(p.second == 'b' && sum_b < y && sum < x+y){
            ans += p.first;
            sum_b++;
            sum++;
        }else if(p.second == 'c' && sum < x+y){
            ans += p.first;
            sum++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 11656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
  int N;
  N=10;
  string input;
  cin >> input;

  int a[N],b[N];
  for(int i=0;i<N;++i){
    b[i] = (char)(input[i]);
    a[i] = (int)(input[i]-'0');
  }

  bool flug;

  int year = (int)(a[0]*1000+a[1]*100+a[2]*10+a[3]);
  int month = (int)(a[5]*10+a[6]);

//   cout << a[0] << endl;
//   cout << month << endl;

  if(year<=2018) flug = true;
  else if (year>=2020) flug = false;
  else{
    if(month<=4) flug = true;
    else flug = false;
  }

  if(flug == true) cout << "Heisei" << endl;
  else cout << "TBD" << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a[10010];
bool c, f;
int main()
{
    scanf("%s", a);
    for(int i=0; i<strlen(a); i++) 
    {
        if(a[i]=='C') c=true; 
        if(a[i]=='F'&&c==true) f=true;
    }
    if(f) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;


signed main()
{
	char str[256];
	cin >> str;
	str[3] = '8';
	cout << str << endl;
}



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


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

    sort(v.begin(),v.end(), greater<>());
    cout<< v[0]*10+v[1]+v[2]<<endl;
    return 0;
}


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

int main(){
    int n, m; cin >> n >> m;
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    vector<int> x(m), d(m-1);
    for(int i = 0; i < m; i++) cin >> x[i];
    sort(x.begin(), x.end());
    int ans = x[m-1] -x[0];
    for(int i = 0; i < m-1; i++) d[i] = x[i] - x[i+1];
    sort(d.begin(), d.end());
    for(int i = 0; i < n-1; i++){
        ans += d[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
if __name__ == "__main__":
    n = int(input())
    arr = list(map(int,input().split(" ")))
    dp = [-1]*len(arr)
    curr = 1
    dp[0] = 0
    dp[1] = abs(arr[1]-arr[0])
    cost = 0
    for i in range(2,len(arr)):
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]))
    print(dp[-1]) 
            
       
            



Measured memory_bytes: 13980
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);


      int N = sc.nextInt();
      int data[] = new int[N];
      int sum = 0;

      for(int i = 0;i<N;i++){
        data[i]=  sc.nextInt();
      }


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

      System.out.println(sum);
                   }
      }


Measured memory_bytes: 21204
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if( a < b )	System.out.println("a < b");
		else if( a > b ) System.out.println("a > b");
		else if( a==b ) System.out.println("a == b");
		
	}

}

Measured memory_bytes: 26056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		long X=sc.nextLong();
		long Y=sc.nextLong();
		long GCD=gcd(X,Y);
		if(GCD==Y) {
			pl(-1);
		}
		else {
			pl(X);
		}
	}
	private static long gcd(long m, long n) {
		if(m < n) return gcd(n, m);
		if(n == 0) return m;
			return gcd(n, m % n);
		}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 21332
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;

void treeDelete(Node z){
  Node x;
  Node y;
  if( z->left == NIL || z->right == NIL ) y = z;
  else y = getSuccessor(z);
  if( y->left != NIL ) x = y->left;
  else x = y->right;
  if( x != NIL ) x->parent = y->parent;
  if( y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  if( y != z ) z->key = y->key;
  free(y);
}

Node getMinimum(Node x){
  while( x->left != NIL ) x = x->left;
  return x;
}

getSuccessor(Node x){
  if( x->right != NIL ) return getMinimum( x->right );
  Node y = x->parent;
  while ( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;
}

Node treeSearch( Node u, int k ){
  while( u != NIL && k != u->key ){
    if( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;
  
  z=(Node)malloc(sizeof(struct node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
   y = x;
    if( z->key < x->key ) x = x->left;
    else x = x->right;
  }
    z->parent = y;
    if(y == NIL) root = z;
  else {
    if( z->key < y->key ){
      y->left = z;
    }
    else y->right = z;
  }
}

void inorder( Node u ){
if(u == NIL) return;
inorder( u->left );
printf( " %d",u->key );
inorder( u->right );
}
void preorder(Node u){
if(u == NIL) return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}

int main (){
    int n,i,x;
    char com[20];
    scanf( "%d", &n );
    root = NIL;
    for(i=0;i<n;i++){
        scanf( "%s", com );
        if( com[0] == 'i' ){
        scanf( "%d", &x );
        insert(x);
        }
        else if(com[0] == 'p'){
        inorder(root);
        printf("\n");
        preorder(root);
        printf("\n");
        }
        else if( com[0] == 'f'){
        scanf( "%d", &x);
        Node t = treeSearch(root,x);
        if( t != NIL )printf("yes\n");
        else printf("no\n");
        }
        else if(com[0] == 'd'){
        scanf( "%d", &x);
        treeDelete(treeSearch(root,x));
        }
    }
    return 0;
    }


Measured memory_bytes: 20456
#include <bits/stdc++.h>
using namespace std;
using pp = pair<int, int>;
const vector<int> dx = {0, 0, -1, 1};
const vector<int> dy = {1, -1, 0, 0};

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  for(int i = 0; i < n; i++) cin >> x.at(i);
  
  auto c = x;
  sort(x.begin(), x.end());
  
  for(int i = 0; i < n; i++){
    if(c.at(i) < x.at(n/2)) cout << x.at(n/2) << endl;
    else cout << x.at(n/2 - 1) << endl;
  }
}

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

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

	ll n, pa, pb, pc, a, b, c;
	cin >> n >> pa >> pb >> pc;	
	for(int i=1; i<n; i++)	{
		cin >> a >> b >> c;
		a+= max(pb, pc);
		b+= max(pa, pc);
		c+= max(pa, pb);
		pa = a; pb = b; pc = c;
	}
	//cout << max(a, max(b, c)) << endl;
	cout << max(pa, max(pb, pc));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
    while(true){
        int M, T, P, R;
        cin >> M >> T >> P >> R;
 
        if(M==0 && T==0 && P==0 && R==0)
            break;
 
        int CP[50], TT[50], PT[50][10];
        for(int i=0; i<T; i++){
            CP[i] = TT[i] = 0;
            for(int j=0; j<P; j++)
                PT[i][j] = 0;
        }
 
        for(int i=0; i<R; i++){
            int m, t, p, j;
            cin >> m >> t >> p >> j;
 
            if(j==0){
                CP[t-1]++;
                TT[t-1] += (m+PT[t-1][p-1]);
            }
            else{
                PT[t-1][p-1] += 20;
            }
        }
 
        int tnow, tpre = -1;
        bool flg[50];
        for(int i=0; i<T; i++)
            flg[i] = false;
 
        for(int i=0; i<T; i++){
            tnow = -1;
            for(int j=0; j<T; j++){
                if(flg[j])
                    continue;
 
                if(tnow==-1){
                    tnow = j;
                }
                else{
                    if(CP[j]>CP[tnow] || (CP[j]==CP[tnow] && TT[j]<=TT[tnow])){
                        tnow = j;
                    }
                }
            }
 
            if(tpre!=-1){
                if(CP[tnow]==CP[tpre] && TT[tnow]==TT[tpre])
                    cout << '=';
                else
                    cout << ',';
            }
            cout << tnow+1;
 
            flg[tnow] = true;
            tpre = tnow;
        }
        cout << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

char C[] = {'I', 'O', 'T', 'J', 'L', 'S', 'Z'};

LL func1(map<char, LL> mp) {
    LL ans = mp['O'];


    LL buf = mp['I'] / 2;
    ans += (buf) * 2;
    buf = mp['L'] / 2;
    ans += (buf) * 2;
    buf = mp['J'] / 2;
    ans += (buf) * 2;



    return ans;
}
LL func2(map<char, LL> mp) {
    LL ans = mp['O'];

    if (mp['I'] > 0 && mp['L'] > 0 && mp['J'] > 0) {
        mp['I'] --;
        mp['J'] --;
        mp['L'] --;
        ans += 3;
    }
    LL buf = mp['I'] / 2;
    ans += (buf) * 2;
    buf = mp['L'] / 2;
    ans += (buf) * 2;
    buf = mp['J'] / 2;
    ans += (buf) * 2;



    return ans;
}

int main(void) {
    map<char, LL> mp;
    REP(i, 7) {
        LL buf;
        scanf("%lld", &buf);
        mp[C[i]] = buf;
    }

    cout << max(func1(mp), func2(mp))<< endl;
}


Measured memory_bytes: 384
if __name__ == "__main__":
    ct = 0
    while True:
        nums = map( int, raw_input().split())
        H = nums[0]
        W = nums[1]
        if H == 0:
            if W == 0:
                break

        s = ""
        j = 0
        while j < W:
            s += "#"
            j += 1

        i = 0
        while i < H:
            print s
            i += 1
        print

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

int main()
{
	int64_t x,k,d;
	cin >> x >> k >> d;

	x=abs(x);
	int64_t firstmoves=x/d;
	if (k<=firstmoves)
	{
		x-=k*d;
		cout << x << endl;
		return 0;
	}

	x-=firstmoves*d;
	k-=firstmoves;

	int64_t aftermove=d-x;
	if (aftermove<x)
	{
		x=aftermove;
		--k;
	}

	if ((k&1)==0)
	{
		cout << x << endl;
	}
	else
	{
		cout << d-x << endl;
	}
	return 0;
}







Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>

int a[3005];
int main()
{
    int n;
    long long sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++) sum+=a[i]-1;
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std::literals;
using namespace std;

namespace xmaho
{
inline namespace input
{
template<typename T>
T get_value(std::istream& is = std::cin);
template<typename C>
C get_container(std::istream& is = std::cin, typename C::size_type length = std::numeric_limits<typename C::size_type>::max());
}
}
using namespace xmaho;

int main()
{
  std::string s;
  std::cin >> s;
  std::cout << (std::next(s.begin()) != std::unique(s.begin(), s.end())) << '\n';
  return 0;
}

class initalization
{
  class custom_numpunct: public std::numpunct<char>
  {
  public:
    using numpunct::numpunct;
  protected:
    std::string do_truename() const override { return "Yes"; }
    std::string do_falsename() const override { return "No"; }
  };

public:
  initalization()
  {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.imbue(std::locale(std::cout.getloc(), new custom_numpunct{}));
    std::cout << std::boolalpha << std::fixed << std::setprecision(15);
  }
} initalize;

template<typename T>
T xmaho::input::get_value(std::istream& is)
{ T v {}; is >> v; return v; }

template<typename C>
C xmaho::input::get_container(std::istream& is, typename C::size_type length)
{
  C v {};
  if (length != std::numeric_limits<typename C::size_type>::max())
    v.reserve(length);
  typename C::value_type e {};
  for (auto i {length}; i != 0 && is >> e; --i)
    v.push_back(std::move_if_noexcept(e));
  return v;
}


Measured memory_bytes: 256
#include <stdio.h>

#define NUM 1000

int main(void)
{
	int h[NUM];
	int w[NUM];
	int i, j;
	int s;

	i = 0;
	s = 0;

	while (1){
		scanf("%d %d", &h[i], &w[i]);
		if (h[i] == 0 && w[i] == 0)break;
		i++;
	}

	while (h[s] != 0 && w[s] != 0){
		for (i = 0; i < h[s]; i++){	//???
			for (j = 0; j < w[s]; j++){	//?¨?
				if ((i % 2 == 0 && j % 2 ==0) || //i?????¶??°???j?????¶??°????????????i??¨j????\???°??????#?????????
					(i % 2==1 && j % 2 ==1)){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		s++;
		printf("\n");
	}

	
	return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int a, b, x;
    cin >> a >> b >> x;
    if (x >= a && x <= a + b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int cr=p[0];
    int ans=0;
    rep(i,n){
        if(p[i]<=cr){
             ans++;
             cr=p[i];
        }
    }
    cout << ans << endl;
return 0;
}


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

int main()
{
  int N,M ;
  cin>>N>>M ;
  int a[M],b[M] ;
  for(int i=0;i<M;i++) cin>>a[i]>>b[i] ;
  
  int count=0 ;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++) if(i+1==a[j]||i+1==b[j]) count++ ;
    cout<<count<<endl ;
    count=0 ;
  }
 
  return 0 ;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS

main = do
    ni <- BS.getLine 
    let n = read $ BS.unpack ni :: Int
    cal <- map (read . BS.unpack) . BS.words <$> BS.getLine :: IO [Int]
    putStrLn $ show $ multi cal

multi :: [Int] -> Int
multi (x:[]) = 0
multi (x:xs) = rest + (multi xs)
    where rest = sum $ map (*x) xs

Measured memory_bytes: 764
from itertools import product
n = int(input())
m = len(str(n))
ans = 0
for i in range(3,m+1):
    l = list(product('753',repeat=i))
    for _ in l:
        x = ''.join(list(_))
        if '7' in x and '5' in x and '3' in x:
            if n >= int(x):
                ans += 1
print(ans)

Measured memory_bytes: 12116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <complex>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){
    if(a % b == 0) return b;
    else return gcd(b, a % b);
}

int main(){
    ll a, b;
    cin >> a >> b;
    if(a < b) swap(a, b);
    cout << a * b / gcd(a, b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int r, D, x_2000, x_output;
    cin >> r >> D >> x_2000;

    int x_temp = x_2000;
    for(int i=0; i<10; ++i){
        x_output = r*(x_temp) - D;
        x_temp = x_output;
        cout << x_output << endl;
    }

    return 0;
}

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

int main()
{
  int N;
  int A[1010];
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> A[i];
  
  bool approved = true;
  for(int i = 0; i < N; ++i)
  {
    if(A[i]%2 == 0)
    {
      if(A[i]%3 != 0 && A[i]%5 != 0)
      {
        approved = false;
        break;
      }
    }
  }
  
  if(approved) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 3572
n, k = map(int, input().split())
l = [0] * n
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for i in a:
        l[i - 1] = 1
cnt = 0
for i in l:
    if i == 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
int main(){
    ll a,b;
    cin >> a >> b;
    if(abs(a-b)>1){cout << 0 << endl;return 0;}
    ll c=max(a,b),d=min(a,b);
    ll ans=1;
    if(c==d){
        ans=(fac(c)*fac(c))%1000000007;
        ans=(ans*2)%1000000007;
    }
    else{
        ans=(fac(c)*fac(d))%1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

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

long long get_lcm(long long a, long long b) {
    long long g = get_gcd(a, b);
    return a / g * b;
}

int main (void)
{
    int n, m;
    char s[(int)1e5 + 1], t[(int)1e5 + 1];

    long long gcd, lcm, i;

    scanf("%d %d", &n, &m);
    scanf("%s", s);
    scanf("%s", t);

    gcd = get_gcd(n, m);
    lcm = get_lcm(n, m);

    for (i = 0; i < gcd; i++) {
        if (s[lcm / m * i] != t[lcm / n * i]) break;
    }

    if (i >= gcd) printf("%lld\n", lcm);
    else puts("-1");

    return 0;
}


Measured memory_bytes: 384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQUE(c)   sort(ALL((c)));(c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	cout << (a + b + c) - max({ a,b,c }) + max({ a,b,c })*pow(2, k) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <map>
using namespace std;
int main() {
    int n;
    cin >> n;
    int cnt = n;
    map<string, bool> m;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        if (m.count(s)) {
            cnt--;
        } else {
            m.insert(make_pair(s, true));
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 19256