akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	bufsiz = 1024 * 1024
)

func main() {
	writer := newWriter(os.Stdout)
	defer writer.Flush()

	sc := newScanner(os.Stdin)
	nPeaple := sc.scanInt()

	// mFoods := sc.scanInt()
	sc.scanInt()

	// 1人目の情報をscan
	kind := sc.scanInt()
	m := make(map[int]bool, kind)

	for i := 0; i < kind; i++ {
		tmp := sc.scanInt()
		m[tmp] = true
	}

	for i := 1; i < nPeaple; i++ { // 2人目の情報、3人目の情報... 「全ての行が含む」を確認したい
		kind := sc.scanInt()
		sl := make([]int, kind)

		for j := 0; j < kind; j++ {
			sl[j] = sc.scanInt()
		}

		for k := range m { // 1人目の情報を有するmapの各要素
			if !contains(sl, k) {
				m[k] = false
			}
		}
	}

	result := 0
	for _, v := range m {
		if v == true {
			result++
		}
	}

	writer.println(result)

}

// contains returns:
// if s contains e, true. / if s not contains e, false.
func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

type scanner struct {
	*bufio.Scanner
}

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &scanner{s}
}

func (s *scanner) scanStr() string {
	s.Buffer(make([]byte, bufsiz), bufsiz)
	if !s.Scan() {
		panic("scan failed")
	}
	return s.Text()
}

func (s *scanner) scanInt() int {
	if !s.Scan() {
		panic("scan failed")
	}
	i, err := strconv.Atoi(s.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type writer struct {
	*bufio.Writer
}

func newWriter(wr io.Writer) *writer {
	w := bufio.NewWriter(wr)
	return &writer{w}
}

func (w *writer) printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(w, f, args...)
}

func (w *writer) println(args ...interface{}) (int, error) {
	return fmt.Fprintln(w, args...)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<tuple<ll,ll>> vtl;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

void solve(){
    ll n;
    cin>>n;
    vl a(n);
    vl s,t;
    rep(i,n){
        cin>>a[i];
        if(i%2==0)s.push_back(a[i]);
        else t.push_back(a[i]);
    }
    if(n%2==0){
        cout<<t[t.size()-1];
    for(ll i=t.size()-2;i>=0;i--){
        cout<<" "<<t[i];
    }
    rep(i,s.size())cout<<" "<<s[i];
    }
    else {
        cout<<s[s.size()-1];
    for(ll i=s.size()-2;i>=0;i--){
        cout<<" "<<s[i];
    }
    rep(i,t.size())cout<<" "<<t[i];
    }
}

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


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

int main()
{
    int n;
    char s[4];
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3])
        cout<<"No"<<endl;
    else if((s[0]==s[1]&&s[2]==s[3])||(s[0]==s[2]&&s[1]==s[3])||(s[0]==s[3]&&s[1]==s[2]))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
int main(){
    init();

    ll N;cin>>N;
    ll F[N][10];
    for(int i=0;i<N;i++){
        for(int j=0;j<10;j++){
            cin>>F[i][j];
        }
    }


    ll P[N][11];

    ll ans=-1*INF;

    for(int i=0;i<N;i++){
        for(int j=0;j<11;j++){
            cin>>P[i][j];
        }
    } 

    for(int s=1;s<(1<<10);s++){
        ll data=0;
        for(int i=0;i<N;i++){
            //店iと被っている個数
            ll num=0;
            for(int j=0;j<10;j++){
                if((s>>j)&1){
                    if(F[i][j]==1)num++;
                }
            }
            data+=P[i][num];
        }
        ans=max(ans,data);
    }

    cout<<ans<<endl;      
}

Measured memory_bytes: 256
type set = Set of char * int ;;
let suit_list = ["S"; "H"; "C"; "D"]

let rec  make_set suit num res =
  if num = 0 then res
  else make_set suit (num-1) ((suit, num) :: res ) ;;
  
let rec make_lst = function
    [] -> []
  | first :: rest -> (make_set first 13 []) @ (make_lst rest) ;;

let all_cards = make_lst suit_list ;;

let rec delete a = function
    [] -> []
  | x :: rest -> if a = x then delete a rest
                 else x :: (delete a rest) ;;

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let pairs = Array.init n (fun _ -> Scanf.scanf "%s %d\n" (fun s n -> s, n)) in
  Array.fold_left (fun lst a -> delete a lst) all_cards pairs
  |> List.iter (fun (x, y) -> Printf.printf "%s %d\n" x y ) ;;


Measured memory_bytes: 2472
n,s = map(int,input().split())
a = list(map(int,input().split()))
mod = 998244353
rui = []
now = 0
pl = []
for i in range(n):
    now += a[i]
    rui.append(now)
l = [[0 for i in range(s)] for i in range(n)]
ans = 0
for i in range(n):
    if a[i] < s:
        l[i][a[i]] += i+1
        l[i][a[i]] %= mod
    elif a[i] == s:
        ans += i*(n-i-1)
        ans += n
        ans %= mod
    for j in range(s):
        if i > 0:
            if l[i-1][j] > 0:
                if j+a[i] < s:
                    l[i][j+a[i]] += l[i-1][j]
                    l[i][j+a[i]] %= mod
                elif j+a[i] == s:
                    ans += l[i-1][j]*(n-i)
                    ans %= mod
                l[i][j] += l[i-1][j]
                l[i][j] %= mod
print(ans)

Measured memory_bytes: 120284
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

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

  string s;
  cin>>s;
  for(auto c:s){
    if(c=='7'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;

  return 0;
}




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

from math import factorial

cn = 0
cm = 0

if n >= 2:
    cn = factorial(n) // (factorial(n - 2) * factorial(2))

if m >= 2:
    cm = factorial(m) // (factorial(m - 2) * factorial(2))

print(int(cn+cm))

Measured memory_bytes: 3060
N, K = map(int, input().split())
A = list(map(int, input().split()))
cnt = [0 for i in range(N)]
for i in range(N):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            cnt[i] += 1

if K == 1:
    print(sum(cnt))
else:
    total = sum(cnt) * K
    cnt2 = [0 for i in range(N)]
    for i in range(N):
        for j in range(N):
            if A[i] > A[j]:
                cnt2[i] += 1
    for i in range(N):
        total = (total + cnt2[i] * K * (K - 1) // 2) % (10 ** 9 + 7)
    print(total)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  double A;
  cin >> A;
  cout << 2*A*3.1415 << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,a[200005],ans;
int main()
{
    //IOS;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    ans=a[n];
    for(int i=2;i<=n-1;i++)
    {
        ans+=a[n-i/2];
    }
    cout<<ans<<endl;
    /*
    if(n==2)
    {
        cout<<a[n]<<endl;
    }
    else if(n==3)
    {
        cout<<a[n]+a[n-1]<<endl;
    }
    else if(n==4)
    {
        cout<<a[n]+a[n-1]+a[n-1]<<endl;
    }
    else if(n>=5)
    {
        ans=a[n]+a[n-1]+a[n-1];
        for(int i=1;i<=n-4;i++)
        {
            ans+=a[n-i-1];
        }
        cout<<ans<<endl;
    }*/
    return 0;
}
/*
AC x 3
WA x 1
TLE x 2
RE x 0

*/


Measured memory_bytes: 5180
def F(X):
    if X % 4 == 1:
        return 1
    if X % 4 == 2:
        return X + 1
    if X % 4 == 3:
        return 0
    if X % 4 == 0:
        return X


def test():
    x = 0
    for i in range(1, 50):
        x ^= i
        print(i, ":", x)


if __name__ == "__main__":
    A, B = map(int, input().split())
    if A == 0:
        print(F(B))
    else:
        print(F(B) ^ F(A-1))

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

ll x;

ll solve(){
    if(x % 11 == 0){
        return 2 * (x / 11);
    }else if(x % 11 <= 6){
        return 2 * (x / 11) + 1;
    }else{
        return 2 * (x / 11) + 2;
    }
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> x;
    cout << solve() << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,a,b,m=0,c=0,i;
  scanf("%d %d",&n,&b);
  for(i=1;i<n;i++){
    scanf("%d",&a);
    if(b>=a)c++;
    else   c=0;
    if(c>m)m=c;
    b=a;
  }
  if(c>m)m=c;
  printf("%d\n",m);
  return 0;
}


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

typedef long long ll;

using namespace std;

void solve() {
    int n;

    cin >> n;
    vector<int> dp(n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int i = 1; i < n; i++) {
        if (i == 1) {
            dp[i] = abs(a[i] - a[i-1]);
            continue;
        }
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    }

    cout << dp[n-1] << endl;
}


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


Measured memory_bytes: 1024
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;

const int MAX_N = 100000;
const int MAX_M = 100000;
const int MAX_Z = 100;
int N = 0;
int M = 0;

void input_NM(void);
void input_XYZ(void);
void init_unionfind(void);
int root(int);
void unite(int, int);

int par[MAX_N];
int check[MAX_N];

int main()
{
    input_NM();
    input_XYZ();
    for (int i = 0; i < N; i++) {
        check[i] = 0;
    }

    for (int i = 0; i < N; i++) {
        check[root(i)] = 1;
    }

    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += check[i];
    }

    cout << sum;
    return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します

/// <summary>
/// NとMを入力させるだけの関数
/// </summary>
void input_NM(void) {
    cin >> N >> M;
}

/// <summary>
/// X,Y,Zを入力し、木構造を作る
/// </summary>
void input_XYZ(void) {
    int x, y, z;
    init_unionfind();
    for (int i = 0; i < M; i++) {
        cin >> x >> y >> z;
        unite(x-1, y-1);
    }
}

/// <summary>
/// parの初期化、全ての要素の親は自分
/// </summary>
void init_unionfind(void) {
    for (int i = 0; i < MAX_N; i++) {
        par[i] = i;
    }
}

/// <summary>
/// データxが∉木の根を再帰で得る
/// </summary>
int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
}

/// xとyの木を併合
void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
}

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

int main(){

  unsigned int *A;
  int num, i;

  scanf("%d", &num);
  
  A = malloc(sizeof(int)*num+1);

  for(i = 1; i <= num; i++){
    scanf("%d", &A[i]);
  }
  
  for(i = 1; i <= num; i++){
    printf("node %d: key = %d, ", i, A[i]);

    if(i/2 != 0){
      printf("parent key = %d, ", A[i/2]);
    }
    
    if(2*i <= num){
      printf("left key = %d, ", A[2*i]);
    }
    if(2*i+1 <= num){
      printf("right key = %d, ", A[2*i+1]);
    }

    printf("\n");
  }
  
  return 0;
}



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

int main(void) {
    char buf[16];
    char *p;
    int bag[3];
    int i;
    int max=0;
    int maxcnt = 1;
    int childa = 0,childb = 0;

    p = fgets(buf, 16, stdin);
    sscanf(buf, "%d %d %d", &bag[0], &bag[1], &bag[2]);

    for(i=0;i<3;i++){
        if(max < bag[i]) {
            max = bag[i];
            maxcnt = i;
        }
    }
    
    for(i=0;i<3;i++) {
        if(i == maxcnt){
            childa += bag[i];
        } else {
            childb += bag[i];
        }
    }

    if(childa == childb) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>

int main(){
    
    size_t n;
    std::cin >> n;

    for(size_t i = 1; i < 10; i++){
        for(size_t j = 1; j < 10; j++){
            if(i * j == n){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "No" << std::endl;
    
    return 0;
}


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

ans = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    l, r = map(int, input().split())
    ans[n-r][l-1] += 1

for	i in range(n-2, -1, -1):
    for	j in range(i+1):
        ans[i - j][j] += ans[i - j + 1][j] + ans[i - j][j + 1] - ans[i - j + 1][j + 1]

tmp = []
for i in range(q):
    p, q = map(int, input().split())
    tmp.append((p, q))

for p, q in tmp:
    print(ans[n-q][p-1])






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

vector<bool> vis;
vector<int> dp;
vector<vector<int> > g;

int dfs(int node){
  vis[node] = true;
  for (int i = 0; i < (int)g[node].size(); i++){
    int vertex = g[node][i];
    if (!vis[vertex]){
      dfs(vertex);
    }
    dp[node] = max(dp[node], dp[vertex] + 1);
  }
  return dp[node];
}

int main(){
  int V, E;
  cin >> V >> E;
  g = vector<vector<int> > (V);
  dp = vector<int> (V, -1);
  vis = vector<bool> (V, false);
  for (int i = 0; i < E; i++){
    int start, end;
    cin >> start >> end;
    start--; end--;
    g[start].push_back(end);
  }
  int ans = 0;
  for (int i = 0; i < V; i++){
    if (!vis[i]){
      ans = max(ans, dfs(i));
    }
  }
  cout << ans + 1 << '\n';
  return 0;
}

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

using namespace std;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vector<ll> p(a), q(b), r(c);
    vector<P> v;
    for (int i = 0; i < a; ++i) {
        cin >> p[i];
        v.emplace_back(p[i], 2);
    }

    for (int i = 0; i < b; ++i) {
        cin >> q[i];
        v.emplace_back(q[i], 1);
    }

    for (int i = 0; i < c; ++i) {
        cin >> r[i];
        v.emplace_back(r[i], 0);
    }

    sort(v.begin(), v.end(), greater<>());

    int cnt = 0;
    int num_r = 0, num_g = 0;
    ll ans = 0;
    for (P& cur : v) {
        if (cur.second == 2) {
            if (num_r < x && cnt < x + y) {
                ++num_r;
                ++cnt;
                ans += cur.first;
            }
        } else if (cur.second == 1) {
            if (num_g < y && cnt < x + y) {
                ++num_g;
                ++cnt;
                ans += cur.first;
            }
        } else {
            if (cnt < x + y) {
                ++cnt;
                ans += cur.first;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 12908
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define ff first
#define ss second

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    if(n==m){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


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

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

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

int main() {
#ifdef Mr_Emrul
        freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul

        ll m, n, x, sum = 0;
        cin >> m >> n;
        for(int i = 1; i <= n; i++) {
                cin >> x;
                sum += x;
        }
        if(sum > m) {
                cout << -1 << endl;
        }
        else {
                cout << m - sum << endl;
        }
        return 0;
}

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

int main () {
    int H, W;
    cin >> H >> W;
    while (H > 0 || W > 0) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        cin >> H >> W;
    }
}


Measured memory_bytes: 3072
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = String.valueOf(n);
    int sum = 0;

    for(int i=0; i<s.length();i++){
      //System.out.println(s.charAt(i));

      sum = sum + s.charAt(i)-48;
      //System.out.println(sum);
    }

    // System.out.println(n);
    // System.out.println(s);

    if(n%sum==0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

  }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int x,a;
	cin>>x>>a;
	if(x<a)cout<<0<<endl;
	else cout<<10<<endl;
	return 0;
}

Measured memory_bytes: 256
// use procontools::prelude::*;
use itertools::Itertools;
use proconio::input;
macro_rules! p {
    ($x:expr) => {
        println!("{}", $x);
    };
}
fn main() {
    input! {n:usize,m:usize,q:usize,
        abcd:[(usize,usize,usize,usize);q]
    }
    let cm = (1..=m).combinations_with_replacement(n);
    let mut ans = 0usize;
    for v in cm {
        let mut tmp = 0;
        for &(a, b, c, d) in &abcd {
            if v[b - 1] - v[a - 1] == c {
                tmp += d;
            }
        }
        ans = ans.max(tmp);
    }
    p!(ans);
}


Measured memory_bytes: 2192
function main(input) {
  // 入力値の分離
  const t = 1000;
  ans = Number(input % t);
  if (ans !== 0){
    ans = 1000 - ans;
  }
  console.log(parseInt(ans));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));parseInt

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

using namespace std;

#define int long long
int asd[1234];


main() {
  string s; cin >> s;
  int n = s.size();
  int ans = n * (n - 1) / 2;
  int fl = -1;
  for (int i = 0; i < n; i++) {
    asd[s[i]]++;
    if (fl != s[i]) {
      fl = -2;
    }
    if (fl == -1) {
      fl = s[i];
    }
  }
  for (int i = 'a'; i <= 'z'; i++) {
    ans -= (asd[i] * (asd[i] - 1) / 2);
  }
  if (fl == -2) ans++;
  printf("%lld", ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll x;
    cin >> x;
    ll flag = 0;
    for(ll a = -1000; a <= 1000; a++){
        for(ll b = -1000; b <= 1000; b++){
            if((a*a*a*a*a) - (b*b*b*b*b) == x){
                cout << a << " " << b << endl;
                flag = 1;
                break;
            }
        }
        if(flag == 1){
            break;
        }
    }

}

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

int main(){
    int N = 0;
    int K = 0;
    
    cin >> N >> K;
    vector<int> h(N);

    int in, itr = 0;

    while(cin >> in){
        h[itr] = in;
        itr++;
        if(itr >= N){
            break;
        }

    }

    int ans = 0;
    for(auto it = h.begin(); it !=h.end(); ++it){
        if(*it >= K){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main() {
	int s;
	int i = 1;
	cin >> s;
	if(s == 1||s==2||s==4) {
		cout << 4 << endl;
		return 0;
	}
	vector<double> a(1000001);
	while(1) {
		if(s % 2 == 0)
			s /= 2;
		else 
			s = s * 3 + 1;
		a.at(s) += 1;
		if(a.at(s)>1) {
			cout << i+1 << endl;
			return 0;
		}
		++i;
	}
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;cin>>x;
    int ans=1;
    for(int i=2;i<x;i++){
        int p=2;
        while(pow(i,p)<=x){
            int tmp=pow(i,p);
            ans=max(ans,tmp);
            p++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <utility>
using namespace std;

int main() {
	string s;
	cin >> s;
	int lose = 0;
	for (int i = 0; i < s.size();i++) {
		if (s[i] == 'x')lose++;
	}
	if (lose < 8)cout << "YES" << endl;
	if (lose >= 8)cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#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,D,tmp,d[500000],Q,q,memo[500000],now=1;
bool ans[500000];

signed main() {
    cin >> n >> D;tmp = D;
    rep(i,n) {
        cin >> d[i];
        if (tmp*2 > d[i]) tmp = abs(tmp-d[i]);
        memo[i] = tmp;
    }
    cin >> Q;
    for(int i=n-1;i>0;--i) {
        if (memo[i-1] >= now) ans[i] = true;
        if (2*now > d[i]) now += d[i];
    }
    if (D >= now) ans[0] = true;
    rep(i,Q) {
        cin >> q;q--;
        if (ans[q]) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}



Measured memory_bytes: 10240
import math

def f(n):
    cnt = 0
    while n != 0:
        n //= 2
        cnt += 1
    return max(cnt,1)

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

cnt = f(k)
ans = 0
num = n
for i in range(n):
    while cnt != 0 and k / (i+1) <= 2**(cnt - 1):
        cnt -= 1
    ans += (1 / num)*math.pow(0.5,cnt)
print(ans)


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

using namespace std;

int main(){

	int N,M;

	cin >> N>>M;

	int P[M+1];
	int Y[M+1];
	map<int,int> year;//年代、市の番号
	
	for(int i=1;i<=M;i++){
		cin >> P[i] >>Y[i];
		year[Y[i]]=i;
	}
	
	int a[N+1];//初期化をすべき
	for(int i=0;i<N+1;i++){
		a[i] = 0;
	}
	
	map<int,pair<int,int>> ans;
	
	
	//年代ごとに調査を行う
	for(auto x:year){
		int i=x.second;
		a[P[i]]++;
		
		//000p[i]000a[i]が答えになる
		
		ans[i] = make_pair(P[i],a[P[i]]);
			
	}
	

	for(auto y:ans){
		int a = y.second.first;
		int b = y.second.second;
		
		std::cout << std::setfill('0') << std::right << std::setw(6) << a; 
		std::cout << std::setfill('0') << std::right << std::setw(6) << b;
		cout <<endl; 	
	
	
	}


	return 0;

}

Measured memory_bytes: 13568
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define ll long long
#define ull unsigned long long

#define PI (3.1415926535897932)
#define eps 1e-8

void solve(ll N) {
	int cnt = -2; int fwd[101] = {};

	for (ll i = N; i > 0; i >>= 1) {
		cnt++;
		if (i & 1) {
			cnt++;
			fwd[cnt] = 1;
		}
	}

	cout << cnt + 100 << endl;
	FOR(i, 1, 101)cout << i << " ";
	RFOR(i, 0, cnt) {
		if (fwd[cnt - i - 1] == 1)cout << i + 1 << " ";
	}
	FOR(i, 0, cnt) {
		if (fwd[cnt - i - 1] == 0)cout << i + 1 << " ";
	}
	cout << endl;
}

int main() {
	ll N;
	cin >> N;
	solve(N + 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define hell 1000000007
#define pb push_back

int main()
{
    int n;cin>>n;
    ll ar[3*n];
    for(int i=0; i<3*n; i++) cin>>ar[i];
    priority_queue<ll, vector<ll>,greater<ll>>a,ta; //min heap
    priority_queue<ll>b,tb;  //max heap
    ll l[n+1],r[n+1]; l[0]=0;
    for(int i=0; i<n; i++) a.push(ar[i]);
    ta=a;
    while(!ta.empty())
    {
        l[0]+=ta.top(); ta.pop();
    }
    ta=a;
    for(int i=0; i<n; i++)
    {
        if(ar[n+i]>ta.top()) { l[i+1]=l[i]-ta.top()+ ar[n+i]; ta.pop(); ta.push(ar[n+i]); }
        else l[i+1]=l[i];
    }
    for(int i=0; i<n; i++)b.push(ar[3*n-i-1]);
    tb=b;
    r[n]=0;
    while(!tb.empty())
    {
        r[n]+=tb.top(); tb.pop();
    }
    tb=b;
    for(int i=0; i<n; i++)
    {
        if(ar[2*n-1-i]<tb.top()) { r[n-1-i]=r[n-i]-tb.top()+ar[2*n-1-i]; tb.pop(); tb.push(ar[2*n-1-i]); }
        else r[n-1-i]=r[n-i];
    }
    ll res=l[0]-r[0];
    for(int i=1; i<n+1; i++)
        res=max(res, l[i]-r[i]);
    cout<<res;
   /*for(int i=0; i<n+1; i++) cout<<l[i]<<" ";
    cout<<endl;
    for(int i=0; i<n+1; i++) cout<<r[i]<<" ";*/
    return 0;
}


Measured memory_bytes: 7412
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int A, B, C, D, Left, Right;
      cin >> A >> B >> C >> D;
      Left = A+B;
      Right = C + D;
      
      if (Left > Right){
        cout << "Left" << endl;
      }
      
      else if (Left < Right){
        cout << "Right" << endl;
      }
      
      else if (Left == Right){
        cout << "Balanced" << endl;
      }
      
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
  ll p, q, r;
  cin >> p >> q >> r;

  cout << min((ll)min(p + q, p + r), q + r);

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long M = inputArray[1];

			var Aarray = retreiveLongArray();

			var twoDictionary = new Dictionary<long, List<long>>();
			
			for (int i = 0; i < N; i++) {

				var inp = Aarray[i];
				var two = (long)Math.Floor(Math.Log10(inp) / Math.Log10(2));

				if (!twoDictionary.ContainsKey(two)) {
					twoDictionary.Add(two, new List<long>{ inp });
				}
				else {
					twoDictionary[two].Add(inp);
				}
			}
			var waribiki = M;
			for (int two = 1000; two >= 0; two--) {
				
				if (twoDictionary.ContainsKey(two)) {

					var tList = twoDictionary[two];
					
					//割引券が余る場合
					if (waribiki > tList.Count()) {
						waribiki -= tList.Count();//割引券消費

						var newList = tList.Select(x => x / 2).ToList();
						if (twoDictionary.ContainsKey(two-1)) {
							twoDictionary[two - 1].AddRange(newList);
						}
						else {
							twoDictionary.Add(two - 1, newList);
						}
						twoDictionary[two] = new List<long>();
					}
					else {//割引券を使い切る場合
						var sortedList = tList.OrderByDescending(x => x).ToList();
						for (int i = 0; i < waribiki; i++) {
							sortedList[i] = sortedList[i] / 2;
						}

						if (twoDictionary.ContainsKey(two - 1)) {
							twoDictionary[two - 1].AddRange(sortedList);
						}
						else {
							twoDictionary.Add(two - 1, sortedList);
						}
						twoDictionary[two] = new List<long>();
						break;
					}
				}

			}

			long sum = 0;
			foreach (var item in twoDictionary) {
				sum += item.Value.Sum();
			}


			//答えの出力
			var ans = sum;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 41732
import Data.List
f l a n=if null l then (n+1) else if a==head l then f (tail l) a (n+1) else mod ((n+1)*f (tail l) (head l) 1) 1000000007
main=do
 n<-getLine
 s<-sort<$>getLine
 print$(f (tail s)(head s)1) -1

Measured memory_bytes: 12668
//
// Created by yamunaku on 2020/01/13.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;


int main(){
    // CFS;
    int h, w;
    cin >> h >> w;
    vector<string> f(h);
    rep(i, h) cin >> f[i];
    int ans = 0;
    vi vx = {0, 1, 0, -1};
    vi vy = {1, 0, -1, 0};
    rep(x1, h){
        rep(y1, w){
            if(f[x1][y1] == '#') continue;
            rep(x2, h){
                rep(y2, w){
                    if(f[x2][y2] == '#') continue;
                    mti dist(h, vi(w, 100000));
                    queue<pair<int, int>> q;
                    q.emplace(x1, y1);
                    dist[x1][y1] = 0;
                    while(!q.empty()){
                        auto now = q.front();
                        q.pop();
                        rep(i, 4){
                            int nx = now.first + vx[i];
                            int ny = now.second + vy[i];
                            if(nx < 0 || h <= nx || ny < 0 || w <= ny) continue;
                            if(f[nx][ny] == '#') continue;
                            if(dist[nx][ny] != 100000) continue;
                            dist[nx][ny] = dist[now.first][now.second] + 1;
                            q.emplace(nx, ny);
                        }
                    }
                    ans = max(ans, dist[x2][y2]);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
local mfl = math.floor
local n = io.read("*n")
local edge = {}
for i = 1, n do edge[i] = {} end
for i = 1, n - 1 do
  local a, b = io.read("*n", "*n")
  table.insert(edge[a], b)
  table.insert(edge[b], a)
end

local tasks = {1}
local asked = {false}
local len = {0}
for i = 2, n do
  asked[i] = false
  len[i] = 0
end
local done = false
while not done do
  local src = tasks[#tasks]
  if asked[src] then
    table.remove(tasks)
  else
    asked[src] = true
    for i = 1, #edge[src] do
      local dst = edge[src][i]
      if not asked[dst] then
        len[dst] = len[src] + 1
        table.insert(tasks, dst)
        if dst == n then
          done = true
          break
        end
      end
    end
  end
end
local halflen = mfl(len[n] / 2)
local pos1, pos2 = 1, n
for i = 1, #tasks do
  local pos = tasks[i]
  local l = len[pos]
  if l == halflen then pos1 = pos
  elseif l == halflen + 1 then pos2 = pos end
end
tasks = {pos1, pos2}
for i = 1, n do asked[i] = 0 end
asked[pos1], asked[pos2] = 1, 2
while 0 ~= #tasks do
  local src = tasks[#tasks]
  table.remove(tasks)
  for i = 1, #edge[src] do
    local dst = edge[src][i]
    if 0 == asked[dst] then
      asked[dst] = asked[src]
      table.insert(tasks, dst)
    end
  end
end
local cnt = {0, 0}
for i = 1, n do
  cnt[asked[i]] = cnt[asked[i]] + 1
end
print(cnt[1] > cnt[2] and "Fennec" or "Snuke")


Measured memory_bytes: 11504
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <bitset>

#define reps(i,s,n) for(ll (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<ll> vec(n);
    rep(i,n) cin >> vec[i];
    vector<ll> zero(63),one(63);
    ll ans = 0;

    rep(i,n){
        bitset<63> bs(vec[i]);
        rep(i,63){
            if(bs[i] == true) one[i]++;
            else zero[i]++;
        }
    }

    rep(i,63){
        ll pow = modpow(2,i,MOD);
        pow = pow % MOD;
        
        ll cnt = one[i] * zero[i];
        ll sub = ((pow % MOD) * (cnt % MOD)) % MOD;
        ans = (ans + sub) % MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
/*input
5 6
1 4 5 9 8
3 1
3 2
5 4
1 5
2 4 5
1 2 9
2 3 4
1 5 1
2 2 1
2 5 5


*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin >> n;
  ll ans = n * (n - 1) / 2;
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i > 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define PI 3.14159265358979

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

ll MOD = 1000000007;

int main()
{
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> x(A);
    vector<ll> y(B);
    vector<ll> z(C);
    REP(i, A) cin >> x[i];
    REP(i, B) cin >> y[i];
    REP(i, C) cin >> z[i];
    sort(ALL(x));
    sort(ALL(y));
    sort(ALL(z));
    reverse(ALL(x));
    reverse(ALL(y));
    reverse(ALL(z));
    vector<ll> tmp;
    REP(i, X) tmp.push_back(x[i]);
    REP(i, Y) tmp.push_back(y[i]);
    sort(ALL(tmp));
    ll cnt = 0;
    REP(i, C) {
        if (z[i] > tmp[cnt]) {
            tmp[cnt] = z[i];
            cnt++;
        }
    }
    ll sum = 0;
    for(ll t : tmp) sum += t;
    PRINT(sum);
    return 0;
}


Measured memory_bytes: 4724
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ryouri = [a, b, c, d, e]

ryouri_amari = [x % 10 for x in ryouri]

idx = 0
min_amari = 10

for i, amari in enumerate(ryouri_amari):
    if amari == 0:
        continue
    elif amari < min_amari:
        min_amari = amari
        idx = i

goukei = 0

for i, r in enumerate(ryouri):
    if i == idx:
        goukei += r
    elif r % 10 == 0:
        goukei += r
    else:
        goukei += r + (10 - (r % 10))

print(goukei)


Measured memory_bytes: 3064
//
//  lcs.cpp
//  
//
//  Created by David Sarpong on 4/25/20.
//

#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

string lcs(string s, string t, int N, int M) {
    int dp[N + 1][M + 1];
    
    for (int i = 0; i <= N; i++) {
        dp[i][M] = 0;
    }
    
    for (int i = 0; i <= M; i++) {
        dp[N][i] = 0;
    }
    
    // if s.at(i) == s.at(j): dp[i][j] = 1 + dp[i + 1][j + 1];
    // if s.at(i) != s.at(j): dp[i][j] = max(dp[i + 1][j], dp[i][j + 1])
    
    for (int i = N - 1; i >= 0; i--) {
        for (int j = M - 1; j >= 0; j--) {
            // if characters match
            if (s.at(i) == t.at(j)) {
                dp[i][j] = 1 + dp[i + 1][j + 1];
            }
            // if they dont match
            else {
                dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
    }
    
    
    // Building the solution the dp
    // this essentially follows the recurrence
    string r("");
    int i = 0;
    int j = 0;
    
    while (i < N && j < M) {
        // if same, append and increment both
        if (s.at(i) == t.at(j)) {
            r += s.at(i);
            i++;
            j++;
        }
        // else increment which ever is better.
        else if (dp[i + 1][j] > dp[i][j + 1]) {
            i++;
        }
        else {
            j++;
        }
    }
    
    return r;
}

int main(int argc, char** argv) {
    string s, t;
    cin >> s >> t;
    
    cout << lcs(s, t, s.size(), t.size()) << endl;
    
    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
int a[1000005];
int cnt[1000005];
bool p[1000005];

int main(void) {
	int n; cin >> n;
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	for(int i=2;i<=1000000;i++) p[i] = true;
	for(int i=2;i<=1000000;i++) {
		if(p[i]) {
			for(int j=2*i;j<=1000000;j+=i) p[j] = false;
		}
	}
	vector<int> pr;
	for(int i=0;i<n;i++) {
		for(int j=2;j<=sqrt(a[i]);j++) {
			if(!p[j]) continue;
			if(a[i]%j==0) {
				while(a[i]%j==0) a[i]/=j;
				cnt[j]++;
			}
		}
		if(a[i]!=1) cnt[a[i]]++;
	}
	bool ok = false;
	for(int i=2;i<=1000000;i++) {
		if(!p[i]) continue;
		if(cnt[i] == n) {
			cout << "not coprime" << endl;
			return 0;
		}
		if(cnt[i] >= 2) {
			ok = true;
		}
	}
	if(ok) cout << "setwise coprime" << endl;
	else cout << "pairwise coprime" << endl;
	return 0;
}



Measured memory_bytes: 12288
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    int maxi = 0,maxn = 0;
    for(int i = 0;i < N;i++){
        int a,b;
        cin >> a >> b;
        if(maxi < a){
            maxi = a;
            maxn = b;
        }
    }
    cout << maxi + maxn << endl;
}

Measured memory_bytes: 256
def main():
    a, b = input().split()
    i, j = a, b
    for _ in range(1, int(j)):
        a += i
    for _ in range(1, int(i)):
        b += j
    ans = [a,b]
    print(sorted(ans)[0])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
from collections import deque
s1=input()
s2=input()
n=len(s1)
m=len(s2)
dp=[[0]*(m+1) for i in range(n+1)]
for i in range(n+1):
    for j in range(m+1):
        if(i==0 or j==0):
            dp[i][j]=0
        else:
            if(s1[i-1]==s2[j-1]):
                dp[i][j]=1+dp[i-1][j-1]
            else:
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])
x=n
y=m
ans=""
while x>0 and y>0:
    if(s1[x-1]==s2[y-1]):
        ans+=s1[x-1]
        x-=1
        y-=1
    else:
        if(dp[x-1][y]>dp[x][y-1]):
            x-=1
        else:
            y-=1
            
'''
if(x==0):
    for i in range(y,-1,-1):
        if(s1[x]==s2[i]):
            ans+=s1[x]
            break
elif(y==0):
    for i in range(x,0,-1):
        if(s1[i]==s2[y]):
            ans+=s1[i]
            break
'''
'''
aabaaa
ababba
'''
print(ans[::-1])

Measured memory_bytes: 111964
from itertools import combinations

def f(in_A,in_B,in_C,A,B,C,ex_l,counter):
    if (counter == len(ex_l)):
        return abs(in_A-A)+abs(in_B-B)+abs(in_C-C)
    else:
        tmp = ex_l[counter]
        counter +=1
        a1 = f(in_A+tmp,in_B,in_C,A,B,C,ex_l,counter)+10
        a2 = f(in_A,in_B+tmp,in_C,A,B,C,ex_l,counter)+10
        a3 = f(in_A,in_B,in_C+tmp,A,B,C,ex_l,counter)+10
        a4 = f(in_A,in_B,in_C,A,B,C,ex_l,counter)
    return min(a1,a2,a3,a4)

N,A,B,C=map(int,input().split())
l = []
for i in range(N):
    l.append(int(input()))
in_l = list(map(list,combinations(l,3)))
ex_l = [l[:] for _ in range(len(in_l))]
for i in range(len(in_l)):
    ex_l[i].remove(in_l[i][0])
    ex_l[i].remove(in_l[i][1])
    ex_l[i].remove(in_l[i][2])

mp = []
for i in range(len(in_l)):
    mp.append(f(in_l[i][0],in_l[i][1],in_l[i][2],A,B,C,ex_l[i],0))
    mp.append(f(in_l[i][0],in_l[i][1],in_l[i][2],A,C,B,ex_l[i],0))
    mp.append(f(in_l[i][0],in_l[i][1],in_l[i][2],B,A,C,ex_l[i],0))
    mp.append(f(in_l[i][0],in_l[i][1],in_l[i][2],B,C,A,ex_l[i],0))
    mp.append(f(in_l[i][0],in_l[i][1],in_l[i][2],C,A,B,ex_l[i],0))
    mp.append(f(in_l[i][0],in_l[i][1],in_l[i][2],C,B,A,ex_l[i],0))
mp = min(mp)
print(mp)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(a==4 || a==6 || a==9 || a==11){
        if(b==4 || b==6 || b==9 || b==11){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(a==2){
        if(b==2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(b==2 || b==4 || b==6 || b==9 || b==11){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256