akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int xMinusA = x - a;
    int xa = Math.abs(xMinusA);
    
    int xMinusB = x - b;
    int xb = Math.abs(xMinusB);
    
    if (xa > xb) {
      System.out.println("B");
    } else if (xa < xb) {
      System.out.println("A");
    }
  }
}

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

const int MAXN = 1e5;

int dp[MAXN];
vi G[MAXN];

int run(int u)
{
	if (dp[u] != -1) return dp[u];
	dp[u] = 0;
	for (auto v : G[u])
		dp[u] = max(dp[u], 1 +run(v));
	return dp[u];
}

int		main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int N, M;
	read2(N, M);
	FOR(i,0, N) dp[i] = -1;

	FOR(i, 0, M)
	{
		int u, v;
		read2(u, v);
		--u, --v;
		G[u].pb(v);
	}
	
	int ans(0);
	FOR(i,0, N)
		ans = max(ans, run(i));
	pnl(ans);
}



Measured memory_bytes: 7552
#include <iostream>
#include<stdio.h>
#define MAXSIZE 101
#define PI 3.141592653589
using namespace std;
int main(){

  int r,c;
  std::cin >> r>>c;
  int a[MAXSIZE][MAXSIZE]={0};
  for(int i=0;i<r;i++){
    int sum1=0;
    for(int j=0;j<c;j++){
      std::cin >> a[i][j];
      sum1+=a[i][j];
    }
    a[i][c]=sum1;
  }

  for(int j=0;j<=c;j++){
    int sum2=0;
    for(int i=0;i<r;i++){
      sum2+=a[i][j];
    }
    a[r][j]=sum2;
  }

  for(int i=0;i<=r;i++){
    for(int j=0;j<c;j++){
      std::cout << a[i][j]<<" ";
    }

    std::cout <<a[i][c] << '\n';
  }

}

Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, a[212345], b[212345];
    cin >> n;
    REP(i, n)
    {
        cin >> a[i];
        b[i] = a[i];
    }

    sort(b, b + n);

    REP(i, n)
    {
        if (a[i] == b[n - 1])
            cout << b[n - 2] << endl;
        else
            cout << b[n - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
// https://atcoder.jp/contests/abc136/tasks/abc136_b
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}


///  [a, b) and [c, d)
fn intersect(a: i32, b: i32, c: i32, d: i32) -> i32 {
    let from = max(a, c);
    let to = min(b, d);
    max(0, to-from)
}

fn main() {
    input! {
        n: i32
    };

    let mut total = 0;
    let mut from = 1;
    let mut w = 1;
    while from <= n+1  {
        let to = from * 10;
        total += w * intersect(1, n+1, from, to);

        w ^= 1;
        from *= 10;
    }
    println!("{}", total);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  string x;
  vector<string>c(n+1);
  for(int i=0; i<n; i++){
    cin >> x;
    sort(x.begin(),x.end());
    c[i]=x;
  }
  c[n]="zzzzzzzzzzz";
  
  sort(c.begin(),c.end());
  
  int64_t ans=0;
  int64_t count=1;
  
  for(int i=0; i<n; i++){
    if(c[i]==c[i+1]) count++;
    
    else{
      ans+=count*(count-1)/2;
      count=1;
    }
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define endl '\n'

 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll N;
  cin >> N;
  string s;
  vector<array<ll,3>> L, R;
  for (int ii = 0; ii < N; ++ii) {
    cin >> s;
    int n = s.length();
    int open = 0;
    int all_l = 0, all_r = 0;
    for (int i = 0; i < n; ++i) {
      if (s[i] == '(') {
        ++open;
      } else {
        if (--open < 0) {
          open = 0;
          ++all_r;
        }
      }
    }
    int close = 0;
    for (int i = n-1; i >= 0; --i) {
      if (s[i] == ')') {
        ++close;
      } else {
        if (--close < 0) {
          close = 0;
          ++all_l;
        }
      }
    }
    if (all_l > all_r) {
      L.push_back({all_l, all_r, ii});
    } else {
      R.push_back({all_l, all_r, ii});
    }
  }

  sort(L.begin(), L.end(), [](const auto& a, const auto& b) {
                             return a[1] < b[1];
                           });
  sort(R.begin(), R.end(), [](const auto& a, const auto& b) {
                             return a[0] > b[0];
                           });
  deque<int> dq;
  bool good = true;
  int o = 0;
  for (int i = 0; i < L.size(); ++i) {
    o -= L[i][1];
    if (o < 0) good = false;
    o += L[i][0];
  }
  for (int i = 0; i < R.size(); ++i) {
    o -= R[i][1];
    if (o < 0) good = false;
    o += R[i][0];
  }

  if (good && o == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 26812
n=int(input())
lists=[]
for i in range(n):
  lists.append(input())
AC=lists.count('AC')
WA=lists.count('WA')
TLE=lists.count('TLE')
RE=lists.count('RE')
print('AC x '+str(AC))
print('WA x '+str(WA))
print('TLE x '+str(TLE))
print('RE x '+str(RE))

Measured memory_bytes: 16132
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}


int main() {
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  cout<<((60*h2+m2)-(60*h1+m1))-k<<endl;
  return 0;
}

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

using namespace std;

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

long long lcm(long long a, long long b)
{
  if (b > a) swap(a, b);
  return a / gcd(a, b) * b;
}

int main()
{
  int N;
  cin >> N;
  long long l = 1;
  for (int i = 0; i < N; i++) {
    long long T;
    cin >> T;
    l = lcm(l, T);
  }
  cout << l << endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	// 10, 2, 5
	as := make([][]int, n)
	for i := range as {
		sc.Scan()
		t := sc.Text()
		if sp := strings.Split(t, "."); len(sp) > 1 {
			bt := strings.TrimRight(sp[1], "0")
			if len(bt) > 0 {
				k := -len(bt)
				a, _ := strconv.Atoi(sp[0] + bt)
				l, m := check(a)
				as[i] = []int{k, l, m}
				continue
			}
			t = sp[0]
		}
		lt := len(t)
		t = strings.TrimRight(t, "0")
		k := lt - len(t)
		a, _ := strconv.Atoi(t)
		l, m := check(a)
		as[i] = []int{k, l, m}
	}
	b := make(map[int][][]int)
	for i := -9; i <= 8; i++ {
		b[i] = make([][]int, 20)
		for j := 0; j < 20; j++ {
			b[i][j] = make([]int, 20)
		}
	}
	for _, v := range as {
		k, l, m := v[0], min(v[1], 19), min(v[2], 19)
		b[k][l][m]++
	}
	var ans int
	for k1 := -9; k1 <= 8; k1++ {
		for l1 := 0; l1 < 20; l1++ {
			for m1 := 0; m1 < 20; m1++ {
				for k2 := -9; k2 <= 8; k2++ {
					for l2 := 0; l2 < 20; l2++ {
						for m2 := 0; m2 < 20; m2++ {
							if k1 == k2 && l1 == l2 && m1 == m2 {
								if k1+k2+min(l1+l2, m1+m2) >= 0 {
									d := b[k1][l1][m1] * (b[k1][l1][m1] - 1)
									ans += d
								}
							} else {
								if k1+k2+min(l1+l2, m1+m2) >= 0 {
									d := b[k1][l1][m1] * b[k2][l2][m2]
									ans += d
								}
							}
						}
					}
				}

			}
		}
	}
	fmt.Println(ans / 2)
}

func check(n int) (l, m int) {
	for n > 0 && n%2 == 0 {
		l++
		n /= 2
	}
	for n > 0 && n%5 == 0 {
		m++
		n /= 5
	}
	return
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 23708
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 long long int A;
 long long int B;
 long long int K;
 cin >> A >> B >> K;
 if(A>=K)cout << A-K << " " << B << endl;
 else if(A+B-K>=0){
     cout << 0 << " " << A+B-K << endl;
 }
 else{cout << 0 << " " << 0 << endl;}
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=900;
unsigned long long seedx = 233;
unsigned long long seedy = 23333;
struct HashString {
	unsigned long long xp[maxn];
	unsigned long long yp[maxn];
	unsigned long long H[maxn][maxn];
	char s[maxn][maxn];
	int x,y;
	void init(int n, int m) {
		xp[0] = yp[0] = 1;
		x = n,y = m;
		for(int i = 1; i <= x; i++) xp[i] = xp[i - 1]*seedx;
		for(int i = 1; i <= y; i++) yp[i] = yp[i - 1]*seedy;
		return;
	}
	void initHash() {
		for(int i = 0; i < x; i++) {
			H[i][0] = s[i][0] - 'a' + 1;
			for(int j = 1; j < y; j++)
				H[i][j] = H[i][j - 1]*seedy + s[i][j] - 'a' + 1;
		}
		for(int i = 1; i < x; i++)
			for(int j = 0; j < y; j++)
				H[i][j] += H[i - 1][j]*seedx;
		return;
	}
	unsigned long long askHash(int x1, int y1, int x2, int y2) {
		unsigned long long ret = H[x2][y2];
		if(x1 > 0) ret -= H[x1 - 1][y2]*xp[x2 - x1 + 1];
		if(y1 > 0) ret -= H[x2][y1 - 1]*yp[y2 - y1 + 1];
		if(x1 > 0 && y1 > 0) ret += H[x1 - 1][y1 - 1]*xp[x2 - x1 + 1]*yp[y2 - y1 + 1];
		return ret;
	}
} s1,s2;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	s1.init(2*n,2*n);
	s2.init(2*n,2*n);
	for(int i=0; i<n; i++)cin>>s1.s[i];
	for(int i=n; i<2*n; i++) {
		for(int j=0; j<n; j++) {
			s1.s[j][i]=s1.s[j][i-n];
		}
	}
	for(int i=n; i<2*n; i++) {
		for(int j=0; j<2*n; j++) {
			s1.s[i][j]=s1.s[i-n][j];
		}
	}
	for(int i=0; i<2*n; i++) {
		for(int j=0; j<2*n; j++) {
			s2.s[i][j]=s1.s[j][i];
		}
	}
	s1.initHash();
	s2.initHash();
	int ans = 0;
	for(int i = 0; i<n; i++) {
		for(int j = 0; j<n; j++) {
			if(s1.askHash(i,j,i+n-1,j+n-1) == s2.askHash(j,i,j+n-1,i+n-1))
				ans ++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13056
#include <stdio.h>

int main(){
	int N;
	scanf("%d",&N);
	char A[N+1];
	int lol=1;
	scanf("%s",A);
	if(N%2==0){
		for(int i=0;i<N/2;i++){
			if(A[i]!=A[(N/2)+i]){
				lol=0;
			}
		}
	}else if(N%2==1){
		lol=0;
	}
	if(lol==0){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
return 0;
}

Measured memory_bytes: 1600
package main

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

var sc *bufio.Scanner

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

const MOD = 1000000007

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()

	primeFactor := make([]int, n+1)
	for i := 2; i <= n; i++ {
		iCopy := i
		for j := 2; j <= n; j++ {
			for iCopy%j == 0 {
				iCopy /= j
				primeFactor[j]++
			}
		}
	}

	ans := 1
	for _, pf := range primeFactor {
		ans = (ans * (pf + 1)) % MOD
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#! /usr/bin/env perl
use strict;
use warnings;


sub gcd{ #最大公約数
    my ($a,$b) = @_;
    if($b == 0){
        return $a;
    }

    return gcd($b, $a%$b);
}

sub lcm{ #最小公倍数
    my ($a,$b) = @_;
    return $a * $b / gcd($a, $b);
}



my $input = <>;
chomp $input;

my ($a,$b) = split / /,$input;

print(lcm($a,$b));

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

int main() {
  int n, m;
  cin >> n >> m;

  vector<pair<long int, int>> shop(n);
  for (int i = 0; i < n; i++) cin >> shop[i].first >> shop[i].second;

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

  long int money = 0;
  int num = 0;
  for (int i = 0; i < n; i++) {
    if (num + shop[i].second < m) {
      num += shop[i].second;
      money += shop[i].first * shop[i].second;
    } else if (num + shop[i].second >= m) {
      money += shop[i].first * (m - num);
      cout << money << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
int main(){
  int cnt = 0;
  int maxcnt = 0;
  string in;
  cin >> in;
  for(auto &c : in){
    if (c == 'A' || c == 'C' || c == 'G' || c == 'T'){
      cnt++;
      maxcnt = (maxcnt < cnt) ? cnt : maxcnt;
    }else{
      cnt=0;
    }
  }
  cout << maxcnt;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 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; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  vi ans(100,0);

  rep(i,100){
    if((a<=i&&i<b) &&(c<=i&&i<d)) ans[i]++;
  }

  cout << accumulate(ans.begin(), ans.end(), 0) << endl;
  return 0;
} 

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

    int N;
    int[] a;

    public void swap(int[] array,int a,int b) {
        int tmp = array[a];
        array[a] = array[b];
        array[b] = tmp;
    }

    public void solve() {
        N = nextInt();
        a = new int[N];
        for(int i = 0;i < N;i++){
            a[i] = nextInt();
        }

        int ans = 0;

        for(int i = 0;i < N;i++){

            if (a[i] == i + 1) {
                if (i == N - 1) {
                    swap(a, i, i - 1);
                } else {
                    swap(a, i + 1, i);
                }
                ans++;
            }
        }

        out.println(ans);

    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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

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

using namespace std;

long long dp[100005];

int main(){
    int N, W;
    cin >> N >> W;
    fill(dp+1, dp+100000+5, INT_MAX/2-5);
    for(int i = 1; i<=N; i++){
        int wt, v;
        cin >> wt >> v;
        for(int j = 100000; j>=v; j--){
            dp[j] = min(dp[j], dp[j-v]+wt);
        }
    }
    int best = 0;
    for(int i = 1; i<=100000; i++){
        if(dp[i] <= W){
            best = i;
        }
    }
    cout << best << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int a;
    int b;
    while(1)
    {
        scanf("%d",&a);
        scanf("%d",&b);
        if(a==0 && b==0) break;
        if(a<b)
        {
            printf("%d %d\n",a,b);
        }
        else
        {
            printf("%d %d\n",b,a);
        }
    }
    return 0;
}

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


void solve(long long A, long long B, long long C, long long D, long long E){
    int ans = 1e9;
    vector<ll> v = {A, B, C, D, E};
    sort(v.begin(), v.end());
    do {
        int now = 0;
        for(int i = 0;i < 5;i++){
            now += (now % 10 == 0 ? 0 : 10 - now%10);
            now += v[i];
        }
        ans = min(ans, now);
    }while(next_permutation(v.begin(), v.end()));
    cout<<ans<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    long long E;
    scanf("%lld",&E);
    solve(A, B, C, D, E);
    return 0;
}


Measured memory_bytes: 256
/*
* @Author: AsilenceBTF
* @Buff: ︿(￣︶￣)︿  芜湖塔台 起飞
* @Date: 2019-06-20 09:22:24
 * @LastEditTime: 2020-09-16 16:48:57
*/

#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define ALL(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
#define debug(x) cout << "##### " << x << endl; 
typedef long long ll;

// #define cin in
// #define cout out
// ifstream in("in.txt");
// ofstream out("out.txt");

const int MOD = 1e9 + 7;
const int N = 2e5 + 105;
ll qpower(ll a, ll b){
    ll ans = 1;
    while(b){
        if(b & 1) ans = ans * a %MOD;
        a = a * a %MOD;
        b >>= 1;
    }
    return ans;
}
int main(){
    ll n;
    cin >> n;
    if(n == 1){
        cout << 0 << endl;
    }else{
        cout << (qpower(10, n) - (qpower(9, n) + qpower(9, n) - qpower(8, n)) + MOD + MOD + MOD + MOD + MOD) % MOD << endl;
    }
}

Measured memory_bytes: 3612
N,M=map(int, input().split())
L=sorted(list(map(int,input().split())))
ans=0
L2=[]

for i in range(M-1):
    L2.append(L[i+1]-L[i])

L2.sort()

for i in range(M-N):
    ans=ans+L2[i]

print(ans)

Measured memory_bytes: 13968
inf=Float::INFINITY
	reads_i=lambda{||gets.chomp.split(" ").map(&:to_i)}
	num=reads_i[]
	idx=0
	k=num[1]
	seq=Array.new(100000){0}
	for i in 0..num[0]-1
		data=reads_i[]
		data[0]-=1
		seq[data[0]]+=data[1]
	end
	
	prog=true
	for i in 0..seq.length-1
		idx+=seq[i]
		if idx>=k && seq[i]>0 && prog==true
				puts(i+1);
				prog=false;
		end
	end

Measured memory_bytes: 2556
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        	int r = scan.nextInt();
        	int c = scan.nextInt();
        	int [][]sheet;
        	sheet = new int[(r+1)][(c+1)];
        	int sheetr,sheetc;

        	for(sheetr = 0; sheetr < r; sheetr++){
        		for(sheetc = 0; sheetc < c; sheetc++){
        		sheet[sheetr][sheetc] = scan.nextInt();
        		}
        	}
        	for(sheetr = 0; sheetr < r; sheetr++){
        		for(sheetc = 0; sheetc < c; sheetc++){        			
        		sheet[sheetr][c] += sheet[sheetr][sheetc];
        		}
        	}
        	for(sheetc = 0; sheetc <= c; sheetc++){
        		for(sheetr = 0; sheetr < r; sheetr++){
        		sheet[r][sheetc] += sheet[sheetr][sheetc];
        		}
        	}
        	for(sheetr = 0; sheetr <= r; sheetr++){
        		for(sheetc = 0; sheetc <= c; sheetc++){ 
        			if(sheetc < c){
        				System.out.print(sheet[sheetr][sheetc]+" ");
        			}
        			else if(sheetc == c){
        			System.out.print(sheet[sheetr][sheetc]);
        			}
        			if(sheetc == c){
        				System.out.print("\r\n");
        			}
        		}
        	}
    }
}

Measured memory_bytes: 41192
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  #define int ll
  int n,m,k;cin>>n>>m>>k;
  vector<int> a(n);rep(i,n)cin>>a[i];
  vector<int> b(m);rep(i,m)cin>>b[i];

  int cnt = 0;
  int sumA = 0;
  rep(i,n){
    if(sumA+a[i] <= k){
      sumA += a[i];
      cnt++;
    }
    else break;
  }

  int ans = cnt;
  int cntB = 0;
  int sumB = 0;
  for(int i = cnt;i >= 0;--i){
    if(i != cnt){
      sumA -= a[i];
    }
    for(int j = cntB;j < m;++j){
      if(sumA+sumB+b[cntB] <= k){
        sumB += b[cntB++];
      }
      else break;
    }
    if(chmax(ans,cntB+i));
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),a[300005];
struct Fenwick_Tree{
	int bit[300005];
	Fenwick_Tree(){fill0(bit);}
	inline void add(int x){
		for(int i=x;i<=n;i+=(i&(-i)))	bit[i]++;
	}
	inline int sum(int x){
		int ans=0;
		for(int i=x;i;i-=(i&(-i)))	ans+=bit[i];
		return ans;
	}
};
inline vector<int> calc(vector<int> t){
	vector<int> v;Fenwick_Tree Bit;
	foreach(it,t){
		v.push_back(Bit.sum(n)-Bit.sum(*it));
		Bit.add(*it);
	}
	return v;
}
signed main(){
	fz(i,1,n)	a[i]=read();
	for(int i=1;i<=n;i+=2)	if(a[i]&1^1)	return puts("No"),0;
	for(int i=2;i<=n;i+=2)	if(a[i]&1)		return puts("No"),0;
	vector<int> b,b1,b2;
	for(int i=1;i<=n;i+=2)	b1.push_back(a[i]);	
	for(int i=2;i<=n;i+=2)	b2.push_back(a[i]);	
	for(int i=1;i<=n;i++)	b.push_back(a[i]);	
	vector<int> c=calc(b),c1=calc(b1),c2=calc(b2);
	int sum1=0,sum2=0,sum3=0;
	foreach(it,c)	sum1+=*it;
	foreach(it,c1)	sum2+=*it;
	foreach(it,c2)	sum3+=*it;
	if(sum1==(sum2+sum3)*3)	puts("Yes");
	else					puts("No");
	return 0;
}

Measured memory_bytes: 12104
#include <bits/stdc++.h>
#define lol long long
template<class A,class B>inline bool chmax(A &a,const B &b){return(b>a&&(a=b,true));}
template<class A,class B>inline bool chmin(A &a,const B &b){return(b<a&&(a=b,true));}
using namespace std;
lol mod=1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >>n>>m;
  vector<int> cost(m),key(m,0);
  for(int i=0;i<m;i++){
    int a,b;
    cin >>a>>b;
    cost[i]=a;
    for(int j=0;j<b;j++){
      int c;cin >>c;
      c--;
      key[i]|=(1<<c);
    }
  }
  vector<vector<lol> > dp(m+1,vector<lol>(1<<n,mod));
  dp[0][0]=0;
  for(int i=0;i<m;i++){
    for(int bit=0;bit<(1<<n);bit++){
      chmin(dp[i+1][bit],dp[i][bit]);
      chmin(dp[i+1][bit|key[i]],dp[i][bit]+cost[i]);
    }
  }
  if(dp[m][(1<<n)-1]==mod) cout <<"-1\n";
  else cout <<dp[m][(1<<(n))-1]<<'\n';
  return (0);
}

Measured memory_bytes: 35356
#include <iostream>

using namespace std;

int main() {
	int a, b;

	cin >> a >> b;

	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}

	return 0;
}


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

#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  // code
  int H, A, R = 0;
  cin >> H >> A;
  while(H > 0) {
    H -= A;
    R++;
  }
  cout << R << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

int main(){
    ll d, t, s;
    std::cin >> d >> t >> s;
    if(s * t >= d){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  //S is Sunny, Cloudy, or Rainy.

  if (s == "Sunny"){
    cout << "Cloudy";
  }
  else if (s == "Cloudy"){
    cout << "Rainy";
  }
  else{
    cout << "Sunny";
  }
  return 0;
}


Measured memory_bytes: 256
/// {{{
#include "bits/stdc++.h"
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
#define   rep(i, s, t)       for(int i = int(s); i < int(t); ++i)
using namespace std;
typedef long long i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

template<class T>
using MaxHeap = priority_queue<T>;

template<class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

signed main()
{
  iostreamBooster();
  int Q;
  cin >> Q;

  MaxHeap<int> left;
  MinHeap<int> right;
  i64 sumLeft = 0;
  i64 sumRight = 0;
  i64 sumB = 0;

  auto pollLeft = [&]() {
    const int ret = left.top(); left.pop();
    sumLeft -= ret;
    return ret;
  };

  auto pollRight = [&]() {
    const int ret = right.top(); right.pop();
    sumRight -= ret;
    return ret;
  };

  auto pushLeft = [&](int v) {
    sumLeft += v;
    left.push(v);
  };

  auto pushRight = [&](int v) {
    sumRight += v;
    right.push(v);
  };

  auto push = [&](int v) {
    if (left.empty() || v <= left.top()) {
      pushLeft(v);
    } else {
      pushRight(v);
    }

    const int lenL = left.size();
    const int lenR = right.size();
    if ((lenL + lenR) % 2 == 0) {
      if (lenL > lenR) {
        const int k = pollLeft();
        pushRight(k);
      } else if (lenL < lenR) {
        const int k = pollRight();
        pushLeft(k);
      }
    }
    else {
      if (lenL - 1 != lenR) {
        const int k = pollRight();
        pushLeft(k);
      }
    }
  };

  while(Q--) {
    int com, a, b;
    cin >> com;

    if (com == 1) {
      cin >> a >> b;
      push(a);
      sumB += b;
    } else {
      const i64 x = left.top();

      const i64 eval =
        (x * left.size() - sumLeft) +
        (sumRight - x * right.size()) +
        sumB;

      cout << x << ' ' << eval << '\n';
    }
  }

  return 0;
}



Measured memory_bytes: 3452
#include "bits/stdc++.h"
#include <iostream>
using namespace std;
const double EPS = 1e-10;

int main(){

	double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
	while(~scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
		&xa1,&ya1,&xa2,&ya2,&xb1,&yb1,&xb2,&yb2)){
			if(xb2 < xa1 || xa2 < xb1 || yb1 > ya2 || yb2 < ya1){
				cout << "NO" << endl;
			}
			else{
				cout << "YES" << endl;
			}
	}
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
 
int main(){
	ll N,A[3],B[3];
	cin >> N;
	FOR(i,0,3)cin>>A[i];
	FOR(i,0,3)cin>>B[i];
	ll M = 5000*5002;
	vector<ll> dpAB(M,0),dpBA(M,0);
	FOR(i,0,M){
		FOR(j,0,3){
			if(i+A[j]<M)
				dpAB[i+A[j]] = max(dpAB[i+A[j]],dpAB[i]+(B[j]-A[j]));
			if(i+B[j]<M)
				dpBA[i+B[j]] = max(dpBA[i+B[j]],dpBA[i]+(A[j]-B[j]));
		}
	}
	cout << dpBA[dpAB[N]+N]+dpAB[N]+N << endl;
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;


void solve() {
	//~ freopen("lca.out", "w", stdout);
	//~ freopen("lca.in", "r", stdin);
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr);
	
	int n, w;
	cin >> n >> w;
	vector<int> weight(n), value(n);
	for (int i = 0; i < n; i++) 
		cin >> weight[i] >> value[i];
		
	vector<ll> dp(w + 1, 0);
	for (int i = 0; i < n; i++) 
		for (int w_already = w - weight[i]; w_already >= 0; w_already--) {
			dp[w_already + weight[i]] = max(dp[w_already + weight[i]], dp[w_already] + value[i]);
		}
		
	ll ans = 0;
	for (ll val : dp)
		ans = max(ans, val);
	cout << ans;
}

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




Measured memory_bytes: 1024
s = input()
t = input()
S = len(s)
T = len(t)

#　dpで最大の長さを求める
dp = [[0]*(T+1) for _ in range(S+1)]
for i in range(S):
    for j in range(T):
        if s[i]==t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])
    # print(dp)
# print(dp[S][T])

# 後ろから復元
m,n = S,T
ans = ""
while m>0 and n>0:
    if dp[m][n]==dp[m-1][n]:
        m -= 1
    elif dp[m][n]==dp[m][n-1]:
        n -= 1
    else:
        m -= 1
        n -= 1
        ans += s[m]
        # print(ans)
print(ans[::-1])

Measured memory_bytes: 112220
using System;
using System.Linq;

class Program
{
    public static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] array = new int[s[1]];
        int count = 0;
        for (int i = 0; i < s[0]; i ++) {
            if (count == s[1]) count = 0;
            array[count] ++;
            count ++;
        }
        Console.WriteLine(array[0]-array[s[1]-1]);
    }
}

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

using namespace std;

int n, m;
vector<int> G[1005], revG[1005];
int u[200005], v[200005];
int reach[1005][1005];
vector<int> topo;
bool used[1005];
int scc[1005];

void tpsort(int v)
{
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(!used[G[v][i]]) tpsort(G[v][i]);
	}
	topo.push_back(v);
}
void sccdfs(int v, int id)
{
	used[v] = true;
	scc[v] = id;
	for(int i = 0; i < revG[v].size(); i++){
		if(!used[revG[v][i]]) sccdfs(revG[v][i], id);
	}
}

void dfs(int v, int s, int t)
{
	if(reach[s][v] == 0) reach[s][v] = t;
	else reach[s][v] = -1;
	
	int u;
	for(int i = 0; i < G[v].size(); i++){
		u = G[v][i];
  		if(reach[s][u] == -1 || reach[s][u] == t) continue;
		dfs(u, s, t);
	}
}

int main(void)
{
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		cin >> u[i] >> v[i];
		G[u[i]].push_back(v[i]);
		revG[v[i]].push_back(u[i]);
	}
	
	for(int i = 1; i <= n; i++){
		reach[i][i] = -1;
		for(int j = 0; j < G[i].size(); j++){
			dfs(G[i][j], i, G[i][j]);
		}
	}
	
	for(int i = 1; i <= n; i++) if(!used[i]) tpsort(i);
	reverse(topo.begin(), topo.end());
	int id = 0;
	for(int i = 1; i <= n; i++) used[i] = false;
	for(int i = 0; i < topo.size(); i++) if(!used[topo[i]]) sccdfs(topo[i], id++);
	
	for(int i = 1; i <= m; i++){
		if(scc[u[i]] != scc[v[i]]){
			if(reach[u[i]][v[i]] == -1) cout << "diff" << "\n";
			else cout << "same" << "\n";
		}
		else{
			if(reach[u[i]][v[i]] != -1) cout << "diff" << "\n";
			else cout << "same" << "\n";
		}
	}
	flush(cout);
	
	return 0;
}

Measured memory_bytes: 9856
xin = input().split()
x = list(map(int, xin))

a = x[0]*2 - x[1]/2
b = -x[0] + x[1]/2

if (a>=0 and b>= 0):
	if(a.is_integer() and b.is_integer()):
		print("Yes")
	else:
		print("No")
else:
	print("No")
	 

Measured memory_bytes: 9168
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=4e18;
const ll MOD=1e9+7;
const double EPS=1e-7;

string s;
ll K;
int main(){
    cin>>s>>K;
    ll now=0;
    for(ll i=0;i<s.length();i++){
        if(s[i]!='a'&&'z'-s[i]+1<=K){
            K-='z'-s[i]+1;
            s[i]='a';
            //cout<<K<<endl;
        }
        if(i==s.length()-1){
            s[i]+=K%26;
            if(s[i]>'z'){
                s[i]='a'+s[i]-'z'-1;
            }
        }
    }
    cout<<s<<endl;
    
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
 
int main(){
    ll n,k;
    cin>>n>>k;
    vector<double> p(n,0);
    rep(i,n) cin>>p[i];
    vector<double> ans(n,0);
    rep(i,n){
        if(i==0) ans[i]=(p[i]+1)/2;
        else ans[i]+=ans[i-1]+(p[i]+1)/2;
    }
    //rep(i,n) cout<<ans[i]<<" ";
    //cout<<endl;
    double max=0;
    rep(i,n-k+1){
        if(i==0){
            max=ans[k-1];
        }
        else{
            //cout<<i<<" "<<ans[i+k-1]<<" "<<ans[i-1]<<endl;
 
            if(max<ans[i+k-1]-ans[i-1]) max=ans[i+k-1]-ans[i-1];
        }
    }
    printf("%.10f\n",max);
    return 0;
}

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

int main() {
  int N, M; cin >> N >> M;

  vector<int> Shurui( M, 0 );
  rep( i, 0, N ) {
    int K; cin >> K;
    rep( j, 0, K ) {
      int A; cin >> A;
      Shurui.at(A-1)++;
    }
  }

  int Ans = 0;
  rep( i, 0, M ) {
    if ( Shurui.at(i) == N ) Ans++;
  }

  cout << Ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
set<int> lislis[5002];
int main(){
    int N;
    while(1){
        cin>>N;
        if(N==0)break;
        int lis[5002][2];
        for(int i=0;i<N;i++)cin>>lis[i][0]>>lis[i][1];
        for(int i=0;i<N;i++)lislis[lis[i][0]].insert(lis[i][1]);
        int ans=0;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                int a[2],b[2],c[2],d[2];
                a[0]=lis[i][0],a[1]=lis[i][1],b[0]=lis[j][0],b[1]=lis[j][1];
                if(a[0]<=b[0]^a[1]<=b[1]){
                    c[0]=a[0]+fabs(a[1]-b[1]),c[1]=a[1]+fabs(a[0]-b[0]);
                    d[0]=b[0]+fabs(a[1]-b[1]),d[1]=b[1]+fabs(a[0]-b[0]);
                    if(0<=c[0]&&c[0]<=5000&&0<=c[1]&&c[1]<=5000&&0<=d[0]&&d[0]<=5000&&0<=d[1]&&d[1]<=5000){
                        if(lislis[c[0]].count(c[1])&&lislis[d[0]].count(d[1])){
                            ans=max(ans,(int)(fabs(c[0]-d[0])*fabs(c[0]-d[0])+fabs(c[1]-d[1])*fabs(c[1]-d[1])));
                        }
                    }
                    c[0]=a[0]-fabs(a[1]-b[1]),c[1]=a[1]-fabs(a[0]-b[0]);
                    d[0]=b[0]-fabs(a[1]-b[1]),d[1]=b[1]-fabs(a[0]-b[0]);
                    if(0<=c[0]&&c[0]<=5000&&0<=c[1]&&c[1]<=5000&&0<=d[0]&&d[0]<=5000&&0<=d[1]&&d[1]<=5000){
                        if(lislis[c[0]].count(c[1])&&lislis[d[0]].count(d[1])){
                            ans=max(ans,(int)(fabs(c[0]-d[0])*fabs(c[0]-d[0])+fabs(c[1]-d[1])*fabs(c[1]-d[1])));
                        }
                    }
                }
                else{
                    c[0]=a[0]+fabs(a[1]-b[1]),c[1]=a[1]-fabs(a[0]-b[0]);
                    d[0]=b[0]+fabs(a[1]-b[1]),d[1]=b[1]-fabs(a[0]-b[0]);
                    if(0<=c[0]&&c[0]<=5000&&0<=c[1]&&c[1]<=5000&&0<=d[0]&&d[0]<=5000&&0<=d[1]&&d[1]<=5000){
                        if(lislis[c[0]].count(c[1])&&lislis[d[0]].count(d[1])){
                            ans=max(ans,(int)(fabs(c[0]-d[0])*fabs(c[0]-d[0])+fabs(c[1]-d[1])*fabs(c[1]-d[1])));
                        }
                    }
                    c[0]=a[0]-fabs(a[1]-b[1]),c[1]=a[1]+fabs(a[0]-b[0]);
                    d[0]=b[0]-fabs(a[1]-b[1]),d[1]=b[1]+fabs(a[0]-b[0]);
                    if(0<=c[0]&&c[0]<=5000&&0<=c[1]&&c[1]<=5000&&0<=d[0]&&d[0]<=5000&&0<=d[1]&&d[1]<=5000){
                        if(lislis[c[0]].count(c[1])&&lislis[d[0]].count(d[1])){
                            ans=max(ans,(int)(fabs(c[0]-d[0])*fabs(c[0]-d[0])+fabs(c[1]-d[1])*fabs(c[1]-d[1])));
                        }
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 2100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2,v=0; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][v-1] = 1;
        }
      }

      StringBuilder buf = new StringBuilder(n*n*2);
      for (int[] vertex : graph) {
        for (int v : vertex) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 25100
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n);
    ll ans=0;
    for(int i=0;i<k;i++)
    ans=ans+arr[i];
    cout<<ans;


    
    return 0;
}

Measured memory_bytes: 3620
N,T = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).reverse

maxv = A[0]
V = A[1..-1].map{ |v|
  profit = maxv - v
  maxv = v if v > maxv
  profit
}.max

#p V

vh = {}
grouph = {}
A.each{ |v|
  vh[v] = (vh[v] || 0) + 1
  if nsell = vh[v+V]
    nbuy = vh[v]
    grouph[v] = [nsell, nbuy]
  end
}

#p grouph

puts grouph.values.map{ |ss| ss.min }.inject(:+)

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

int main() {
  
  int A, B, C; cin >> A >> B >> C; int sum = 0;
  
  for (int i = 1; i < 1000001; i++) {
    
    sum += A;
    
    if (i % 7 == 0) sum += B;
    
    if (C <= sum) {
      cout << i << endl;
      break;
    }
    
  }
  
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
	char a[51],b[51];
	scanf("%s %s",a,b);
	int cont1=0;
	int cont2=0;
	for(int i=1;i<=strlen(b)+strlen(a);i++){
		if(i%2!=0){
			printf("%c",a[cont1]);
			cont1+=1;}
		else{
			printf("%c",b[cont2]);
			cont2+=1;}
		
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
#include <set>
#include <functional>

using namespace std;

class UnionFind {
public:
    vector<int> parent;

    UnionFind(int N) {
        parent = vector<int>(N, -1);
    }

    int root(int a) {
        if (parent[a] < 0) return a;
        return parent[a] = root(parent[a]);
    }

    int size(int a) {
        return -parent[root(a)];
    }

    bool connect(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) {
            return false;
        }
        if (size(a) < size(b)) {
            swap(a, b);
        }

        parent[a] += parent[b];
        parent[b] = a;
        return true;
    }
};

int main() {
    int n, m;
    cin >> n >> m;

    vector<pair<int, int>> e(m);
    
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    vector<long long> ans;
    ans.push_back((long long) n * (n - 1) / 2);

    UnionFind U(n);
    for (int i = m - 1; i > 0; i--) {
        long long tmp = ans.back();
        if (U.root(a[i]) != U.root(b[i])) {
            ans.push_back(tmp - (long long) U.size(a[i]) * U.size(b[i]));
            U.connect(a[i], b[i]);
        } else {
            ans.push_back(tmp);
        }
    }
    
    for (int i = ans.size() - 1; i >= 0; i--) {
        cout << ans[i] << endl;
    }

    return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int N,M,a,b;
map<int,int> m;

signed main() {
    cin >> N >> M;
    rep(i,M) {
        cin >> a >> b;
        m[a]++;
        m[b]++;
    }
    for(auto i : m) if (i.se%2) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;

}



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

int64_t ceil(int64_t a, int64_t b){
    if(a%b==0) return a/b;
    else return a/b+1;
}

int main(){
    int N,k;
    cin>>N>>k;
    int64_t ans=0;
    for(int i=0;i<N;i++){
        int64_t left=ans,right=1e18;
        while(right-left>1){
            int64_t mid=(left+right)/2;
            if(mid-ceil(mid,k)<ans){
                left=mid;
            }else{
                right=mid;
            }
        }
        if(right-ceil(right,k)==ans){
            ans=right;
        }else{
            ans=left;
        }
    }
    cout<<ans-1<<endl;

    return 0;
}

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

int main(){
  long long n, p;
  cin >> n >> p;
  long long odd = 0;
  for(int i = 0; i < n; i++){
    int k;
    cin >> k;
    if(k%2) odd++;
  }
  
  long long ans = 0;
  if(odd == 0 && !p) ans = pow(2, n);
  if(odd > 0) ans = pow(2, n-1);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

/** Problem0066 : Tic Tac Toe **/
int main()
{
	string board;
	while (cin>>board) {
		for (int i=0; i<3; i++) {
			if (board[i*3] != 's' && board[i*3] == board[i*3+1] && board[i*3] == board[i*3+2]) {
				cout << board[i*3] << endl;
				goto end;
			}
			else if (board[i] != 's' && board[i] == board[i+3] && board[i] == board[i+6]) {
				cout << board[i] << endl;
				goto end;
			}
		}
		
		if (board[0] != 's' && board[0] == board[4] && board[0] == board[8])
			cout << board[0] << endl;
		else if (board[2] != 's' && board[2] == board[4] && board[2] == board[6])
			cout << board[2] << endl;
		else
			cout << "d" << endl;
		
	end: ;
	}
	return 0;
}

Measured memory_bytes: 1180