akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            break;
        vector<int> page(n);
        for(int i=0; i<n; ++i)
            cin >> page[i];
        for(int i=0; i<n; ++i){
            if(i != 0)
                cout << ' ';
            cout << page[i];
            int j = i+1;
            while(j < n && page[j] == page[j-1] + 1)
                ++ j;
            if(j > i + 1)
                cout << '-' << page[j-1];
            i = j - 1;
        }
        cout << endl;
    }
}

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

int dp[100010][3];

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

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

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j == k) continue;
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + A[i][k]);
            }
        }
    }

    int maxi = -1e9;
    for(int i = 0; i < 3; i++){
        maxi = max(maxi, dp[n][i]);
    }

    cout << maxi << endl;

    return 0;
}

Measured memory_bytes: 2560
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n

INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x

def prob_1():
    d = Debug()
    d.off()
    S = input()
    d.dmp((S),'S')
    count = 0
    zeroFound = False
    for c in S:
        #d.dmp((c),'c')
        if c == '0':
            zeroFound = True
        elif c == '+':
            if zeroFound:
                zeroFound = False
            else:
                count += 1
        #d.dmp((count),'count')
    if not zeroFound:
        count += 1
    return count

def prob():
    d = Debug()
    d.off()
    N = getInt()
    H = getIntList()
    d.dmp((N,H),'N,H')
    v = zeros(N)
    v[0] = H[0]
    count = 1
    for i in range(N-1):
        if v[i] <= H[i+1]:
            v[i+1] = H[i+1]
            count += 1
        else:
            v[i+1] = v[i]
    d.dmp((v),'v')
    return count


ans = prob()
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repe(i, n) for(int (i) = 0; i <= (n); (i)++)
#define repr(i, n) for(int (i) = (n); (i) > 0; --(i))
#define repre(i, n) for(int (i) = (n); (i) >= 0; --(i))
typedef long long ll;
typedef unsigned long long ull;
const ull MOD = 1000000007;
ull mpow(ull a, ull n);
ull inv_mod(ull a){return mpow(a, MOD-2);}

ull mpow(ull a, ull n)
{
    ull ans = 1;
    while(n){
        if(n & 1)(ans *= a)%= MOD;
        (a*=a)%MOD;
        n>>1;
    }
}

ull nCr(ull n, ull r)
{
    vector<ull> factorial(n+1);
    factorial[0]=1;
    rep(i, n)factorial[i+1] = factorial[i]*(i+1)%MOD;
    return factorial[n]*inv_mod(factorial[n-r]%MOD)*inv_mod(factorial[r]%MOD);
}

int sumses1(int n)
{
    if(n == 1)return 1;
    return (n * sumses1(n-1));
}

int sumses(int n)
{
    if(n == 1)return 1;
    return (n + sumses(n - 1));
}


double dp[9][9] = {0};

int main()
{
    ll N;
    cin >> N;
    int a, b;
    int pat1 = sumses1(N);
    int pat2 = sumses(N-1);
    double sum = 0;
    double ave;
    vector<pair<int, int>> dist(N+1);
    rep(i, N){
        cin >> a >> b;
        dist[i+1] = make_pair(a, b);
    }
    for(int i = 1; i <= N - 1; i++){
        for(int j = i + 1; j <= N; j++) {
            sum += sqrt((pow(dist[i].first -dist[j].first, 2)) + pow(dist[i].second - dist[j].second, 2)) * (pat1/ pat2);
        }
    }
    ave = sum / pat1 * (N -1);
    cout << setprecision(10) << ave << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

s = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))

count = 0
for i in range(2**n):
    flag = True
    for j in range(m):
        if not([1 & (i >> k-1) for k in s[j]].count(1) % 2 == p[j]):
            flag = False
    if flag:
        count += 1
print(count)





Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			int n = sc.nextInt();/* 山の枚数 */
			int r = sc.nextInt();/* 切る回数 */
			if(n == 0) break;
			
			int[] yama = new int[n];
			for(int i = 0; i < n; i++) {
				yama[i] = i + 1;
			}
			
			for(int i = 0; i < r; i++) {
				int p = sc.nextInt();/* c枚の開始点 */
				int c = sc.nextInt();/* 切る枚数 */
				
				int mid = n - (p - 1), min = mid - c;
				int[] cut = new int[c];/* シャッフルの一時保存先 */
				System.arraycopy(yama, min, cut, 0, c);/* コピー */
				
				System.arraycopy(yama, mid, yama, min, p - 1);/* ずらし */				
				System.arraycopy(cut, 0, yama, n-c, c);/* コピーの戻し */
			}
			System.out.println(yama[n-1]);
		}
	}

}



Measured memory_bytes: 36372
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long unsigned int ll;

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

int main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
    }
    cout<<sum-n<<endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N string

func main() {
	sc.Split(bufio.ScanWords)

	N = nextStr()
	d := len(N)
	n, _ := strconv.Atoi(N)
	a, _ := strconv.Atoi(string(N[0]))

	if a*powInt(10, d-1)+powInt(10, d-1)-1 == n {
		fmt.Println(a + 9*(d-1))
	} else {
		fmt.Println((a - 1) + 9*(d-1))
	}

}


Measured memory_bytes: 640
deg = Math::PI/2
x = 0.0;y = 0.0
until (s=gets.chomp) == "0,0" do
    diff = s.split(",").map(&:to_i)
    x += diff[0]*Math.cos(deg)
    y += diff[0]*Math.sin(deg)
    deg -= (diff[1]*Math::PI/180.0)
end
puts x.to_i, y.to_i

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

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define rep(i,n) for (unsigned int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define mp make_pair
const int maxe = 2e5+5;

ll t=1, n=0, m=0, ans=0;
ll arr[maxe];
void solve(){
	cin >> n;
	rep(i, n){
		cin >> arr[i];
	}
	sort(arr, arr+n);
	ll ans = 0;
	for(int i = 0; i<n; i++){
		for(int j = i+1; j<n; j++){
			for(int l = j+1; l<n; l++){
				if(arr[i] + arr[j] > arr[l] && arr[i] != arr[j] && arr[j] != arr[l] && arr[i] != arr[l]) 
					ans++;
			}
		}
	}
	cout << ans;
	
}

int main(){
	while(t--){
		solve();
	}
	return 0;
}





Measured memory_bytes: 3636
N = input()

if (N[-1] == '2') or (N[-1] == '4') or (N[-1] == '5') or (N[-1] == '7') or (N[-1] == '9'):
  print('hon')
elif (N[-1] == '0') or (N[-1] == '1') or (N[-1] == '6') or (N[-1] == '8'):
  print('pon')
elif (N[-1] == '3'):
  print('bon')
else:
  pass

Measured memory_bytes: 9064
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize h, w;
    std::cin >> h >> w;
    while (h--) {
        std::string s;
        std::cin >> s;
        std::cout << s << '\n';
        std::cout << s << '\n';
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bitset>
using namespace std;
using ll =long long;
const ll  p = 1e9 + 7;
ll mod_inv(ll x, ll prime = p){
    ll y = p-2;
    bitset<64> y_(y);
  ll ans = 1L;
  while(y){
      
    if(y&1){
      ans = (ans * x)%prime;
    }
    x = (x*x)%prime;
    y >>= 1;
    y_>>=1;
  }
  
  return ans;
}

int main(){
  int N;
  cin>>N;
  vector<ll> a(N);
  int i = 0;
  while(cin>>a[i++]);
  ll sum_of_squares = accumulate(a.begin(), a.end(), 0, [](ll prev, ll cur){return(prev  + cur*cur%p)%p;});
  ll sum = accumulate(a.begin(), a.end(), 0, [](ll prev, ll cur){return (prev  + cur)%p;});
  ll square_of_sum = sum* sum %p;
//   cout<<"mod_inv(2) = "<<mod_inv(2)<<endl;
  cout<<(square_of_sum - sum_of_squares + p)*mod_inv(2)%p;
}

Measured memory_bytes: 4840
object Main extends App {
	val n = scala.io.StdIn.readInt
	var a = n/100
	var b = (n%100)/10
	var c = n%10

	a match {
		case 1 => a = 9
		case 9 => a = 1
		case _ => 
	}

	b match {
		case 1 => b = 9
		case 9 => b = 1
		case _ => 
	}

	c match {
		case 1 => c = 9
		case 9 => c = 1
		case _ => 
	}

	println(100*a + 10*b + c)


} 


Measured memory_bytes: 25420
#include <iostream>
using namespace std;
typedef long long int ll;
ll dp[52][52][3000];//i枚まででj枚選んでpになる選び方
int main(){
  int n,a;
  cin >> n>>a;
  int x[n];
  for(int i=0;i<n;i++) cin >>x[i];
  ll ans=0;
  dp[0][0][0] = 1; // dp[0][0] だけ 1 に
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      for(int p=0;p<=n*a;p++){
      dp[i+1][j][p] += dp[i][j][p];//x[i]を選ばない
      if (p>= x[i]) dp[i+1][j+1][p] += dp[i][j][p-x[i]];//x[i]を選ぶ
    }
  }
  }
  for(int i=1;i<=n;i++) ans+=dp[n][i][i*a];
  cout << ans<<endl;
}


Measured memory_bytes: 61184
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    IO;
    int n;
    cin >> n;
    long long ans = 0;
    int numberOfDigits = log10(n);
    for(int i = 0; i < numberOfDigits; i += 2)
    {
        long long kk = 9 * pow(10, i);
        ans += kk;
    }
    if(!(numberOfDigits & 1))
        ans += n - pow(10, numberOfDigits) + 1;
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int INF = 100000000;
int f(vector<int> &s, int X){
  int N = s.size();
  int level = 1;
  int cnt = 0;
  int p = 0;
  for (int i = 0; i < N - 1; i++){
    if (s[i] >= level + X){
      return INF;
    } else {
      while (s[i + 1] >= level + X){
        int max_d = 1;
        if (p < N){
          while (s[p] < level){
            p++;
            if (p == N){
              break;
            }
          }
        }
        if (p < N){
          if (s[p] < level + X){
            max_d = max(max_d, X - abs(level - s[p]));
          }
        }
        if (p > 0){
          max_d = max(max_d, X - abs(level - s[p - 1]));
        }
        level += max_d;
        cnt++;
      }
    }
  }
  cnt++;
  return cnt;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  while (1){
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0){
      break;
    }
    vector<int> s(N);
    for (int i = 0; i < N; i++){
      cin >> s[i];
    }
    int tv = max(s[0] - 1, 0);
    int fv = INF;
    while (fv - tv > 1){
      int mid = (tv + fv) / 2;
      int cnt = f(s, mid);
      if (cnt >= M){
        tv = mid;
      } else {
        fv = mid;
      }
    }
    if (tv == max(s[0] - 1, 0) || fv == INF){
      cout << -1 << endl;
    } else {
      cout << tv << endl;
    }
  }
}



Measured memory_bytes: 3548
import collections
import itertools as it
import math
import numpy as np

# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

N = int(input())
S = input()



for s in S:
    # print(ord('A'))
    print(chr(((ord(s) + N) - 65) % 26 + 65), end="")

Measured memory_bytes: 22156
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  int n, m;
  scanf("%d%d", &n, &m);
  vector<ll> dp(m + 1);
  while (n--) {
    int w, v;
    scanf("%d%d", &w, &v);
    for (int i = m; i >= w; --i)
      dp[i] = max(dp[i], dp[i - w] + v);
  }
  printf("%lld\n", dp.back());

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str_scan = scan.nextLine();
    // スペース区切りで分ける
    var str = str_scan.split(" ");
    // int型へ変換
    var A = Integer.parseInt(str[0]);
    var B = Integer.parseInt(str[1]);
    var C = Integer.parseInt(str[2]);

    String ans = "No";

    String k_scan = scan.nextLine();
    var K = Integer.parseInt(k_scan);

    for (var i=0;i<=K;i++) {
      var Atmp = A << i;
      for (var j=0;j<=K;j++) {
        var Btmp = B << j;
        for (var f=0;f<=K;f++) {
          var Ctmp = C << f;

          if ( (Btmp > Atmp)  && (Ctmp > Btmp) && (i+j+f <= K) ) {
            ans = "Yes";
            break;
          }

        }
        if (ans == "Yes") {
          break;
        }
      }
      if (ans == "Yes") {
        break;
      }
    }

    System.out.println(ans);
    scan.close();
  }
}

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

using namespace std;

#define INF 2<<29
#define F first
#define S second

typedef long long ll;
typedef pair<int,int>P;

int main(){
  int n,temp=0;
  int a;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    temp=temp^a;
  }

  if(temp==0) printf("Yes\n");
  else printf("No\n");
	
  return 0;
}



Measured memory_bytes: 256
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: x,k,d,n

    read*, x,k,d

    if (x>=0) then
        if (log10(dble(k))+log10(dble(d)) <= 18) then
            if (x-k*d >= 0) then
                print*, x-k*d
            else
                n = x/d
                if (mod(n,2_8) == mod(k,2_8)) then
                    print*, mod(x,d)
                else
                    print*, -(mod(x,d)-d)
                end if
            end if
        else
            n = x/d
            if (mod(n,2_8) == mod(k,2_8)) then
                print*, mod(x,d)
            else
                print*, -(mod(x,d)-d)
            end if
        end if
    else
        if (log10(dble(k))+log10(dble(d)) <= 18) then
            if (x+k*d <= 0) then
                print*, -(x+k*d)
            else
                n = -x/d
                if (mod(n,2_8) == mod(k,2_8)) then
                    print*, mod(-x,d)
                else
                    print*, -(mod(-x,d)-d)
                end if
            end if
        else
            n = -x/d
            if (mod(n,2_8) == mod(k,2_8)) then
                print*, mod(-x,d)
            else
                print*, -(mod(-x,d)-d)
            end if
        end if
    end if
end program main

Measured memory_bytes: 2956
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N; cin >> N;
	ll K; cin >> K;
	ll ans = 0;
	for (int i = 1; i <= N;i++) {
		ll x; cin >> x;
		ans += min(2 * abs(x), 2 * abs(K - x));
	}
	cout << ans << endl;
	return 0;
}

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

n1 = S
n2 = 1

if n1 < 10 ** 9:
    print(0, 0, 1, 0, 0, n1)
elif n1 == 10 **18:
    print(0, 0, 10**9, 0, 0, 10**9)
else:
    a = n1 // (10 ** 9) + 1
    d = 10 ** 9
    b = (10 ** 9) - n1 % (10 ** 9)
    c = 1
    print(0, 0, a, b, c, d)

Measured memory_bytes: 3064
import bisect
from functools import lru_cache

six_list = [6 ** i for i in range(7)]
nine_list = [9 ** i for i in range(6)]


@lru_cache(maxsize=1000)
def six_nine(n):
    if n < 6:
        return n
    else:
        six = six_list[bisect.bisect_right(six_list, n) - 1]
        nine = nine_list[bisect.bisect_right(nine_list, n) - 1]
        return min(n // six + six_nine(n % six), 1 + six_nine(n - nine))


if __name__ == '__main__':
    x = int(input())
    print(six_nine(x))

Measured memory_bytes: 38384
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def main():
    A, B, C, D = input()
    for a in ["+", "-"]:
        for b in ["+", "-"]:
            for c in ["+", "-"]:
                s = A + a + B + b + C + c + D
                if eval(s) == 7:
                    print(s + "=7")
                    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = 0,b = 0;
		while(scan.hasNext()){
			a = scan.nextInt();
			b = scan.nextInt();
			int sum = a + b;
			int i = 1,count=0;
			while(true){
				if(sum < i){
					System.out.println(count);
					break;
				}
				i *= 10;
				count++;
			}
			if(scan.hasNext() == false){
				break;
			}
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
#define N 105
using namespace std;

typedef long long ll;
ll n, m, k, z, ans, en, w, b[N], s[2][N], mx[N], go[N], a[N];
int main()
{
	ll i, j, t;
	cin >> n >> m;
	en = 45;
	for (i = 0, j = m; i <= en; i++, j /= 2) {
		b[i] = j % 2;
	}
	for (i = 0; i < n; i++) {
		scanf ("%lld", &t);
		j = t;
		for (k = 0; k <= en; k++, j /= 2) {
			s[j % 2][k]++;
		}
	}
	go[0] = 1;
	for (i = 1; i <= en; i++) go[i] = go[i - 1] * 2;
	for (i =0, k = 1; i <= en; i++, k *= 2) {
		if (i > 0) mx[i] += mx[i - 1];
		mx[i] += (max(s[0][i], s[1][i])) * k;
	}
	for (i = en; i >= 0; i--) {
		if (i > 0) z = mx[i - 1];
		else z = 0;
		if (b[i] == 1) {
			ans = max(ans, w + s[1][i] * go[i] + z);
			w += s[0][i] * go[i];
		} else {
			w += s[1][i] * go[i];
		}
	}
	ans = max(ans, w);
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int sum[1000][1000], i, j;
int main(void)
{
	int a, b, f;
	
	while (scanf("%d %d", &a, &b), a + b != 0){
		f = 0;
		for (;a <= b; a++){
			if (a % 4 == 0){
				if (a % 100 == 0){
					if (a % 400 == 0){
						sum[i][f] = a;
						f++;
					}
				}
				else {
					sum[i][f] = a;
					f++;
				}
			}
		}
		if (f == 0){
			sum[i][0] = -1;
			f++;
		}
		sum[i][f] = -2;
		i++;
	}
	sum[i][0] = -3;
	
	i = 0;
	while (sum[i][0] != -3){
		j = 0;
		while (sum[i][j] != -2){
			if (sum[i][0] == -1){
				printf("NA\n");
				break;
			}
			else {
				printf("%d\n", sum[i][j]);
			}
			j++;
		}
		if (sum[i + 1][0] != -3){
			printf("\n");
		}
		i++;
	}
	
	return 0;
}

Measured memory_bytes: 660
N = int(input())
a = list(map(int,input().split()))
z = 0
ans = 0


for i in a:
    while z == 0:
        if i % 2 == 0:
            i = i // 2
            ans += 1
        else:
            z += 1
    z = 0

print(ans)
        



Measured memory_bytes: 10148
#include <iostream>


int main()
{
	double w, h, x, y;
	std::cin >> w >> h >> x >> y;
	
	std::cout << w * h / 2 << " ";
	if (x == w / 2 && y == h / 2)
	{
		std::cout << 1;
	}
	else
	{
		std::cout << 0;
	}
	std::cout << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n,m;
	cin>>n;
	vi a(n);
	rep(i,0,n) cin>>a[i];
	cin>>m;
	vi b(m),c(m);
	rep(i,0,m) cin>>b[i];
	rep(i,0,m) cin>>c[i];

	sort(all(a));
	vi d=a;
	rep(i,1,n) d[i]+=d[i-1];

	rep(i,0,m){
		int it=upper_bound(all(a),b[i])-a.begin();
		int tmp=0;
		if(it==0) tmp=0;
		else tmp=d[it-1];
		o((tmp>=c[i]?"Yes":"No"));
	}
}

Measured memory_bytes: 10244
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long int a, b, k[100000], l[100000], sum = 0, count = 0;
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		cin >> k[i] >> l[i];
	}
	sort(k, k + a);
	reverse(k, k + a);
	sort(l, l + a);
	reverse(l, l + a);
	for (int i = 0; i < a; ++i) {
		if (l[i] > k[0] && b > 0) {
			sum += l[i];
			b -= l[i];
			++count;
		}
		else break;
	}
	if (b>0&&b%k[0] == 0) count += b / k[0];
	else if(b>0&&b%k[0]!=0) count += b / k[0] + 1;

	cout << count << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int parent(int i){
  return floor(i/2);
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(int argc, char const *argv[]) {
  int count,i;
  int A[100000];

  scanf("%d",&count);
  for (i = 1; i <= count; i++) {
    scanf("%d",&A[i]);
  }
  for (i = 1; i <= count; i++) {
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=count) printf("left key = %d, ",A[left(i)]);
    if(right(i)<=count) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
const int m=1e5+1;
int  a[m];
main(){
    int n; cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    long long ans=0ll;
    for(int i=n-1;i>=0;i--){
        ans+=a[i]/2;
        if(a[i]&1)
            if(i!=0&&a[i-1]){
                ++ans;
                --a[i-1];
                --a[i];
            }
    }   
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>

int main()
{
    int n;
    std::cin >> n;
    uint64_t power = 1;
    for (int i = 0; (i < n); ++i) {
        power = power * (i + 1) % static_cast<uint64_t>(std::pow(10, 9) + 7);
    }
    std::cout << power << std::endl;
    return 0;
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
N=int(input())
L=[int(input()) for i in range(N)]
if a in L and b in L and c in L:
  print('Yes')
elif d in L and e in L and  f in L:
  print('Yes')
elif g in L and h in L and  i in L:
  print('Yes')
elif a in L and d in L and  g in L:
  print('Yes')
elif b in L and e in L and  h in L:
  print('Yes')
elif c in L and f in L and  i in L:
  print('Yes')
elif a in L and e in L and  i in L:
  print('Yes')
elif c in L and e in L and  g in L:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    int n; cin>>n;
    int ans = inf;
    for(int i = 1; i <= sqrt(n);i++)
    {
        if(n%i == 0)
        {
            ans = min(ans , ((i-1) +(n/i - 1) ));
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    long long K;
    cin >> K;

    int pnt = 0;
    for (int i = 0; i < K; ++i) {
        if (S[i] != '1') {
            pnt = i;
            break;
        }
    }

    cout << S[pnt] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int cmpfunc(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int cmpstr(const void* a, const void* b) {
    const char* aa = (const char*)a;
    const char* bb = (const char*)b;
    return strcmp(aa, bb);
}

int main(void){
    int m,n;
    scanf("%d %d",&n,&m);
    int s[n+1],i;
    for (i = 1; i <= n; i++) {
        s[i]=0;
    }
    int ans,ans1;
    for (i = 1; i <= m; i++){
        scanf("%d %d",&ans,&ans1);
        s[ans]++;
        s[ans1]++;
    }
    for (i = 1; i <= n; i++){
        printf("%d\n",s[i]);
    }
    return 0;
}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
s=1
d=[1]*n
d[0]=0
for i in range(1,n):
    if(a[i]<=a[i-1]):
        d[i]=s
        s=s+1
    else:
        d[i]=0
        s=1
print(max(d))
        

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


int main() {
    int k, n, ans = 1e9; 
    cin >> k >> n;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    ans = a[n-1] - a[0];
    for(int i = 0; i < n-1; ++i) {
        ans = min(k-abs(a[i]-a[i+1]), ans);
    }
    
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;
 
fn abc(txy: Vec<(i32, i32, i32)>) -> String {
    let now = 0;
    let pos_sum = 0;
 
    for &(t, x, y) in txy.iter() {
        let time = t - now;
        let dist = x + y - pos_sum;
        if ((time % 2) != (dist % 2)) || (time < dist) {
            return "No".to_string();
        }
        let now = t;
        let pos_sum = x + y;
    }
    return "Yes".to_string();
}
 
 
fn main() {
    //assert_eq!(abc(9, 45_000), vec![4, 0, 5]);
    //assert_eq!(abc(20, 196_000), vec![-1, -1, -1]);
    //assert_eq!(abc(1_000, 1_234_000), vec![2, 54, 944]);
    //assert_eq!(abc(2_000, 20_000_000), vec![2_000, 0, 0]);
 
    let n: i32 = read();
    let txy: Vec<(i32, i32, i32)> = (0..n).map(|_| (read(), read(), read())).collect();
 
 
    let result = abc(txy);
 
    println!("{}", result);
}
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
  ans += B[A[i]-1]
  if ( i != 0):
    if ((A[i] - A[i-1]) == 1):
      ans += C[A[i-1]-1]
print(ans)
    

Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

struct UnionFind {
	VI par;
	UnionFind(int N) :par(N) {
		REP(i, N)par[i] = i;
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void merge(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}
	bool issame(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M, K;
	cin >> N >> M >> K;
	UnionFind uni(N);
	VI fri(N, 0);
	VI ans(N, 0);
	VI cnt(N, 1);

	REP(i, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		int tmp = cnt[uni.root(a)];
		bool f = uni.issame(a, b);
		if(!f)uni.merge(a, b);
	
		fri[a]++;
		fri[b]++;
		if (!f) {
			cnt[uni.root(b)] += tmp;
		}
		//cout << uni.root(a) << endl;
	}

	REP(i, N) {
		ans[i] = cnt[uni.root(i)] - fri[i] - 1;
		//cout << cnt[uni.root(i)] << " "<<uni.root(i)<<endl;
	}

	REP(i, K) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		if (uni.issame(a, b)) {
			ans[a]--;
			ans[b]--;
		}
	}

	REP(i, N)cout << ans[i] << " ";
	cout << endl;
	return 0;
}



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

#define int long long

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 2e5 + 5;
int a[N], f[N], n, k;

bool check(int x)
{
	int res = 0;
	for (int i = 1; i <= n; ++i) 
		res += max(0LL, a[i] - x / f[i]);
	return res <= k;
}

signed main()
{
	n = read();
	k = read();
	for (int i = 1; i <= n; ++i) a[i] = read();
	for (int i = 1; i <= n; ++i) f[i] = read();
	sort(a + 1, a + n + 1);
	sort(f + 1, f + n + 1);
	reverse(f + 1, f + n + 1);
	
	int l = 0, r = 1e12;
	while (l < r)
	{
		int mid = l + r >> 1;
		if (check(mid)) r = mid;
			else l = mid + 1;
	}
	printf("%lld\n", l);
	
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
int main()
{
    ll n, m;
    cin >> n >> m;
    if (n == m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

string s;
int c[100005];

void countLeft(int idx) {
  int i = idx - 1, l = 1, r = 1;
  bool right = true;

  while (i >= 0 && s[i] == 'R') {
    if (right) r++;
    else l++;
    
    i--;
    right = !right;
  }

  c[idx] = l;
  c[idx+1] = r;
}

void countRight(int idx) {
  int i = idx + 2, l = 0, r = 0;
  bool left = true;

  while (i < s.length() && s[i] == 'L') {
    if (left) l++;
    else r++;

    i++; left = !left;
  }
  c[idx] += l;
  c[idx + 1] += r;
}

int main() {
  cin >> s;

  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'R' && s[i+1] == 'L') {
      countLeft(i);
      countRight(i);

      i++;
    }
  }

  for (int i = 0; i < s.length(); i++) {
    cout << c[i] << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n+2];
  a[0]=0;
  a[n+1]=0;
  rep(i,0,n) cin>>a[i+1];
  int sum[n+2];
  sum[0]=0;
  rep(i,0,n+1){
    sum[i+1]=sum[i]+abs(a[i+1]-a[i]);
  }
  
  int sum2[n+2];
  sum2[0]=0;
  rep(i,0,n+1){
    sum2[i+1]=sum2[i]+abs(a[n+1-i]-a[n-i]);
  }
  
  rep(i,1,n+1){
    cout<<sum[i-1]+sum2[n-i]+abs(a[i-1]-a[i+1])<<endl;
  }
}

Measured memory_bytes: 2432
x1, y1, x2, y2 = map(int, input().split())
 
x3 = x2 + (y1 - y2)
y3 = y2 - (x1 - x2)
x4 = x3 + (x1 - x2)
y4 = y3 + (y1 - y2)
 
print(x3, y3, x4, y4)

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

int main()
{
    int N;
    cin >> N;
    vector<int> A;
    unsigned long long answer = 0;
    for (int i = 0; i < 3 * N; ++i)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.rbegin(), A.rend());
    for (int i = 0; i < N; ++i)
    {
        answer += A[2 * i + 1];
    }
    cout << answer << endl;
}

Measured memory_bytes: 5360
# -*- coding: utf-8 -*-
n = int(input())
x = list(map(int, input().split()))

left = min(x)
right = max(x)

min_cost = 100000000000000
min_pos=-1

for i in range(left,right+1):
  cost=0
  for j in range(n):
    cost = cost + (x[j]-i)*(x[j]-i)
  if min_cost>cost:
    min_cost=cost
    min_pos=i

print(min_cost)

Measured memory_bytes: 3064
H,W = list(map(int,input().split()))
N=H*W

#壁のノード
wall=[]
for h in range(H):
    for w_idx,w in enumerate(list(input())):
        if w == '#':
            wall.append(W*h+w_idx+1)
#道のノード        
path=[_ for _ in range(1,N+1) if _ not in wall]

#隣接リスト
ad = {}
for n in range(N):
    ad[n+1]=[]
    
for n in range(N):
    n=n+1
    if n not in wall:
        up = n-W
        if up > 0 and up not in wall:
            ad[n].append(up)
            
        down = n+W
        if down <= N and down not in wall:
            ad[n].append(down)
            
        left = n-1
        if n % W != 1 and left not in wall and left > 0:
            ad[n].append(left)
        
        right = n+1
        if n % W != 0 and right not in wall:
            ad[n].append(right)      

from collections import deque

def BFS(start):
    que = deque([start])
    visit = deque([])

    color = {}
    for n in range(N):
        color[n+1] = -1
    color[start] = 0

    depth = {}
    for n in range(N):
        depth[n+1] = -1

    depth[start] = 0
    while len(que) > 0:
        start = que[0]
        for v in ad[start]:
            if color[v] == -1:
                que.append(v)
                color[v] = 0
                depth[v] = depth[start]+1

        color[start] = 1
        visit.append(que.popleft())

    return depth[start]

ans=-1
for start in path:
    ans_=BFS(start)
    if ans < BFS(start):
        ans = ans_
    
#     print(start,ans_)
    
print(ans)

Measured memory_bytes: 9556
parseInt(x) = parse(Int,x)

parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
#readline() |> split |> parseMap
function main()
    a = parseInt(readline()) 
    b = parseInt(readline())
    h = parseInt(readline())
    println(Int((a+b)*h/2))
end

main()


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

ll nCr(ll n, ll r) {
    ll a = 1;
    for (ll i = 1; i <= r; i++)
    {
        a *= n--;
        a /= i;
    }
    return a;
}

int main() {
    int n;
    cin >> n;
    map<char, int> mp;
    mp['M'] = 0;
    mp['A'] = 0;
    mp['R'] = 0;
    mp['C'] = 0;
    mp['H'] = 0;
    rep(i, n) {
        string s;
        cin >> s;
        if (s[0] == 'M') mp[s[0]]++;
        else if (s[0] == 'A') mp[s[0]]++;
        else if (s[0] == 'R') mp[s[0]]++;
        else if (s[0] == 'C') mp[s[0]]++;
        else if (s[0] == 'H') mp[s[0]]++;
    }
    int m, a, r, c, h, cnt;
    m = mp.at('M');
    a = mp.at('A');
    r = mp.at('R');
    c = mp.at('C');
    h = mp.at('H');
    cnt = m + a + r + c + h;
    
    ll ans;
    ans = nCr(cnt, 3);

    if (m > 1) {
        ans -= nCr(m, 2) * (cnt - m) + nCr(m, 3);
    }
    if (a > 1) {
        ans -= nCr(a, 2) * (cnt - a) + nCr(a, 3);
    }
    if (r > 1) {
        ans -= nCr(r, 2) * (cnt - r) + nCr(r, 3);
    }
    if (c > 1) {
        ans -= nCr(c, 2) * (cnt - c) + nCr(c, 3);
    }
    if (h > 1) {
        ans -= nCr(h, 2) * (cnt - h) + nCr(h, 3);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3416
/*2019/08/25 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int llasc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
int lldesc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
/*
int asc_t(const void *a,const void *b){return ((struct_t*)a)->member - ((struct_t*)b)->member;}
int desc_t(const void *a,const void *b){return ((struct_t*)b)->member - ((struct_t*)a)->member;}
*/

int main(){
    char s[200],t[200];

    scanf("%s",s);
    scanf("%s",t);
    int cnt=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]){
            cnt++;
        }
    }

    printf("%d\n",cnt);

    return 0;
}

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

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

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<int>vec(N,1);
  rep(i,K){
    int d;
    cin >> d;
    
    rep(j,d){
      int A;
      cin >> A;
      vec.at(A-1) = 0;
    }
  }
  int ans = 0;
  rep(i,N) ans += vec.at(i);
  
  cout << ans << endl;
}

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

ans = 0

while len(S) > 1:
    if S[0] == S[-1]:
        S.pop(0)
        S.pop(-1)
    elif S[0] == 'x':
        ans += 1
        S.pop(0)
    elif S[-1] == 'x':
        ans += 1
        S.pop(-1)
    else:
        ans = -1
        break

print(ans)


Measured memory_bytes: 4084
#B問題

N = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(0,len(A)):
    for j in range(i+1,len(A)):
        for k in range(j+1,len(A)):
            if A[i] + A[j] > A[k] and A[j] + A[k] > A[i] and A[k] + A[i] > A[j] and A[i] != A[j] and A[j] != A[k] and A[k] != A[i] :
                ans += 1
print(ans)

Measured memory_bytes: 9144
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
     
	int a,b,n;
	
	while(cin>>a>>b>>n){
		int s=0;
		a%=b;
		for(int i=1;i<=n;i++){
			a*=10;
			s+=a/b;
			a%=b;
		}
		
		cout<<s<<endl;
	}

}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
using namespace std;
int n,m,ans=0;
vector<int> v[55];
vector<pair<int,int> > store;
bool used[55];
bool check(int now,int lim1,int lim2){
	used[now]=true;
	bool flag=0;
	for(int i=1;i<=n;i++){
		if(used[i]==0){flag=1;break;
		}
	}
	if(!flag)return true;
	for(int i=0;i<(int)v[now].size();i++){
		int next=v[now][i];
		if((now==lim1&&next==lim2)||(now==lim2&&next==lim1))continue;
		if(!used[next]&&check(next,lim1,lim2))return true;
	}
	return false;
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
		store.push_back(make_pair(a,b));
	}
	for(int i=0;i<m;i++){
		auto p=store[i];
		int e1=p.first,e2=p.second;
		if(!check(1,e1,e2)){
			ans++;
		}
		for(int i=0;i<55;i++)used[i]=0;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#define ll long long
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define fd(i, l, r) for (int i = r; i >= l; i--)
using namespace std;
inline ll read()
{
	ll x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}
double p,q,dp[1050][1050];
int ip;
int main()
{
	char sb[1500];
	scanf("%s",sb+1);
	int n = strlen(sb+1);
	fo(i,1,n){
		if(sb[i]=='1') sb[i] ='9';
		else if(sb[i]=='9') sb[i] = '1';
	}
	cout<<sb+1;
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<string.h>
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	int sum=0;
	for(int i=0;i<a;i++){
		int p;
		cin>>p;
		sum+=p;
		if(sum>b){
			cout<<i+1;
			return 0;
		}
	}
	cout<<a+1;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int x,y;
	for(;;){
		scanf("%d %d",&x,&y);
		if((x == 0)&&(y == 0)){
			break;
		}
		if(x>y){
			printf("%d %d\n",y,x);
		}else{
			printf("%d %d\n",x,y);
		}
	}
	return 0;
}


Measured memory_bytes: 1836
require "prime"
MOD = 1000000007

def nCk(n,k)
	return fact(n)*mypow(fact(k),MOD-2)%MOD*mypow(fact(n-k),MOD-2)%MOD
end

def mypow(a,m)
	return a**m % MOD if m < 4
	c, res = a, 1
	while(m>0);res = res * c % MOD if m.odd?;c, m = c * c % MOD, m >> 1;end
	return res
end

def fact(n)
	res = 1
	Prime.each(n) do |pr|
		m, q, e = n, pr, 0
		e, q = e+m/q, q*pr while q <= m
		res = res *  mypow(pr, e) % MOD
	end
	return res
end

def f(x)
	return (x**3-x)/6%MOD
end

N, M, K = gets.split.map(&:to_i)
puts (N * N * f(M) + M * M * f(N)) % MOD * nCk(N*M-2, K-2) % MOD


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

int main(){
    int w; //長方形の横の長さ
    int h; //長方形の縦の長さ
    int x,y; //面積を分けるときに通る点
    cin >> w >> h >> x >> y;

    int way; //面積を分ける方法
    if(x+x == w && y+y == h){
        way = 1;
    }else{
        way = 0;
    }

    cout << double(w)*double(h)/2 << " " << way << endl;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
c=[[int(i) for i in input().split()] for i in range(10)]
Points=[]
for i in range(0,10):
  if i==1:
    Points.append(0)
  else:
    Roots=[[i]]
    Roots_finished=[]
    for R in Roots:
      for j in range(10):
        if R[-1]==1:
          Roots_finished.append(R)
          break
        elif j in R:
          pass
        elif j==1:
          R_kari=list(R)
          R_kari.append(1)
          Roots.append(R_kari)
        elif c[R[-1]][j]<c[R[-1]][1]:
          R_kari=list(R)          
          R_kari.append(j)
          Roots.append(R_kari)
    S=1000000000000
    for r in Roots_finished:
      S_kari=0
      j=r[0]
      for i in r:
        S_kari+=c[j][i]
        j=i
      if S>S_kari:
        S=S_kari
    Points.append(S)
Magic_Power=0
for i in range(H):
  for j in input().split():
    if int(j)==-1:
      j=1
    Magic_Power+=Points[int(j)]
print(Magic_Power)   

      
      
      
      
    
    
    
  

Measured memory_bytes: 4780
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let ab: Vec<i32> = (0..6).map(|_| read()).collect();
    let mut count = [0; 4];
    for ab_i in ab {
        count[ab_i as usize - 1] += 1;
    }
    println!(
        "{}",
        if count.iter().all(|&x| x > 0 && x != 3) {
            "YES"
        } else {
            "NO"
        }
    );
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
import java.util.*;

import static java.lang.System.*;

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

        Integer[] nums = new Integer[N + 1];
        Arrays.fill(nums, 0);
        for (int i = 0; i < N; i++) {
            nums[sc.nextInt()]++;
        }

        Arrays.sort(nums, Comparator.reverseOrder());

        int cnt = 0;
        for (int i = K; i < N + 1; i++) {
            cnt += nums[i];
        }

        out.println(cnt);
    }
}

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

int m=2019;

ll power(ll a,ll b)
{
    if(b==1)
    {
        return a;
    }
    else if(b&1)
    {
        return (a%m*power((a%m*a%m)%m,b/2)%m)%m;
    }
    else 
    return power((a%m*a%m)%m,b/2)%m;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  #ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
  freopen ("output.txt", "w", stdout);
  #endif 
  
  string s;
  cin>>s;
  ll n=s.size(),mod[n];
  mod[n-1]=s[n-1]-'0';

  for(ll i=n-2;i>=0;i--)
  {
      mod[i]=(mod[i+1]%m + ((s[i]-'0')%m*power(10,n-1-i)%m)%m)%m;
  } 
   



  map<ll,ll> mp;
  ll ans=0;

  for(ll i=n-1;i>=0;i--)
  {
      if(mod[i]==0)
      {
          ans+=1;
          if(mp.find(0)!=mp.end())
          {
             ans+=mp[0];
          }
          mp[mod[i]]++;
      }
      else 
      {
          if(mp.find(mod[i])!=mp.end())
          {
             ans+=mp[mod[i]];
          }
          mp[mod[i]]++;
      }
  }
  cout<<ans<<endl;


}

Measured memory_bytes: 5340
#include<bits/stdc++.h>
#define up(l,r,i) for(int i=l;i<=r;i++)
#define dn(l,r,i) for(int i=l;i>=r;i--)
using namespace std;

typedef long long LL;
const int INF =2147483647;
int qread(){
	int w=1,c,ret;
	while((c=getchar())> '9'||c< '0')
	w=(c=='-'?-1:1); ret=c-'0';
	while((c=getchar())>='0'&&c<='9')
	ret=ret*10+c-'0';
	return ret*w;
}
const int MAXN =1e5+3;
int n,cnt[MAXN],tot;
int main(){
	dn(n=qread(),1,i) cnt[qread()]++;
	up(1,MAXN-1,i) if(cnt[i]) tot+=cnt[i]-1;
	printf("%d\n",n-tot-(tot&1));
	return 0;
}


Measured memory_bytes: 640