akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>

int main(void){
  int i,j,temp;
  int num[3] = {0};
  for(i=0;i<3;i++){
  	scanf("%d",&num[i]);
  }
  
  
  for (i = 0; i < 2; i++) {
    for (j = 2; j > i; j--) {
      if (num[j-1] > num[j]) {
        temp = num[j-1];
        num[j-1] = num[j];
        num[j] = temp;
      }
    }    
  }
  
  int sum = 0;
  
  for (i=0;i<2;i++)
	  sum += num[i+1] - num[i]; 
  
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
/*2019/10/02 */
/*template*/
#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 tmp;tmp=*x;*x=*y;*y=tmp;}
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){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
/*
int asc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return -1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return 1;}
int desc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return 1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return -1;}
*/

int main(){
    int h,w;
    char map[200][200];
    int skipx[200]={},skipy[200]={};

    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        scanf("%s",map[i]);
    }
    int flg=0;
    for(int i=0;i<h;i++){
        flg=0;
        for(int j=0;j<w;j++){
            if(map[i][j]=='#'){
                flg=1;
                break;
            }
        }
        if(!flg){
            skipy[i]=1;
        }
    }
    for(int i=0;i<w;i++){
        flg=0;
        for(int j=0;j<h;j++){
            if(map[j][i]=='#'){
                flg=1;
                break;
            }
        }
        if(!flg){
            skipx[i]=1;
        }
    }
    for(int i=0;i<h;i++){
        if(skipy[i])continue;
        for(int j=0;j<w;j++){
            if(skipx[j])continue;
            printf("%c",map[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, non_snake_case)]
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

//{{{ macros missing in 1.15.1
#[macro_use]
mod macros {
    macro_rules! eprint {
        ($($t:tt)*) => {{
            use ::std::io::Write;
            let _ = write!(::std::io::stderr(), $($t)*);
        }};
    }
    macro_rules! eprintln {
        () => { eprintln!(""); };
        ($($t:tt)*) => {{
            use ::std::io::Write;
            let _ = writeln!(::std::io::stderr(), $($t)*);
        }};
    }
    macro_rules! dbg {
        ($val:expr) => {
            match $val {
                tmp => {
                    eprintln!(
                        "[{}:{}] {} = {:#?}",
                        file!(),
                        line!(),
                        stringify!($val),
                        &tmp
                    );
                    tmp
                }
            }
        };
    }
}
//}}}

fn minimum(mut time: usize, mut speed: usize) -> usize {
    while speed > 1 {
        time += speed;
        speed /= 3;
    }
    time
}

fn run() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    let n: usize = sc.read();
    let mut speed = 1;
    let mut time = 0;
    let mut answer = 0;
    while time < n {
        time += speed;
        answer += 1;
        if minimum(time, speed * 3) <= n {
            speed *= 3;
        } else if minimum(time, speed) > n {
            speed /= 3;
        }
    }
    println!("{}", answer);
}

fn main() {
    std::thread::Builder::new()
        .name("run".to_string())
        .stack_size(1024 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap()
}

//{{{ Scanner
pub struct Scanner<R> {
    reader: R,
}

impl<R> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner { reader: r }
    }
}

fn is_whitespace(b: u8) -> bool {
    b == b' ' || b == b'\n' || b == b'\r' || b == b'\t'
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        let buf = std::io::Read::bytes(self.reader.by_ref())
            .map(|b| b.expect("Read failed"))
            .skip_while(|&b| is_whitespace(b))
            .take_while(|&b| !is_whitespace(b))
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error")
    }

    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
//}}}



Measured memory_bytes: 9056
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int dp[3005][3005],t[3005][3005];
int a[3005],mod=998244353;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	FOR(i,1,n)cin>>a[i],dp[i][a[i]]=i;
	FOR(i,2,n){
		FOR(j,a[i],m)t[i][j]=(dp[i-1][j-a[i]]+dp[i][j])%mod;
		FOR(j,0,m)dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
		FOR(j,a[i],m)dp[i][j]=(dp[i-1][j-a[i]]+dp[i][j])%mod;
	}
	int ans=0;
	FOR(i,1,n){
		ans=(ans+t[i][m]*(n-i+1))%mod;
	}
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 141184
using System;
using System.Collections.Generic;
using System.Dynamic;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine(a + (a * a) + (a * a * a));
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define IOS			ios::sync_with_stdio(0), cin.tie(0)

int32_t main() {

	IOS;

	int n;
	cin >> n;
	string ans;

	vector<char> v(26);
	v[0] = 'z';

	for (int i = 1; i < 26; i++) {
		v[i] = i + 96;
	}

	int rem;
	while (n) {
		rem = n % 26;
		ans.push_back(v[rem]);
		if (rem == 0)
			n--;
		n /= 26;
	}
	reverse(ans.begin(), ans.end());

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(void) {
    ll n;
    cin>>n;
    vector<ll> v;
    rep(i,0,n){
        ll a;
        cin>>a;
        a-=i+1;
        v.pb(a);
    }
    sort(all(v));
    ll mn = 1000000000000000000LL;
    if(n%2==1){
        ll b = v[n/2];
        ll sum = 0;
        rep(i,0,n){
            sum += abs(v[i]-b);
        }
        mn = min(mn,sum);
    }
    else{
        ll b0 = v[n/2];
        ll b1 = v[n/2+1];
        ll sum;
        sum = 0;
        rep(i,0,n){
            sum += abs(v[i]-b0);
        }
        mn = min(mn,sum);
        sum = 0;
        rep(i,0,n){
            sum += abs(v[i]-b1);
        }
        mn = min(mn,sum);
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 2420
N, K = map(int, input().split())
V = [int(i) for i in input().split()]

ans = 0
for i in range(1, K+1):
    enq = K - i
    for j in range(i+1):
        combi = V[:i-j] + V[N-j:]
        tmp = sum(combi)
        ans = max(ans, tmp)
        for _ in range(enq):
            combi.remove(min(combi))
            if sum(combi) <= tmp:
                break
            else:
                tmp = sum(combi)
                ans = max(ans, tmp)
                if not combi:
                    break
        if i >= N:
            break

print(ans)


Measured memory_bytes: 3064
/**
 *   @FileName	e.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.19 21:36:51
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    ll n,x,m;cin >> n >> x >> m;
    vector<ll> a;
    a.push_back(x);
    vector<int> b(m,-1);
    vector<ll> sum(m+1,0);
    int start,end; 
    sum[0] = x;
    for (int i = 0; i <= m; i++) {
        a.push_back(a[i] * a[i] % m);
        sum[i+1] = sum[i] + a[i+1];
        if (b[a[i+1]] != -1) {
            start = b[a[i+1]];
            end = i+1;
            break;
        }
        b[a[i+1]] = i+1;
    }
    if (n-1 <= end) {
        cout << sum[n-1] << endl;
        return 0;
    }
    ll k = sum[end] - sum[start];
    ll t = (n-1-end);
    
    cout << sum[end] + t/(end-start)*k+sum[t%(end-start)+start]-sum[start] << endl;
    return 0;
}

Measured memory_bytes: 4960
#include <iostream>
#include <map>
#include <cstring>
using namespace std;
map<string,int> m;
int main(){
	string s,t;
	while(cin >> s >> t){
		int x,a=0,b,S=s.size(),T=t.size(),i,j;
		b=min(S,T)+1;
		while(true){
			x=0;
			j=(a+b)/2;
			if(b-a==1) break;
			for(i=0;i<=S-j;i++) m[s.substr(i,j)]++;
			for(i=0;i<=T-j;i++) if(m[t.substr(i,j)]>=1) x++;
			m.clear();
			if(!x) b=j;
			else a=j;
		}
		cout<<a<<endl;
	}
}

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

const int N = 1e5 + 10;
int n, q, cnt[N];

int main() {
	cin >> n >> q;
	for (int i = 0; i < q; i++) {
		int v, u;
		cin >> v >> u;
		v--;
		u--;
		cnt[v]++;
		cnt[u]++;
	}
	
	for (int i = 0; i < n; i++)
		if (cnt[i] & 1)
			return cout << "NO", 0;
	cout << "YES";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    int x, n;
    cin >> x >> n;
    vi a(111, 0);
    for(int i = 0; i < n; i++)
    {
        int b; cin >> b;
        a[b] = 1;
    }

    pii ans(120, 120 + x);
    for(int i = 0; i <= 110; i++)
        if(!a[i]) ans = min(ans, pii(abs(x - i), i));

    cout << ans.second << endl;

    return 0;
}

Measured memory_bytes: 3652
using System;

namespace ITP1_3_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int cnt = 0;
            int[] array = new int[10001];
            while (true) {
                int x = int.Parse(Console.ReadLine());
                if (x == 0) break;
                cnt++;
                array[cnt] = x;
            }
            for (int i=1;i<=cnt;i++)
            {
                Console.WriteLine("Case " + i + ": " + array[i]);
            }
        }
    }
}

Measured memory_bytes: 9052
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main(void) {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	for (int i = A; i <= B; ++i) {
		string s = to_string(i);
		if (s[0] == s[4] && s[1] == s[3])ans++;
	}
	OUT(ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		long ans = b + Math.min(c, b + a + 1);
		System.out.println(ans);
	}
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define perm(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define unique(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define minv(v) min_element(all(v))
#define maxv(v) max_element(all(v))
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min3(a, b, c), d)
#define min5(a, b, c, d, e) min(min4(a, b, c, d), e)
#define min6(a, b, c, d, e, f) min(min5(a, b, c, d, e), f)
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max3(a, b, c), d)
#define max5(a, b, c, d, e) max(max4(a, b, c, d), e)
#define max6(a, b, c, d, e, f) max(max5(a, b, c, d, e), f)
// b is [a, c)
#define range(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define range2d(a, b, c, d, e, f) (range((a), (c), (e)) && range((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = min3(a, (b), (c))
#define chmin4(a, b, c, d) a = min4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = min5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = min6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = max3(a, (b), (c))
#define chmax4(a, b, c, d) a = max4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = max5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = max6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define yes(f) cout << ((f) ? yes_str : no_str) << endl;

using namespace std;
#define cin input
#define cout output

void solve(istream& input, ostream& output) {
	string s; cin >> s;
	int cnt = 0;
	string pre = "";
	string now = "";
	rep(i, s.size()) {
		now += s[i];
		if (pre != now) {
			cnt++;
			pre = now;
			now = "";
		}
	}
	cout << cnt << endl;
}

#undef cin
#undef cout

#ifndef check_cpp

signed main() {
	solve(cin, cout);
}

#endif


Measured memory_bytes: 640
import sys 
import math
try:
	sys.stdin = open('input.txt', 'r') 
	sys.stdout = open('output.txt', 'w')
except:
	pass

input = sys.stdin.readline
for tt in range(1):
	n,k= map(int,input().split())
	n+=1; ans = 0
	for i in range(k,n+1):
		minSum = (i*(i-1))//2
		maxSum = (n*(n-1))//2 - ((n-i)*(n-i-1))//2
		ans += (maxSum - minSum + 1)%(10**9+7)
	print(ans%(10**9+7))

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

using namespace std;

int main() {
	int l[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	int K;
	cin >> K;

	cout << l[K-1] << endl;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,z,w = f()
    a = f()

    print(max(abs(a[n-1] - w), abs(a[n-2] - a[n-1])))

solve()


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

int main()
{
  string s;
  cin >> s;
  int n = 0;
  if(s[0] == '9') n += 100;
  else n += 900;
  if(s[1] == '9') n += 10;
  else n += 90;
  if(s[2] == '9') n += 1;
  else n += 9;
  
  cout << n;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<functional>
#include<stack>
#include<list>
#include<set>
#include<deque>
#include<climits>
using namespace std;

int N,M;
int par[100],_rank[100];

struct Way{
	int A,B,D;
	Way(){}
	Way(int _A,int _B,int _D){
		A=_A; B=_B; D=_D;
	}
	bool operator<(const Way &a)const{
		return D<a.D;
	}
};

void Init(){
	for(int i=0;i<N;i++) par[i] = i;
}

int Find(int x){
	if(par[x]==x) return x;
	else return par[x] = Find(par[x]);
}

bool Unite(int x,int y){
	int a = Find(x),
		b = Find(y);
	if(a==b) return false;
	if(_rank[a]>_rank[b]){
		par[b] = par[a];
	}
	else{
		par[a] = par[b];
		if(_rank[a]==_rank[b]) _rank[b]++;
	}
	return true;
}

int main(){
	Way way[10000];
	while(cin>>N,N){
		cin>>M;
		for(int i=0;i<M;i++){
			scanf("%d,%d,%d",&way[i].A,&way[i].B,&way[i].D);
		}
		sort(way,way+M);
		int ans=0;
		Init();
		for(int i=0;i<M;i++){
			if(Unite(way[i].A,way[i].B)==true){
				ans += way[i].D/100-1;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1296
// D - Caracal vs Monster
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
ll H;

ll solve(){
	ll ans=0;
	ll count = 1;
	while(H){
		ans += count;
		count <<= 1;
		H >>= 1;
	}
	return ans;
}

int main(){
	cin>>H;
	cout<< solve() <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 101

int main(){
  int n, i, j, k, u, v, A[N][N];

  scanf("%d", &n);

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      A[i][j] = 0;
    }
  }

  for(i = 1; i <= n; i++){
    scanf("%d%d", &u, &k);
    for(k; k > 0; k--){
      scanf("%d", &v);
      A[u][v] = 1;
    }
  }

  for(i = 1; i <= n; i++){
    for(j = 1; j < n; j++){
      printf("%d ", A[i][j]);
    }
    printf("%d\n", A[i][j]);
  }
  
  return 0;
}

Measured memory_bytes: 636
function Main(input){
	var N = input;	
  	var bool = false;
  	for(var i = 0;i<N.length;i++){
    	if(N[i] == "7"){
        	bool = true;
        }
    }
  	var result = bool?"Yes":"No";
  	console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 30128
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;

int main(){
	long long N, M, L = 0, ans = -1;
	string S, T;
	map<long long, char> X;

	cin >> N >> M >> S >> T;

	long long s = S.size(), t = T.size();

	if (s % t == 0){
		L = s;
	}
	else if (t % s == 0){
		L = t;
	}
	else{
		int r, x = s, y = t;
		while ((r = x % y) != 0){
			x = y;
			y = r;
		}
		L = s * t / y;
	}

	if (L != 0){
		for (long long i = 0; i < S.size(); ++i){
			X[i * (L / S.size())] = S[i];
		}
		for (long long i = 0; i < T.size(); ++i){
			if (X[i * (L / T.size())] != 0 && X[i * (L / T.size())] != T[i])
				break;
			if (i == T.size() - 1)
				ans = L;
		}		
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10880
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        m: usize,
        py: [[usize; 2]; m]
    }
    let mut w = py;
    for i in 0..m {
        w[i].push(i);
    }
    w.sort_by(|x, y| if x[0] == y[0] { x[1].cmp(&y[1]) } else { x[0].cmp(&y[0]) });
    let mut p = 0;
    let mut c = 1;
    for i in 0..m {
        if p != w[i][0] {
            p = w[i][0];
            c = 1;
        }
        w[i].push(c);
        c += 1;
    }
    w.sort_by_key(|x| x[2]);
    for city in w {
        println!("{0: >06}{1: >06}", city[0], city[3]);
    }
}


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

int main() {
  int n; cin>>n;
  string s; cin>>s;
  string t; t=s;
  int i=0;
  while(i<t.size()-1){
    if(t[i]=='(' && t[i+1]==')'){
      t.erase(i,2);
      if(t.size()==0)break;
      if(i>0){i--;}
    }
    else{i++;}
  }
  int a=count(t.begin(),t.end(),'(');
  int b=t.size()-a;

  
  rep(j,b){cout<<"(";}
  cout<<s;
  rep(j,a){cout<<")";}
  
  cout<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int h, m, s;
	while (cin >> h >> m >> s) {
		if ((h&m&s) == -1) break;
		int sum = h * 3600 + m * 60 + s;
		int ans1 = 7200 - sum;
		int ans2 = 7200 * 3 - sum * 3;
		printf("%02d:%02d:%02d\n", ans1 / 3600, ans1 % 3600 / 60, ans1 % 60);
		printf("%02d:%02d:%02d\n", ans2 / 3600, ans2 % 3600 / 60, ans2 % 60);
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=200005;
int n,m,fa[N];
LL dist[N];
int getfa(int x)
{
	if(fa[x]==x) return x;
	int ff=fa[x]; LL len=dist[x];
	fa[x]=getfa(fa[x]);
	dist[x]=dist[ff]+len;
	return fa[x];
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) fa[i]=i;
	//puts("");
	for(int i=1;i<=m;i++)
	{
		int l,r; LL d; scanf("%d%d%lld",&l,&r,&d);
		int x=getfa(l),y=getfa(r);
		//cout<<i<<"  "<<x<<' '<<y<<' '<<fa[x]<<' '<<fa[y]<<endl;
		//for(int j=1;j<=n;j++) cout<<dist[j]<<' '; cout<<endl;
		if(x!=y){
			LL d1=dist[l],d2=dist[r];
			//cout<<d1<<" "<<d2<<endl;
			if(d1+d>=d2){
				fa[y]=x; dist[y]=dist[x]+d1+d-d2;
			}
			else{
				fa[x]=y; dist[x]=dist[y]+d2-d1-d;
			}
			//fa[y]=x; dist[y]=dist[x]+d;
		}
		else{
			if(dist[r]-dist[l]!=d) {printf("No\n");return 0;}
		}
		//cout<<"Di"<<' ';for(int i=1;i<=n;i++) cout<<dist[i]<<' '; cout<<endl;
		//cout<<"Fa"<<' ';for(int i=1;i<=n;i++) cout<<fa[i]<<' '; cout<<endl<<endl;
	}
	for(int i=1;i<=n;i++)
	  if(dist[i]>1e9) {printf("No\n");return 0;}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 1408
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;


int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;
    }
    return sum;
}
int main(){
    int N,M;
    cin >> N >> M;
    vector<pair<int,int>> cities[100001];
    for(int i =0; i<M; i++){
        int p,y;
        cin >> p >> y;
        cities[p].push_back({y,i});
    }

    pair<int,int> ans[1000001];
    for(int i = 1; i<=N; i++){
        sort(cities[i].begin(),cities[i].end());
        for(int j = 0;j < cities[i].size(); j++){
            ans[cities[i][j].second] = {i,j+1};
        }
    }

    for(int i=0; i<M; i++){
        printf("%06d%06d\n" ,ans[i].first,ans[i].second);
    }
    return 0;
}


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

int main()
{
	// 入力 
	int n;
	int a[100];
	int max = 1, min = 1000000000;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > max) max = a[i];
		if (a[i] < min) min = a[i];
	}

	int result;
	result = abs(max - min);
	
	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>



using namespace std;

int a[4][13];

int main() {
    int n, num;
    char mark;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> mark >> num;
        switch (mark) {
        case 'S':
            a[0][num - 1] = 1;
            break;
        case 'H':
            a[1][num - 1] = 1;
            break;
        case 'C':
            a[2][num - 1] = 1;
            break;
        case 'D':
            a[3][num - 1] = 1;
            break;
        }

    }

   /* for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            cout << a[i][j];
        }
        cout << endl;
    }*/




    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (a[i][j] == 0) {
                switch (i) {
                case 0:
                    cout << 'S' << ' ' << j + 1 << endl;
                    break;
                case 1:
                    cout << 'H' << ' ' << j + 1 << endl;
                    break;
                case 2:
                    cout << 'C' << ' ' << j + 1 << endl;
                    break;
                case 3:
                    cout << 'D' << ' ' << j + 1 << endl;
                    break;
                }
            }


        }
    }
}


Measured memory_bytes: 3092
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}

int odd[60];
ll dp[60];

int main(int argc, char const* argv[])
{
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n)cin >> a[i];
  int ma = 0;
  rep(i, n){
    int j = 0;
    ll tmp = a[i];
    while(tmp){
      odd[j] += tmp % 2;
      tmp /= 2;
      j++;
    }
    ma = max(ma, j);
  }
  vector<int> kb;
  ll tmp = k;
  while(tmp){
    kb.pb(tmp % 2);
    tmp /= 2;
  }
  ll res = 0;
  for(int i = ma - 1; i >= sz(kb); i--){
    res += (1LL << i) * (ll)odd[i];
  }
  ll curr = 0;
  for(int i = sz(kb) - 1; i >= 0; i--){
    dp[i] = dp[i+1];
    if(i + 1 == sz(kb)){
      dp[i] = (1LL << i) * (ll)odd[i];
    }else{
      dp[i] += (1LL << i) * (ll)max(odd[i], n - odd[i]);
      if(kb[i] == 1){
        dp[i] = max(dp[i], curr + (1LL << i) * (ll)odd[i]);
      }
    }
    curr = curr + (ll)((kb[i] == 0) ? odd[i]: n - odd[i]) * (1LL << i);
  }
  cout << res + max(dp[0], curr) << endl;
	return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var D = input[0];
            var G = input[1];
            var P = new int[D];
            var C = new int[D];
            var bonus = new int[D];
            for (int i = 0; i < D; i++)
            {
                input = ReadArrayInt();
                P[i] = input[0];
                C[i] = input[1];
                bonus[i] = 100 * (i + 1) * P[i] + C[i];
            }
            var ans = int.MaxValue;
            for (int i = 0; i < (1 << D); i++)
            {
                var sum = 0;
                var cnt = 0;
                var end = new bool[D];
                for (int j = 0; j < D; j++) if ((i & (1 << j)) == (1 << j)) end[j] = true;
                for (int j = 0; j < D; j++) if (end[j]) { sum += bonus[j]; cnt += P[j]; }
                if (sum >= G && cnt < ans) { ans = cnt; continue; }
                else if (sum >= G) continue;
                for (int j = D - 1; j >= 0; j--)
                {                    
                    if (!end[j])
                    {
                        for (int k = 0; k < P[j]; k++)
                        {
                            sum += 100 * (j + 1);
                            if (k == P[j] - 1) sum += C[j];
                            cnt++;
                            if (sum >= G) break;                            
                        }
                    }
                    if (sum >= G) break;
                }
                if (cnt < ans) ans = cnt;
            }
            
            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
import java.util.*;
import java.util.Map.*;

public class Main {

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



	public void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		s += 'T';
		int N=s.length();
		int x=sc.nextInt();
		int y=sc.nextInt();

		ArrayList<Integer>xl = new ArrayList<>();
		ArrayList<Integer>yl = new ArrayList<>();

		int sw = 0;
		int cnt = 0;
		for(int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			if(c=='T') {
				if(sw%2==0) {
					xl.add(cnt);
				}else {
					yl.add(cnt);
				}
				sw = (sw+1)%2;
				cnt=0;

			}else {
				cnt++;
			}
		}


		boolean dpx[][] = new boolean[xl.size()+1][N*2+1];
		dpx[1][N+xl.get(0)]=true;
		for(int i=1; i<xl.size(); i++) {
			int f = xl.get(i);
			for(int j=0; j<=N*2; j++) {
				if(dpx[i][j]) {
					dpx[i+1][j+f] = true;
					dpx[i+1][j-f] = true;
				}
			}
		}
		boolean dpy[][] = new boolean[yl.size()+1][N*2+1];
		dpy[0][N]=true;
		for(int i=0; i<yl.size(); i++) {
			int f = yl.get(i);
			for(int j=0; j<=N*2; j++) {
				if(dpy[i][j]) {
					dpy[i+1][j+f] = true;
					dpy[i+1][j-f] = true;
				}
			}
		}
		if(dpx[xl.size()][N+x] && dpy[yl.size()][N+y]) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}

}


Measured memory_bytes: 176336
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
int n,k;
vi dp((int)1e5), prv((int)1e5), prv2((int)1e5);
vi dp2((int)1e5);
const int mod = (int)1e9 + 7;
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n >> k;                
    swap(n, k);
    FOR1(i, sqrt(k) + 1){
        prv[i] =1;
        prv2[i] = 1;
    } 
    int temp = sqrt(k);
    if(temp * temp == k)temp--;
    FOR(i, n){
        int num = 1;
        for(; num <= temp; num++){
            dp[num] = prv2[num]; 
            int fac = ((k/num) - max(k/(num + 1), (long long)sqrt(k)));
            dp2[num] = prv[num]*fac;
            //cout << dp[num] << "  " << dp2[num] << endl;
        } 
        if(num * num == k){
            dp[num] = prv[num];
            num--;
        }
        int pr = 0;
        for(int j = 1; j <= sqrt(k); j++){
            prv[j] = dp[j] + prv[j-1];
            prv[j] %= mod;
            //debug(prv[j]);
        }
        pr = prv[sqrt(k)];
        for(int j = 1; j <= temp; j++){
            prv2[j] = pr + dp2[temp - j + 1];
            prv2[j] %= mod;
            pr = prv2[j];
        //    cout << pr << " "; 
        }
        int x = 1, y = temp;
        while(x <  y){
            swap(prv2[x], prv2[y]); 
            x++; y--;
        }
    }
    cout << prv2[1];

}




Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int N, M, X; cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    rep(i, N) {
        cin >> C[i];
        rep(j, M) {
            cin >> A[i][j];
        }
    }

    int max_ans = 1e7;
    int ans = max_ans;

    for (int i = 0; i < (1 << N); ++i) {
        vector<int> tX(M);
        int tans = 0;
        rep(j, N) {
            if ((i >> j) & 1) {
                tans += C[j];
                rep(k, M) {
                    tX[k] += A[j][k];
                }
            }
        }
        int over_x = 1;
        rep(j, M) {
            if (tX[j] < X) {
                over_x = 0;
                break;
            }
        }
        if (over_x) {
            ans = min(ans, tans);
        }
    }
    if (ans == max_ans) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
n, t = map(int, input().split())
a = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
  x, y = map(int, input().split())
  a[i][0], a[i][1] = x, y
a = sorted(a, key=lambda x: x[0], reverse=True)
dp = [[0 for i in range(t+1)] for j in range(n+1)]

for i in range(1, n+1):
  for j in range(1, t+1):
    dp[i][j] = max(dp[i-1][j], dp[i][j-1])
    if j == 1:
      dp[i][j] = max(dp[i][j], a[i-1][1])
    if j >= a[i-1][0]:
      dp[i][j] = max(dp[i][j], dp[i-1][j-a[i-1][0]] + a[i-1][1])
print(dp[n][t])  

Measured memory_bytes: 125272
from collections import defaultdict


N,W = map(int, input().split())
WV = []
for i in range(N):
    WV.append(list(map(int, input().split())))
    
dp = defaultdict(int)

dp[0] = 0

for w,v in WV:
    for new_w, new_v in list(dp.items()):
        if w + new_w <= W:
            dp[w + new_w] = max(dp[w + new_w], v + new_v)
            
print(max(dp.values()))


Measured memory_bytes: 3828
#include <cstdio>
 
int main(void) {
    int x, y, ans=0;
    scanf("%d %d", &x, &y);
    if(x==0) ans=(y>0)?y:-y+1;
    if(y==0) ans=(x>0)?x+1:-x;
    if((x>0 && y>0) || (x<0 && y<0))
        ans+=(x>y)?x-y+2:y-x;
    if((x>0 && y<0) || (x<0 && y>0)) {
        ans=1;
        x=x<0?-x:x;
        y=y<0?-y:y;
        ans+=(x>y)?x-y:y-x;
    }    
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if ((x + y) % 3 != 0) {
			System.out.println(0);
			return;
		}
		if (x > y * 2 || y > x * 2) {
			System.out.println(0);
			return;
		}
		int a = x - (x + y) / 3;
		int b = y - (x + y) / 3;

		long mod = (long) Math.pow(10, 9) + 7;
		FermatCombination com = new FermatCombination((a + b), mod);
		long num = com.combine((a + b), a);

		System.out.println(num);
	}

}

class FermatCombination {

	long factrial[]; // 階乗を保持
	long inverse[]; // 逆元を保持
	long MOD;

	FermatCombination(int size, long mod) {

		this.factrial = new long[size + 1];
		this.inverse = new long[size + 1];
		this.MOD = mod;

		this.factrial[0] = 1;
		this.inverse[0] = 1;

		for (int i = 1; i <= size; i++) {
			factrial[i] = (factrial[i - 1] * i) % MOD; // 階乗を求める
			inverse[i] = pow(factrial[i], (int) MOD - 2) % MOD; // フェルマーの小定理で逆元を求める
		}
	}

	long combine(int n, int k) {
		return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
	}

	long pow(long x, int n) { // x^n 計算量O(logn)
		long ans = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				ans = ans * x % MOD;
			}
			x = x * x % MOD; // 一周する度にx, x^2, x^4, x^8となる
			n >>= 1; // 桁をずらす n = n >> 1
		}
		return ans;
	}
}

Measured memory_bytes: 34004
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;

    set<ll> a;
    for(int i=0;i<n;i++){
        ll l;
        cin >> l;
        if(a.count(l))a.erase(l);
        else a.insert(l);
    }

    cout << a.size() << endl;

    return 0;
}


Measured memory_bytes: 8232
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long a, b, c, d, e, f, g;
long long A, B, C, D, E, F, G;
int main(){
	cin >> a >> b >> c >> d >> e >> f >> g;
	A = a;
	B = b;
	C = c;
	D = d;
	E = e;
	F = f;
	G = g;
	long long num = 0;
	num += 2 * (a/2);
	num += 1 * (b);
	num += 2 * (d/2);
	num += 2 * (e/2);
	if(a%2 == 1 && d%2 == 1 && e%2 == 1){
		num += 3;
	}

	long long NUM = 0;
	if(a>0 && d>0 && e>0){
		NUM += 3;
		a--;
		d--;
		e--;
	}
	NUM += 2 * (a/2);
	NUM += 1 * (b);
	NUM += 2 * (d/2);
	NUM += 2 * (e/2);

	cout << max(num, NUM) << endl;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n, m; cin >> n >> m;
	vector<vector<int>> gr(n + 1);
	for (int i = 1; i <= m; i++) {
		int u, v; cin >> u >> v;
		gr[u].push_back(v);
		gr[v].push_back(u);
	}

	vector<bool> vis(n + 1, false);

	function<int(int)> dfs = [&](int curr) -> int {
		int res = 1;
		vis[curr] = true;

		for (auto child : gr[curr]) {
			if (vis[child]) continue;
			res += dfs(child);
		}
		return res;
	};

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (vis[i] == false) {
			ans = max(ans, dfs(i));
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 26688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	char s[4];

	scanf("%s", s);

	bool exist[3];
	for(int i=0;i<3;i++) exist[i] = false;
	for(int i=0;i<3;i++){
		exist[s[i]-'a'] = true;
	}
	if(exist[0]&&exist[1]&&exist[2]){
		printf("Yes\n");
	}else{
		printf("No\n");		
	}
	return 0;
}


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

int main()
{
	int point, base, n, out;
	string ibe;

	cin >> n;
	for (int k = 0; k < n; k++){
		base = point = out = 0;
		while (1){
	 	 cin >> ibe;
		 if (ibe == "HIT"){
			 base++;
			 if (base == 4){
				 base--;
				 point++;
			 }
		 }
		 else if (ibe == "OUT"){
			 out++;
		 }
		 else {
			 point += base + 1;
			 base = 0;
		 }
		 if (out >= 3) break;
		 
		}
		cout << point << endl;
	}
	return (0);
}	

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

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

	int res = 0;
	for(int i = 0; i < N; ++i) {
		res += L + (i + 1) - 1;
	}

	int cnt = 0;
	int tmp = 100000;
	int ans = 0;
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j < N; ++j) {
			if(i == j) {
			} else {
				cnt = cnt + ( L + (j + 1) - 1 );
			}
		}

		if(tmp > abs(res - cnt)) {
			tmp = abs(res - cnt);
			ans = cnt;
		}

		cnt = 0;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
# D - equeue

import heapq

n, k = map(int, input().split())
v = list(int(x) for x in input().split())

ans = 0
for l in range(k+1):
    for r in range(k+1-l):
        if l+r>n:
            continue
        tmp = 0
        s = []
        for i in range(l):
            tmp += v[i]
            heapq.heappush(s, v[i])

        for i in range(n-r, n):
            tmp += v[i]
            heapq.heappush(s, v[i])
            
        for i in range(k-l-r):
            if len(s)==0:
                break
            if s[0]>0:
                break
            tmp -= heapq.heappop(s)
        
        ans = max(ans, tmp)

print(ans)

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

int main() {
    int N;
    cin >> N;
    int one = 0, two = 0, three = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a == 1) one++;
        if (a == 2) two++;
        if (a == 3) three++;
    }
    vector<vector<vector<double>>> dp(N+1, vector<vector<double>>(N+1, vector<double>(N+1, 0)));
    for (int rem = 1; rem <= N*3; rem++) {
        for (int i = 0; i <= N; i++) {
            for (int j = 0; i+j*2 <= rem && j <= N; j++) {
                if ((rem-i-j*2)%3 != 0) continue;
                int k = (rem-i-j*2)/3;
                if (k < 0 || k > N) continue;
                if (i+j+k > N) continue;
                double roll = (double)N / (i+j+k);
                if (i > 0) dp[i][j][k] += (dp[i-1][j][k]+roll)*(double)i/(i+j+k);
                if (j > 0) dp[i][j][k] += (dp[i+1][j-1][k]+roll)*(double)j/(i+j+k);
                if (k > 0) dp[i][j][k] += (dp[i][j+1][k-1]+roll)*(double)k/(i+j+k);
            }
        }
    }
    cout << setprecision(15) << dp[one][two][three] << endl;
    return 0;
}

Measured memory_bytes: 219944
use itertools::Itertools;
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    let mut map = HashMap::new();
    for item in s {
        let item = item.chars().collect::<Vec<char>>();
        match item[0] {
            'M' | 'A' | 'R' | 'C' | 'H' => {
                let count = map.entry(item[0]).or_insert(0);
                *count += 1;
            }
            _ => (),
        }
    }

    let combi = map.keys().into_iter().combinations(3);
    let mut count: u64 = 0;
    for items in combi {
        let mut sub_count = 0;
        for item in items {
            if map.contains_key(&item) {
                if sub_count == 0 {
                    sub_count = *map.get_key_value(&item).unwrap().1;
                } else {
                    sub_count *= map.get_key_value(&item).unwrap().1;
                }
            }
        }
        count += sub_count;
    }

    println!("{}", count);
}


Measured memory_bytes: 8212