akhauriyash/Code-Regression huggingface dataset:
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));


int const maxn = 2005;

vector<int> gr[maxn];
pair<int64_t,int64_t> sum[maxn];
int cnt[maxn];
string s;

const int64_t INF = 1000000000000000000LL;

int64_t ans = 0;
void dfs(const int v, const int p = -1) {
    vector<pair<int64_t, int64_t>> curt;
    for (const int ne : gr[v])
    if (ne != p) {
        dfs(ne, v);
        curt.emplace_back(sum[ne].first + cnt[ne], sum[ne].second + cnt[ne]);
        cnt[v] += cnt[ne];
    }
    sort(rbegin(curt), rend(curt));
    int64_t maxsum = 0;
    for (size_t i = 1; i < curt.size(); ++i)
        maxsum += curt[i].second;
    if (!curt.empty()) {
        if (curt[0].first > maxsum)
            sum[v] = {curt[0].first - maxsum, maxsum + curt[0].second};
        else {
            if ((curt[0].first % 2) == (maxsum % 2))
                sum[v] = {0, maxsum + curt[0].second};
            else
                sum[v] = {1LL, maxsum + curt[0].second};
        }
    }
    if (s[v] == '1')
        ++cnt[v];
}

int64_t solve(const int v) {
    fill(begin(sum), end(sum), make_pair(0,0));
    fill(begin(cnt), end(cnt), 0);
    ans = 0;
    dfs(v);
    if (sum[v].first == 0)
        return sum[v].second / 2;
    return INF;
}

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cin.tie(0);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    int n;
    cin >> n;
    cin >> s;

    for (int i = 1; i < n; ++i) {
        int a,b;
        cin >> a >> b;
        --a, --b;
        gr[a].push_back(b);
        gr[b].push_back(a);
    }

    int64_t result = INF;

    for (int i = 0; i < n; ++i)
        result = min(result, solve(i));

    if (result == INF)
        result = -1;

    cout << result << endl;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;

const string YES = "Yes";
const string NO = "No";

void solve()
{
  string s;
  cin >> s;
  string t;
  cin >> t;
  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  if (s<t) cout << YES << endl;
  else cout << NO << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, B;
    cin >> N >> B;
    lint powb = 1, ret = 0;
    while (powb <= N) {
        ret++;
        powb *= B;
    }
    cout << ret << endl;
    return 0;
};

Measured memory_bytes: 3656
#include <iostream>
#include <math.h>
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

int r,c,a[100][100],sum;

int main() {
  
   cin>>r>>c;
   
   for(int j=0; j<r; j++){
     
     int ans=0;
   
   for(int i=0; i<c; i++){
       
       cin>>a[i][j];
       
       cout<<a[i][j]<<' ';
       
       ans+=a[i][j];
       
     }
     
     cout<<ans<<endl;
     
     }
     
   for(int i=0; i<c; i++){
     
     int ans=0;
   
   for(int j=0; j<r; j++){
       
       ans+=a[i][j];
       
     }
     
     sum+=ans;
     
     cout<<ans<<' ';
     
     }
     
     cout<<sum<<endl;
    
}

Measured memory_bytes: 1200
import java.util.*;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int inN = stdin.nextInt();
		int[] inC = new int[inN - 1];
		int[] inS = new int[inN - 1];
		int[] inF = new int[inN - 1];

		for (int i = 0; i < (inN - 1); i++) {
			inC[i] = stdin.nextInt();
			inS[i] = stdin.nextInt();
			inF[i] = stdin.nextInt();
		}

		for (int i = 0; i < inN; i++) {
			int time = 0;
			for (int station = i; station < (inN - 1); station++) {
				if (time <= inS[station]) {
					time = inS[station];
				}
				else if ((time % inF[station]) > 0) {
					time += (inF[station] - (time % inF[station]));
				}

				time += inC[station];
			}

			System.out.println(time);
		}
	}

}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		Array.Sort(A);
		Array.Sort(B);
		Array.Sort(C);
		
		long[] btot = new long[N];
		int k = 0;
		for(int j=0;j<N;j++){
			while(k < N){
				if(C[k] <= B[j]){
					k++;
					continue;
				}
				break;
			}
			btot[j] = N - k;
		}
		
		long[] bsum = new long[N+1];
		for(int i=0;i<N;i++){
			bsum[i+1] = btot[i] + bsum[i];
		}
		
		long ans = 0;
		k = 0;
		for(int i=0;i<N;i++){
			while(k < N){
				if(B[k] <= A[i]){
					k++;
					continue;
				}
				break;
			}
			ans += bsum[N] - bsum[k];
		}
		
		Console.WriteLine(ans);
		
		
		
	}
	int N;
	int[] A,B,C;
	public Sol(){
		N = ri();
		A = ria();
		B = ria();
		C = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 36184
import bisect
import sys
from math import atan
def lis(L):
    if not L:
        return 0
    seq = [L[0]]
    for i in L[1:]:
        if seq[-1] < i:
            seq.append(i)
        else:
            seq[bisect.bisect_left(seq, i)] = i
    return len(seq)

def mhd(x, y):
    return abs(x) + abs(y)

x1, y1, x2, y2 = map(int, sys.stdin.readline().split())
        
N = int(sys.stdin.readline())

if x1 == x2 or y1 == y2:
    if x1 == x2:
        if y1 > y2:
            y1, y2 = y2, y1
        for _ in range(N):
            X, Y = map(int, sys.stdin.readline().split())
            if X != x1:
                continue
            else:
                if y1 <= Y <= y2:
                    print(100*mhd(0, y1-y2) - 20 + 40*atan(1))
                    sys.exit()
                else:
                    print(100*mhd(0, y1-y2))
                    sys.exit()
    else:
        if x1 > x2:
            x1, x2 = x2, x1
        for _ in range(N):
            X, Y = map(int, sys.stdin.readline().split())
            if Y != y1:
                continue
            else:
                if x1 <= X <= x2:
                    print(100*mhd(x1-x2, 0) - 20 + 40*atan(1))
                    sys.exit()
                else:
                    print(100*mhd(x1-x2, 0))
                    sys.exit()
if x1 > x2:
    x1, x2 = x2, x1
    y1, y2 = y2, y1

geta = 10**9+7
B = []
if y1 < y2:
    for _ in range(N):
        X, Y = map(int, sys.stdin.readline().split())
        if x1 <= X <= x2 and y1 <= Y <= y2:
            B.append(X*geta + Y)
    B.sort()
    B = [b%geta for b in B]
    lb = lis(B)
    if lb == min(abs(x1-x2), abs(y1-y2)) + 1:
        print(100*mhd(x1-x2, y1-y2) + (lb-1)*(20*atan(1)-20) + 40*atan(1) - 20)
    else:
        print(100*mhd(x1-x2, y1-y2) + lb*(20*atan(1)-20))
    
else:
    for _ in range(N):
        X, Y = map(int, sys.stdin.readline().split())
        if x1 <= X <= x2 and y2 <= Y <= y1:
            B.append(X*geta - Y)
    B.sort()
    B = [b%geta for b in B]
    lb = lis(B)
    if lb == min(abs(x1-x2), abs(y1-y2)) + 1:
        print(100*mhd(x1-x2, y1-y2) + (lb-1)*(20*atan(1)-20) + 40*atan(1) - 20)
    else:
        print(100*mhd(x1-x2, y1-y2) + lb*(20*atan(1)-20))

Measured memory_bytes: 70696
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    ll A, B; cin >> A >> B;
    ll X[100100]; rep(i, N) cin >> X[i];
    ll ans = 0;
    rep(i, N - 1) {
        ans += min(B, A * abs(X[i] - X[i + 1]));
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        double count = 0;
        for(int i = 1; i <= a; i++){
            if(i % 2 != 0){
                count++;
            }
        }
        double sum = count / a;
        System.out.println(sum);
    }
}

Measured memory_bytes: 21972
<?php
$string_tmp = array();
// 回答保存用
$ans_set = array();
// 入力受付処理
while ($line = fgets(STDIN)) {
   $tmp[] = trim($line);
}
// INIT処理
$max_lenge = 8;
foreach($tmp as $val){
    // データセットをデクリメント
    $max_lenge--;
    // 1があるかどうかを確認
    if(preg_match('/1/',$val)){
        $string_tmp[] = $val;
    }// 一つデータセットを見終わった時の処理
     // 見つかった行数によって図形を判別
    if($max_lenge < 0){
        $tmp_length = count($string_tmp);
        if($tmp_length == 4){
            $ans_set[] = "B";
        }elseif($tmp_length == 1){
            $ans_set[] = "C";
        }elseif($tmp_length == 2){
            $ans_set[] = judge_line2($string_tmp);
        }elseif($tmp_length == 3){
            $ans_set[] = judge_line3($string_tmp);
        }
        // INIT 処理
        $string_tmp = array();
        $max_lenge = 8;
    }
}
$ans_set[] = judge($string_tmp);
foreach($ans_set as $val){
    echo $val."\n";
}
function judge($string_tmp){
    $ans;
    $tmp_length = count($string_tmp);
        if($tmp_length == 4){
            $ans = "B";
        }elseif($tmp_length == 1){
            $ans = "C";
        }elseif($tmp_length == 2){
            $ans = judge_line2($string_tmp);
        }elseif($tmp_length == 3){
            $ans = judge_line3($string_tmp);
        }
    return $ans;
}
// ラインが二列だった時の図形判別用
function judge_line2($string_tmp){
    $pos = strpos($string_tmp[0], "1");
    $pos2 = strpos($string_tmp[1], "1");
    if($pos == $pos2){
        return "A";
    }elseif ($pos < $pos2) {
        return "E";
    }else{
        return "G";
    }
}// ラインが三列だった時の図形判別用    
function judge_line3($string_tmp){
    $pos = strpos($string_tmp[0], "1");
    $pos2 = strpos($string_tmp[1], "1");
    if($pos > $pos2){
        return "D";
    }else{
        return "F";
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m ;
    cin >> n >> m ;
    vint h(n) ;
    REP(i,n){
        cin >> h[i] ;
    }

    vvint vec ;
    REP(i,n){
        vec.PB(vint()) ;
    }
    REP(i,m){
        int a, b ;
        cin >> a >> b ;
        vec[a-1].PB(b-1) ;
        vec[b-1].PB(a-1) ;
    }

    int cnt = 0 ;
    REP(i,n){
        bool f = true ;
        REP(j,SZ(vec[i])){
            if(h[i]<=h[vec[i][j]]){
                f = false ;
            }
        }
        if(f){
            cnt++ ;
        }
    }
    cout << cnt <<endl ;


    

    return 0;
}


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

int main(){
  string str;
  int q;
  cin >> str;
  cin >> q;
  while(q--){
    string s;
    cin >> s;
    if(s == "print"){
      int a, b;
      cin >> a >> b;
      cout << str.substr( a, b - a + 1) << endl;
    } else if(s == "reverse"){
      int a, b;
      cin >> a >> b;
      reverse( str.begin() + a, str.begin() + b+ 1);
    } else {
      int a, b;
      string p;
      cin >> a >> b >> p;
      str.replace( a, b - a + 1, p);
    }
  }
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(3*n);
    for(int i=0; i<3*n; i++)cin>>a[i];
    sort(a.begin(), a.end());

    long long ans = 0LL;
    for(int i=3*n-2; i>=n; i-=2){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif
int n, m, q;
vector<int> a, b, c, d;

ll calc(vector<int> &v){
	ll res = 0;
	// rep(i, v.size()){
	// 	if(i) cout << " ";
	// 	cout << v[i];
	// }
	// cout << endl;
	rep(i, q){
		if(v[b[i]] - v[a[i]] == c[i]){
			res += d[i];
		}
	}
	return res;
}

ll make_str(vector<int> v, int bef){
	if(v.size() == n){
		return calc(v);
	}

	ll res = 0;
	rep2(i, 1, m+1){
		if(i < bef) continue;
		vector<int> v2;
		rep(j, v.size()) v2.push_back(v[j]);
		v2.push_back(i);
		res = max(res, make_str(v2, i));
	}

	return res;
}

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	cin >> n>> m >> q;
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	rep(i, q){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--;
	}

	vector<int> v;
	cout << make_str(v, -1) << endl;

	return 0;
}


Measured memory_bytes: 3636
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def is_prime(n): # 素数判定
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return True



A, B = map(int, input().split())
A_d = divisor(A)
B_d = divisor(B)
n_d = []
for i in A_d:
    if i in B_d:
        n_d.append(is_prime(i))
print(sum(1 for i in n_d if i is True))

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  const ll M = (ll)1e9 + 7;
  ll ans = 0;
  for (ll i = k; i <= n + 1; i++) {
    ll beg = (i - 1) * i / 2;
    ll end = (2 * n - i + 1) * i / 2;
    ll sum = (end - beg + 1) % M;
    // cout << beg << ' ' << end << ' ' << sum << endl;
    ans += sum;
    ans %= M;
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	sort(h.begin(), h.end(), greater<int>());

	int mn = 1e9;
	for (int i = 0; i < n - k + 1; i++) {
		mn = min(mn, h[i] - h[i + k - 1]);
	}
	cout << mn << endl;

}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();

		for (int i = 0; i < s.length; i++) {
			if(s[i] == 'A')System.out.print("T");
			else if(s[i] == 'T') System.out.print("A");
			else if(s[i] == 'C') System.out.print("G");
			else System.out.print("C");
		}
		sc.close();
	}
}

Measured memory_bytes: 21076
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int sum = 0;
		for(int i = A; i > 0; i--){
			sum += i;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21460
from collections import deque
import sys
input = sys.stdin.readline

n, q = map(int, input().split())

tree = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

counter = [0] * n

for _ in range(q):
    p, x = map(int, input().split())
    counter[p-1] += x

query = deque([(0, -1)]) # current, parent
while query:
    current, parent = query.popleft()
    value = counter[current]
    for node in tree[current]:
        if node == parent:
            continue
        else:
            counter[node] += value
            query.append((node, current))

print(*counter)

Measured memory_bytes: 96460
#!/usr/bin/env python3
# DPL_1_B: Combinatorial - 0-1 Knapsack Problem

from operator import itemgetter


def max_value(total_weight, items):
    values = [0] * (total_weight+1)

    for v, w in sorted(items, key=itemgetter(1)):
        for i in reversed(range(w, total_weight+1)):
            values[i] = max(values[i], values[i-w] + v)

    return values[-1]


def run():
    n, t = [int(i) for i in input().split()]
    vs = []

    for _ in range(n):
        v, w = [int(i) for i in input().split()]
        vs.append((v, w))

    print(max_value(t, vs))


if __name__ == '__main__':
    run()



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

int main()
{
    int n, s, sum, ans;

    while(true) {

        cin >> n >> s;

        if(n == 0 && s == 0)
            break;

        int arr[10] = {0};

        for(int i = 0; i < n; i++)
            arr[9-i] = 1;

        ans = 0;

        do {
            sum = 0;
            for(int i = 0; i < 10; i++) {
                if (arr[i])
                    sum += i;
            }
            if (sum == s)
                ans++;
        } while(next_permutation(arr, arr+10));

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

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int a = in.nextInt();
			int b = in.nextInt();

			out.println(a + b >= 10 ? "error" : a+b);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21204
import bisect as bi
import collections as cc
I=lambda:list(map(int,input().split()))
x,=I()
ar=[]
i=1
fl=1

t=bi.bisect_left(ar,x)
for i in range(-1000,1000):
    for j in range(-1000,1000):
        if pow(i,5)-pow(j,5)==x:
            print(i,j)
            fl=0
            break
    if not fl:
        break

Measured memory_bytes: 68164
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                int[] a = new int[N];
                int cnt = 0;
                
                for(int i=0;i<N;i++){
                    a[i] = scan.nextInt();
                }
                for(int i=0;i<N;i=i+2){
                    if(a[i]%2==1){
                        cnt++;
                    }
                }
                
                
                System.out.println(cnt);
        }               
}

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

s = [0,0]
ans = [0,0]
# [0]:+ - + - ... [1]:- + - + - ...

for i in range(n):
    s[0] += a[i]
    s[1] += a[i]
    if s[0]*pow(-1,i) <= 0:
        ans[0] += 1 - s[0]*pow(-1,i)
        s[0] = pow(-1,i)
    if s[1]*pow(-1,i) >= 0:
        ans[1] += s[1]*pow(-1,i) + 1
        s[1] = -pow(-1,i)
print(min(ans))


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

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        int N = int.Parse(input);
        input = Console.ReadLine();
        char[] S= input.ToCharArray();
        int white_all = 0;
        int black = 0;
        for(int i = 0; i < N; i++)
        {
            if (S[i] == '.') { white_all++; }
        }
        int ans = white_all;
        int counter = 0;
        int white = white_all;
        if (white_all == S.Length || white_all == 0) ans = 0;
        else
        {
            for (int i = 0; i < N; i++)
            {
                if (S[i] == '#') { black++; }
                else { white--; }
                counter = black + white;
                if (counter < ans) { ans = counter; }
            }
        }
        Console.WriteLine(ans);
    }
}

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

int search(int A[], int n, int key) {
	int i = 0;
	A[n] = key;
	while (A[i] != key) i++;
	return i != n;
}

int main()
{
	int n, A[10001], q, key, sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];

	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> key;
		if (search(A, n, key)) sum++;
	}
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <stdio.h>
#include <vector>
#define mp make_pair
using namespace std;

int fib(int x){
	switch(x){
		case 0:
		return 1;
		case 1:
		return 1;
		case 2:
		return 2;
		case 3:
		return 3;
		case 4:
		return 5;
		case 5:
		return 8;
		case 6:
		return 13;
		case 7:
		return 21;
		default:
		return 34;
	}
}
int main(){
	int h, w, k;
	cin>>h>>w>>k;
	long long s[w];
	long long e[w];
	for(int i = 0;i < w;i ++){
		s[i]=(i==0);
	}
	for(int i = 0;i < h;i ++){
		for(int j = 0;j < w;j ++){
			e[j]=0;
		}
		for(int j = 0;j < w;j ++){
			if(j){
				e[j-1]+=s[j]*fib(j-1)*fib(w-j-1);
				e[j-1]%=1000000007;
			}
			if(j<w-1){
				e[j+1]+=s[j]*fib(j)*fib(w-j-2);
				e[j+1]%=1000000007;
			}
			e[j]+=s[j]*fib(j)*fib(w-j-1);
			e[j]%=1000000007;
		}
		for(int j = 0;j < w;j++){
			s[j]=e[j];
		}
	}
	cout<<(int)e[k-1]<<"\n";
}

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

int n;
vector<vector<int>> tree;
vector<vector<int>> dp;

const int MOD = 1e9 + 7;

long long solve(int node, int parent, bool is_white) {
    if (dp[node][is_white] == 0) {
        long long res = 1;
        for (int child : tree[node]) {
            if (child != parent) {
                if (is_white) {
                    res *= (solve(child, node, true) + solve(child, node, false)) % MOD;
                } else {
                    res *= solve(child, node, true);
                }
                res = res % MOD;
            }
        }

        dp[node][is_white] = res;
    }

    return dp[node][is_white];
}

int main() {
    cin >> n;

    tree.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        tree[x - 1].push_back(y - 1);
        tree[y - 1].push_back(x - 1);
    }

    dp.resize(n, vector<int>(2));
    cout << (solve(0, -1, true) + solve(0, -1, false)) % MOD;
}

Measured memory_bytes: 19584
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut cur: usize = 0;
    for _ in 0..n {
        let h: usize = scan(tokens);
        if h < cur {
            println!("No");
            return;
        } else if h == cur {
            // do nothing
        } else {
            cur = h - 1;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
#define rep1(i, a, b) for(int i=a; i<=(int)(b); i++)
typedef long long LL;

const int MAX_N = 101, MAX_K=1e5+1, mod = 1e9+7;
int n, K, A[MAX_N], dp[MAX_N][MAX_K];

int main() {
    scanf("%d %d", &n, &K);
    rep(i, n) scanf("%d", &A[i]);
    rep(i, n+1) dp[i][0]=1;
    rep1(i, 1, n) {
        rep1(j, 1, K) {
            dp[i][j] = (dp[i][j-1]+dp[i-1][j]) % mod;
            if(j-1-A[i-1]>=0) dp[i][j] = (dp[i][j]-dp[i-1][j-1-A[i-1]]+mod)%mod;
        }
    }
    // rep(i,n+1) rep(j,K+1) {
    //     printf("%d%c", dp[i][j], ((j==K)?'\n':' '));
    // }


    printf("%d\n", dp[n][K]);
    return 0;
}


Measured memory_bytes: 39296
n = int(input())
a = list(map(int,input().split()))
ans = 0
d = {}
for i in range(n):
  if d.get(i+a[i],0)==0:
    d[i+a[i]] = [0,0]
  if d.get(i-a[i],0)==0:
    d[i-a[i]] = [0,0]
  d[i+a[i]][0] += 1
  d[i-a[i]][1] += 1
for v in d.values():
  ans += v[0]*v[1]
print(ans)

Measured memory_bytes: 88996
n = int(input())
A = list(map(int, input().split()))

ans = 1
A.sort(reverse = True)
flag = True

if 0 in A:
    ans = 0
    flag = False

if flag:
    for i in range(n):
        ans = ans * A[i]
        if ans > 10 ** 18:
            ans = -1
            break

print(ans)

Measured memory_bytes: 21520
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; i+=2) {
    int tcnt = 0;
    for (int j = 1; j <= i; j++) {
      if (i%j == 0) tcnt++;
    }
    if (tcnt == 8) cnt++;
  }
  dump(cnt);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//??£??\???????????¨???
	ll to, cost;
};
struct S {//???????????±?????\???????????°
	int from, to, cost;
};
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
ll gcm(ll i, ll j) {//?????§??¬?´???°
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad?????§?¨???????2??????????????¢
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//????????°?????????
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int h, w, a[1000][1000];
H b[1000001];
signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> a[i][j];
	priority_queue<H, vector<H>, greater<H>>p;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			b[a[i][j]] = H{ i,j };
			if (i > 0 && a[i - 1][j] < a[i][j])
				continue;
			if (i < h - 1 && a[i + 1][j] < a[i][j])
				continue;
			if (j > 0 && a[i][j - 1] < a[i][j])
				continue;
			if (j < w - 1 && a[i][j + 1] < a[i][j])
				continue;
			p.push(H{ a[i][j], a[i][j] });
		}
	}
	int ans = 0;
	while (!p.empty()) {
		int f = p.top().x, sum = 0;
		int x = b[f].x, y = b[f].y;
		while (!p.empty() && p.top().x == f) {
			int t = p.top().y;
			while (!p.empty() && p.top().y == t&&p.top().x == f) {
				p.pop();
			}
			if (x > 0 && a[x - 1][y] > a[x][y])
				p.push(H{ a[x - 1][y],t });
			if (x < h - 1 && a[x + 1][y] > a[x][y])
				p.push(H{ a[x + 1][y],t });
			if (y > 0 && a[x][y - 1] > a[x][y])
				p.push(H{ a[x][y - 1],t });
			if (y < w - 1 && a[x][y + 1] > a[x][y])
				p.push(H{ a[x][y + 1],t });
			sum++;
		}
		if (sum > 1)
			ans++;
	}
	cout << ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 42724
from fractions import gcd

# inputa
n , x , d = map(int, list(input().split()))

# process
if d == 0:
    if x == 0:
        print(1)
    else:
        print(n + 1)

else:
    # sが何通りあるかを求める
    
    # dを正にする
    if d < 0: d, x = -d, -x

    # d,xを互いに素にする   
    g = gcd(d, abs(x))
    d, x =  d//g, x//g
    
    # s=k*x+c*d
    # cは最小で0からk-1の和、最大でn-kからn-1の和
    # kを固定するとs//dは1ずつの単調増加なので、最小と最大で個数が分かる

    # sはs%d=k*x%dなので、それで分類する
    # →klistをk*x%dでソート
    klist = list(range(n + 1))
    klist.sort(key=lambda k: (k*x%d, k))

    # kを固定し、cの最小・最大を求め、加算していく
    ans = 0

    # 1つ前の値を保持
    pmin, pmax = 1, 0
    pmd = -1
    for k in klist:
        # s//dの最小・最大・s%d
        tmin = (k * x + (k - 1) * k // 2 * d) // d
        tmax = (k * x + (2 * n - k - 1) * k // 2 * d) // d
        tmd = k*x%d

        # s%dが前と同じ　かつ
        # s//dの最小<=前の最大　かつ　s//dの最大>=前の最小のとき
        # 最大・最小を更新
        if tmd == pmd and tmin <= pmax and tmax >= pmin:
            pmin, pmax = min(pmin, tmin), max(pmax, tmax)
        else:
            ans += pmax - pmin + 1
            pmin, pmax = tmin, tmax
        pmd = tmd
        
    ans += pmax - pmin + 1
    print(ans)


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

int strint(string s){
    int a=0;
    for (int i=0; i<s.size(); i++) {
        if(s.at(i) == '1')
            a+=1;
        if(s.at(i) == '2')
            a+=2;
        if(s.at(i) == '3')
            a+=3;
        if(s.at(i) == '4')
            a+=4;
        if(s.at(i) == '5')
            a+=5;
        if(s.at(i) == '6')
            a+=6;
        if(s.at(i) == '7')
            a+=7;
        if(s.at(i) == '8')
            a+=8;
        if(s.at(i) == '9')
            a+=9;

        a *= 10;
    }
    a /= 10;
    return a;
}

int main(){
    string s; cin>>s;
    int answer = abs(strint(s.substr(0,3))-753);
    for (int i=1; i+3<=s.size(); i++) {
        int n = abs(strint(s.substr(i,3))-753);
        answer = min(answer,n);
    }
    cout<<answer<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   vector<int> a(n);
   rep(i, n) { cin >> a[i]; }
   sort(a.begin(), a.end());
   bool issame = false;
   for (int i = 1; i < n; i++) {
      if (a[i - 1] == a[i])
         issame = true;
   }
   if (issame)
      cout << "NO" << endl;
   else
      cout << "YES" << endl;
   return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
x = list(sorted(set(a)))
n_sub = n * (n + 1) // 2
Li = 0
Ri = len(x)
while Ri > Li + 1:
    i = (Li + Ri) // 2
    xi = x[i]
    UorD = [1 if ak >= xi else -1 for ak in a]
    cnt_sum = [0] * (2 * n + 1)
    cumsum = 0
    cnt_sum[cumsum + n] = 1
    judge = 0
    s = 0
    for uk in UorD:
        cumsum += uk
        if uk == 1:
            s += cnt_sum[cumsum + n] + 1
        else:
            s -= cnt_sum[cumsum + n + 1] - 1
        cnt_sum[cumsum + n] += 1
        judge += s
        if judge >= n_sub // 2:
            Li = i
            break
    else:
        Ri = i
print(x[Li])


Measured memory_bytes: 15012
num = input().split(" ")
zahyou_x = input().split(" ")
zahyou_y = input().split(" ")
x_num = int(num[0])
y_num = int(num[1])
x_sum = 0
y_sum = 0

for i in range(x_num):
    x_sum += int(zahyou_x[i]) * (i*2 - x_num + 1)

for i in range(y_num):
    y_sum += int(zahyou_y[i]) * (i*2 - y_num + 1)
print(x_sum*y_sum%(10**9+7))

Measured memory_bytes: 19452
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
A = Counter(map(int, input().split()))

cand = []
for k, v in A.items():
    if v >= 2:
        cand.append((k, v))
cand = sorted(cand, reverse=True)

ans = 0
if len(cand) == 0:
    ans = 0
elif cand[0][1] >= 4:
    ans = cand[0][0] ** 2
else:
    ans = cand[0][0] * cand[1][0]
print(ans)




Measured memory_bytes: 28040
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
  ll X;
  cin>>X;
  ll a=X%100;
  ll b=X/100;
  if(a>b*5){
    cout<<0<<endl;
  }else{
    cout<<1<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
S = list(input())


def check(i):
    if i % 2 == 0:
        return False

    first = S[:i // 2 + 1]
    tail = S[i // 2 + 1:i + 1]
    return "".join(first) == "".join(tail)


N = len(S) - 2
ans = -1
for i in range(N):
    if check(i):
        ans = i + 1
print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	vector<int>as(4), bs(4);
	while (cin >> as[0]) {
		for (int i = 0; i < 3; ++i) {
			cin >> as[i + 1];
		}
		for (int i = 0; i < 4; ++i) {
			cin >> bs[i];
		}
		int hit = 0, blow = 0;
		for (int i = 0; i < 4;++i){
			if (as[i] == bs[i])hit++;
			for (int j = 0; j < 4; ++j) {
				if (i == j)continue;
				if (as[i] == bs[j])blow++;
			}
		}
		
		cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
x=0
1.upto(N) do|i|
  if i*(i+1)/2>N
      puts "No"
      exit
  elsif i*(i+1)/2==N
      x=i
      break
  end
end
puts "Yes"
puts x+1
ans=array(x,-1,x+1)
now=0
v=0
x.times do|i|
  i.upto(x-1) do|j|
    ans[j+1][now]=j+1+v
    ans[now][j]=j+1+v
  end
  now+=1
  v+=x-1-i
end
(x+1).times do|i|
    puts x.to_s+" "+ans[i].join(" ")
end

Measured memory_bytes: 15708
#include <cstdio>
#include <cmath>

int main(){
    double a, b, C, d, e, S, L, h;
    scanf("%lf %lf %lf", &a, &b, &C);
    d = C * acos(-1) / 180;
    S = (a * sin(d) * b) / 2;
    e = sqrt((a * a) + (b * b) - (2 * a * b * cos(d)));
    L = a + b + e;
    h = S * 2 / a;
    printf("%f %f %f", S, L, h);
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define LOG1(a)			  cerr<< #a << " = " << (a) << "\n"
#define LOG2(a, b)		  cerr<< #a << " = " << (a) << ", " << #b << " = " << (b) << "\n"
#define endl "\n"

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int n, arr[nax];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    cout << 24 + 24 - n << endl;
    return 0;
}


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

typedef long long int lli;

string s;
int idx;

lli term();

lli number() {
    lli ret = 0;
    while (isdigit(s[idx])) {
        ret = ret * 10 + (s[idx] - '0');
        idx++;
    }
    return ret;
}

lli expr() {
    lli left = term();
    while (s[idx] == '/') {
        idx += 2; // skip ">>"

        double val = left;
        lli right = term();
        for (int i = 0; val + 1e-5 > 1 && i < right; i++)
            val /= 2;
        left = floor(val);
    }
    return left;
}

lli term() {
    if (s[idx] == 'S') {
        idx += 2; // skip 'S<'

        lli val = expr();
        val %= 1000000007;
        val = (val * val) % 1000000007;

        idx++; // skip ">"
        return val;
    }
    return number();
}

string preproc(string s) {
    string ret = "";
    reverse(s.begin(), s.end());
    bool pre_term = false;
    for (int i = 0; i < s.size(); i++) {
        while (s[i] == ' ') i++;
        if (pre_term && i + 1 < s.size() && s[i] == '>' && s[i+1] == '>') {
            i++; // skip ">>"
            ret += "//";
            pre_term = false;
            continue;
        }
        if (s[i] == 'S' || isdigit(s[i]))
            pre_term = true;
        else
            pre_term = false;
        ret += s[i];
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

int main() {
    while (true) {
        idx = 0;
        getline(cin, s);
        if (s == "#") break;
        s = preproc(s);
        // cerr << s << endl;
        cout << expr() << endl;
    }
}



Measured memory_bytes: 5996
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Hcount,Wcount;

		while(true){
			Hcount = sc.nextInt();
			Wcount = sc.nextInt();

			if(Hcount ==0 && Wcount ==0) {
				break;
			}
			for(int i =0; i<Hcount;i++) {
				if(i%2==0){
					for(int x =0; x<Wcount;x++) {
						if(x%2==0)
							System.out.print("#");
						else
							System.out.print(".");
					}
					}else {
						for(int x =0; x<Wcount;x++) {
							if(x%2==0)
								System.out.print(".");
							else
								System.out.print("#");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 33132
n = int(input())
A = list(map(int,input().split()))

ans = [0]*8
free = 0
for a in A:
    for i in range(8):
        if a < (i+1)*400:
            ans[i]=1
            break
    if 3200 <= a:
        free += 1
ans_max = sum(ans)+free
ans_min = max(1, sum(ans))
print(ans_min, ans_max, sep=' ')

Measured memory_bytes: 38256
n = int(raw_input())
p = [0 for i in range(0, 101)]
m = [[0 for i in range(0, 101)] for j in range(0, 101)]
for i in range(1, n + 1):
    p[i-1], p[i] = map(int, raw_input().split())
     
for l in range(2, n + 1):
    for i in range(1, n - l + 2):
        j = i + l - 1
        m[i][j] = float("inf")
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]* p[k] * p[j])
 
print m[1][n]

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    long long sub = 0;
    long long p[3] = {0, 0, 0};
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') p[0]++;
        else if (s[i] == 'G') p[1]++;
        else p[2]++;
        for (int j = 1; j < min(i+1, n-i); j++) {
            if (s[i] != s[i-j] && s[i] != s[i+j] && s[i-j] != s[i+j]) sub++;
        }
    }
    cout << p[0] * p[1] * p[2] - sub << "\n";
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
using namespace std;
#include <string>
#include <vector>
int main(){
int n, m;
  cin >> n >> m;
  vector<int> H(n+1),N(n+1,1);
  for(int i =1; i <= n; i++)cin >> H[i];
  int a,b;
  for(int i = 1; i <= m; i++){
	cin >> a >> b;
    if(H[a]==H[b])N[a]=N[b]=0;
    if(H[a] > H[b]){
      N[b]=0;
    }else{
      N[a]=0;
    }
  }
  int ans=0;
  for(int i = 1; i <= n; i++){
    if(N[i]==1)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
//#define debug 1

int main() {
	int a,b,city[]={0,0,0,0,0};
	for(int i=0;i<3;i++) {
		cin>>a>>b;
		city[a]++;city[b]++;
#ifdef debug
	for(int i=0;i<4;i++) cout<<city[i]<<endl;
#endif
	}
	
	int one=0,two=0;
	for(int i=1;i<5;i++) {
		if(city[i]==1) one++;
		else if(city[i]==2) two++;
	}
	if(one==2 && two==2) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
#ifdef debug
	for(int i=0;i<4;i++) cout<<city[i]<<endl;
#endif
	return 0;
}


Measured memory_bytes: 256