akhauriyash/Code-Regression huggingface dataset:
// JavaProgram.cpp
// Author : Priydarshi Singh (@dryairship)
// One cat just leads to another. One bug leads to two others.

#include <bits/stdc++.h>
using namespace std;

// I like my types defined.
typedef long long           ll;
typedef pair<int, int>      pii;
typedef pair<ll, ll>        pll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef vector<pii>         vii;
typedef vector<pll>         vll;
typedef set<int>            si;
typedef map<string, int>    msi;
typedef map<int, int>       mii;

// Traditional science is all about finding "hashtag define"s.
#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n, c)        for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define fill1(a)            memset(a, -1, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

// When you realize MOD > INF...
int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const ll LINF    =          1e18;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

// I'D SPAM. Hehe.
ll gcdEx                    (ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;} 
ll x1,y1,gcd=gcdEx          (b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)         {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
ll modD(ll a, ll b)         {return (modI(b,MOD)*(a%MOD))%MOD;}
ll modS(ll a, ll b)         {return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;} y=y>>1; x=(x*x)%MOD;} return r;}
ll modA(ll a, ll b)         {return ((a%MOD)+(b%MOD))%MOD;}
ll modM(ll a, ll b)         {return ((a%MOD)*(b%MOD))%MOD;}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vi adj[100005];
int dp[100005];

int dfs(int u){
    if(dp[u]) return dp[u];
    int mx=0, cn;
    for(int v : adj[u]){
        cn = dfs(v);
        mx = max(mx, cn);
    }
    mx++;
    return dp[u]=mx;
}

void solve(int TEST_CASE){
    int n, m, u, v;
    cin >> n >> m;
    fr(i,m){
        cin >> u >> v;
        u--; v--;
        adj[u].pb(v);
    }
    fill(dp);
    fr(i,n) dfs(i);
    int mx=0;
    fr(i,n) mx = max(mx, dp[i]);
    cout << mx-1;
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

Measured memory_bytes: 11444
/**
*    author:  boutarou
*    created: 14.06.2020 21:02:54
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const double PI = 3.1415926535897932;

bool used[105];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x, n;
	int a[105];

	cin >> x >> n;
	rep(i, n) cin >> a[i];
	int mi = 1000;
	sort(a, a + n);
	rep(i, n) {
		used[a[i]] = true;
	}
	rep(i, 102) {
		if (!used[i]) {
			chmin(mi, abs(x - i));
		}
	}
	rep(i, 102) {
		if (!used[i] && abs(x - i) == mi) {
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}

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

typedef long long ll;

vector<int> Zalgorithm(string S) {
    vector<int> A(S.size());
    A[0] = S.size();
    int i = 1, j = 0;
    while (i < S.size()) {
        while (i+j < S.size() && S[j] == S[i+j]) ++j;
        A[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
        i += k; j -= k;
    }
    return A;
}

int main() {
    string s, t;
    cin >> s >> t;
    string u = t;
    rep(i, (2 * s.size() + t.size() - 2) / s.size()) {
        u += s;
    }
    //cout << "u=" << u << "\n";
    auto z = Zalgorithm(u);
    /*
    rep(i, z.size()) {
        cout << "z[" << i << "]=" << z[i] << "\n";
    }
    */
    vector<bool> match(s.size(), false);
    rep(i, s.size()) {
        if (z[t.size() + i] >= t.size()) match[i] = true;
    }
    //rep(i, s.size()) if (match[i]) cout << i << "\n";
    vector<int> l(s.size(), 1e9);
    queue<pair<int, int>> q;
    rep(i, s.size()) {
        if (!match[i]) q.push(make_pair(i, 0));
    }
    int v = s.size() - t.size();
    while (v < 0) v += s.size();
    while(!q.empty()) {
        auto p = q.front();
        q.pop();
        l[p.first] = p.second;
        int j = (p.first + v) % s.size();
        if (match[j]) {
            q.push(make_pair(j, p.second + 1));
        }
    }
    int ans = 0;
    rep(i, s.size()) {
        ans = max(ans, l[i]);
    }
    if (ans == 1e9) ans = -1;
    cout << ans << "\n";
}

Measured memory_bytes: 17168
#include<bits/stdc++.h>
            using namespace std;
             
            #define int long long
            #define ll long long
            #define pb emplace_back
            #define mp make_pair
            #define f(i,a,n) for(int i=a ; i<n ; i++)
            #define F first
            #define S second
            #define E "\n"
            #define fast ios:: sync_with_stdio(false),cin.tie(0);
            
            
            int lcm(int x,int y)
            {
                  int t=__gcd(x,y);
                  return (x*y)/t;
            }
            int prime[(int)1e6+1]={0};
            void pr()
            {
                  prime[0]=1;
                  prime[1]=1;
                  for(int i=2;i<(int)1e6+1;i++)
                  {
                        if(prime[i]==0)
                        {
                              
                              for(int j=i*2;j<(int)1e6+1;j=j+i)
                              {
                                    prime[j]=1;
                              }
                        }
                  }
                  
            }
            
           int32_t main()
              {
                    int n,m;
                    cin >> n >> m;
                    int g=  __gcd(n,m);
                    ll ans = 1;
                    ll temp = 0;
                    for(int i=2;i*i<=g;i++)
                    {
                          temp = 0;
                          while(g%i==0)
                          {
                                g = g/i;
                                if(temp==0)    temp=1,ans++;
                          }
                    }
                    if(g!=1)   ans++;
                    cout<<ans;
            }

Measured memory_bytes: 256
def CountingSort(A, B, k):
    C = [0 for i in range(k+1)]
    for i in range(len(A)):
        C[A[i]] += 1
    for i in range(1,k+1):
        C[i] += C[i-1]
    for i in range(len(A)-1,-1,-1):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1
    return B

n = int(input())
A = list(map(int, input().split()))
k = max(A)
B = [0 for i in range(n)]
CountingSort(A, B, k)

for i in range(len(B)):
    if i<len(B)-1:
        print(B[i],end=' ')
    else:
        print(B[i])


Measured memory_bytes: 224384
#include <iostream>
#include <limits.h>
#include <string>
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    int mn=INT_MAX;
    for(int i=0; i<=(s.length()-t.length()); i++){
        int temp=i;
        int count=0;
        for(int j=0; j<t.length(); j++){
            if(temp>=s.length()){
                break;
            }
            if(s[temp]==t[j]){
                count++;
            }
            temp++;
        }
        if((t.length()-count)<mn){
            mn=t.length()-count;
        }
    }
    cout << mn;
    return 0;
}

Measured memory_bytes: 3636
n = gets.to_i
a = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)

beated_monsters = 
  b.map.with_index do |saver, i|
    beated_count = (a[i] + a[i + 1] > saver ? saver : a[i] + a[i + 1])
    if a[i] < beated_count
      (a[i + 1] -= (beated_count - a[i])) > 0 || a[i + 1] = 0
    end
    beated_count
  end

puts beated_monsters.inject(:+)


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

const int mod = 100000;
int main(){
    int n,m,s;
    int dp[50][3001];
    while(cin>>n>>m>>s,n){
        memset(dp,0,sizeof(dp));
        dp[0][0]=1;
        for(int i=1;i<=m;++i){
            for(int j=n*n-1;j>=0;--j){
                for(int k=0;k<=s-i;++k){
                    dp[j+1][k+i] +=dp[j][k];
                    dp[j+1][k+i] %= mod;
                }
            }
        }
        cout<<dp[n*n][s]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(int argc, char const *argv[])
{
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n", (a + b) % 24);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
struct Unionfind{
    vector<int> rank,p;
    Unionfind(){}
    Unionfind(int size){
	rank.resize(size,0);
	p.resize(size,0);
	for(int i=0;i<size;i++){
	    makeSet(i);
	}
    }
    void makeSet(int x){
	p[x]=x;
	rank[x]=0;
    }
    bool same(int x,int y){
	return (findSet(x)==findSet(y));
    }
    void unite(int x,int y){
	link(findSet(x),findSet(y));
    }
    void link(int x,int y){
	if(rank[x]>rank[y]){
	    p[y]=x;
	}
	else{
	    p[x]=y;
	    if(rank[x]==rank[y]){
		rank[y]++;
	    }
	}
    }
    int findSet(int x){
	if(x!=p[x]){
	    p[x]=findSet(p[x]);
	}
	return p[x];
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    int com,x,y;
    cin>>n>>q;
    Unionfind un(n);
    rep(i,q){
	cin>>com>>x>>y;
	if(com==0){
	    un.unite(x,y);
	}
	else{
	    if(un.same(x,y)){
		cout<<1<<'\n';
	    }
	    else{
		cout<<0<<'\n';
	    }
	}
    }
    return(0);
}



Measured memory_bytes: 3304
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using IP = pair<int, P>;
using LLP = pair<ll, LP>;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

// template specialization of std::hash for std::pair
namespace std {
template<typename T, typename U>
struct hash<pair<T, U> > {
    size_t operator()(const pair<T, U> &key) const noexcept {
        size_t h1 = hash<T>()(key.first);
        size_t h2 = hash<U>()(key.second);
        return h1 ^ (h2 << 1);
    }
};
} // namespace std

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    size_t sz = v.size();
    os << "[";
    for (size_t i = 0; i < sz-1; i++) {
        os << v[i] << ", ";
    }
    os << v[sz-1] <<  "]";
    return os;
}

template<typename T>
void printArray(T *arr, size_t sz) {
    cerr << "[";
    for (size_t i = 0; i < sz-1; i++) {
        cerr << arr[i] << ",";
    }
    cerr << arr[sz-1] <<  "]" << endl;
}

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

struct Compare {
    //vector<ll> &x_, &y_;
    //Compare(vector<ll> &x, vector<ll> &y): x_(x), y_(y) {}
    //bool operator()(const P &lhs, const P &rhs) {
    //    return x_[lhs.fi]+y_[lhs.se] < x_[rhs.fi]+y_[rhs.se];
    //}
    bool operator()(const int x, const int y) {
        return x < y;
    }
};

// print floating-point number
// cout << fixed << setprecision(12) <<

// }}}

set<ll> s;

void solve()
{
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    REP (i, N) {
        ll a;
        cin >> a;
        if (s.find(a) != s.end()) {
            cout << "NO" << endl;
            return 0;
        }
        s.insert(a);
    }
    cout << "YES" << endl;
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 9600
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    cout << (N + 999) / 1000 * 1000 - N << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void) {
  int a,b,c,d,e;
  for(e=1;;e++){
  scanf("%d %d",&b,&d);
  if(b==0&&d==0)break;
  for(a=1;a<=b;a++){
  for(c=1;c<=d;c++){
    if(a>1&&a<b&&c>1&&c<d)
    printf(".");
    else
    printf("#");
  }
  printf("\n");
  }
  printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2048
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) > *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static size_t countDivisors(const size_t n)
{
	size_t count = 1;

	for (size_t i = 2; i <= n; i++) {
		if (n%i == 0) {
			count++;
		}
	}

	return count;
}

static size_t lrMap[500][500];
static size_t lrMapSum[500][500];

int main(void) {
	size_t N, M, Q;

	scanf("%zu %zu %zu\n", &N, &M, &Q);

	for (size_t from = 0; from < N; from++) {
		for (size_t to = from; to < N; to++) {
			lrMap[from][to] = 0;
		}
	}

	for (size_t i = 0; i < M; i++) {
		size_t L, R;
		scanf("%zu %zu\n", &L, &R);
		lrMap[L - 1][R - 1]++;
	}

	for (size_t l = 0; l < N; l++) {
		for (size_t r = l; r < N; r++) {
			if (l == r) {
				lrMapSum[l][r] = lrMap[l][r];
			}
			else {
				lrMapSum[l][r] = lrMapSum[l][r - 1] + lrMap[l][r];
			}
		}
	}

	for (size_t i = 0; i < Q; i++) {
		size_t p, q;
		scanf("%zu %zu", &p, &q);
		if (i < Q - 1) {
			scanf("\n");
		}
		p--;
		q--;
		size_t count = 0;
		for (size_t l = p; l <= q; l++) {
			count += lrMapSum[l][q] - lrMapSum[l][l] + lrMap[l][l];
		}
		printf("%zu\n", count);
	}

	return 0;
}


Measured memory_bytes: 4736
H, W = map(int, input().split())
canvas = [str(input()) for _ in range(H)]

def check_border(x, y):
  return 0<=x and x<W and 0<=y and y<H

def can_draw(x, y):
  a = 1 if check_border(x-1,y) and canvas[y][x-1]=='#' else 0
  b = 1 if check_border(x+1,y) and canvas[y][x+1]=='#' else 0
  c = 1 if check_border(x,y-1) and canvas[y-1][x]=='#' else 0
  d = 1 if check_border(x,y+1) and canvas[y+1][x]=='#' else 0
  return 0 < a+b+c+d
        

def solve():
  for y in range(H):
    for x in range(W):
      if  ((canvas[y][x]=='#') and (not can_draw(x, y))): return False
  return True

print('Yes' if solve() else 'No')

Measured memory_bytes: 3064
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
sum_a = sum(a)
acc = list(itertools.accumulate(a))
ans = mod
if n == 2:
    print(abs(a[0] - a[1]))
else:
    for i in range(n-1):
        tmp = abs(acc[i] - (acc[-1]-acc[i]))
        ans = min(ans, tmp)
    print(ans)

Measured memory_bytes: 25384
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

string s;
cin>>s;

if(s<="2019/04/30"){
    cout<<"Heisei"<<endl;
}else{
    cout<<"TBD"<<endl;
}



return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
n -= 2
ans = n//11*5

for i in range(n//11*11+1, n+1):
    for j in range(5):
        s = (7*i-6)*9+72+9*j
        if s % 11 == k:
            # print(i, j, s, k)
            ans += 1

print(ans)


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

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

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

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

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

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

fn main() {
    ipt_1_2_d();
}

fn ipt_1_2_d(){
    input!{
        w: i32, h: i32, x: i32, y: i32, r: i32
    }
    let text = if x >= r && y >= r && w >= x+r && h >= y+r {
        "Yes"
    } else { "No" };
    println!("{}", text)
}


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

struct UnionFind {
    vector<int> data;

    UnionFind() = default;

    explicit UnionFind(size_t sz) : data(sz, -1) {}

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y)
            return false;
        if(data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int find(int k) {
        if(data[k] < 0)
            return (k);
        return data[k] = find(data[k]);
    }

    int size(int k) { return -data[find(k)]; }

    bool same(int x, int y) { return find(x) == find(y); }
};

int main() {
    cout << fixed << setprecision(0);

    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        uf.unite(a - 1, b - 1);
    }

    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans = max(ans, uf.size(i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}

#define pb             push_back
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define rep(i, n)  	   for (int i = 0; i < n; ++i)
#define irep(i, a, b)  for (int i = a; i <= b; ++i)
#define repr(i, a, b)  for (int i = a; i >= b; --i)
#define iter(it, x)    for (auto it = x.begin(); it != x.end(); ++it)

using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
const char nl = '\n';
const int inf = 2e9;
const ll INF = (ll)2e18;
const ll mod = 1e9 + 7;
const int N = 2e6 + 15;
int H, W, K;
int ans = 0;
char color[6][6];
int r[6], c[6];

void solve() {
	for (int i = 0; i < (1 << H); ++i) {
		for (int j = 0; j < (1 << W); ++j) {
			int cur = 0;
			for (int a = 0; a < H; ++a) {
				for (int b = 0; b < W; ++b) {
					if (!(i & (1 << a)) and !(j & (1 << b)) and color[a][b] == '#') cur++;
				}
			}
			if (cur == K) ans++;
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> H >> W >> K;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> color[i][j];
		}
	}
	solve();
	cout << ans << nl;
    return 0;
}


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

const int M = 1e9 + 7;
const int INF = 1e9 + 5;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> v(3, vector<int> (n));
	
	for(int i = 0; i < n; i++) {
		cin >> v[0][i] >> v[1][i] >> v[2][i];
	}
	
	
	vector<int> dp(3);
	for(int i = 1; i <= n; i++) {
		vector<int> new_dp(3);
		new_dp[0] = v[0][i-1] + max(dp[1], dp[2]);
		new_dp[1] = v[1][i-1] + max(dp[0], dp[2]);
		new_dp[2] = v[2][i-1] + max(dp[0], dp[1]);
		dp = new_dp;
	}
	
	cout << max({dp[0], dp[1], dp[2]}) << "\n";
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int mxN = 2*1e5, mxM = 2*1e5;
bool visited[mxN+1];
vector<int> adj[mxM+1];



int dfs(int node){
    int cc_size = 1;
    visited[node] = 1;
    for(int child:adj[node]){
        if(!visited[child]){
            cc_size+=dfs(child);
        }
    }
    return cc_size;




}






int main()
{
    int n,m,a,b;
    cin>>n>>m;
    while(m--){
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    int ans = -1;
    int cc = 0;
    for(int i=1;i<=n;i++){
        if(!visited[i]){
            ans = max(ans,dfs(i));
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 24136
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args){
        FastReader scan=new FastReader();
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int n=scan.nextInt();
            int[] arr=new int[n];
            Map<Integer,Integer> bmx=new HashMap<>();
            Map<Integer,Integer> apy=new HashMap<>();
            for(int i=0;i<n;i++){
                arr[i]=scan.nextInt();
                bmx.putIfAbsent(i-arr[i],0);
                bmx.put(i-arr[i],bmx.get(i-arr[i])+1);
                apy.putIfAbsent(i+arr[i],0);
                apy.put(i+arr[i],apy.get(i+arr[i])+1);
            }
            long ans=0;
            for(int i=0;i<n;i++){
                Integer v=apy.get(i-arr[i]);
                if(v!=null){
                    ans+=v;
                }
            }
            out.println(ans);
        }
        out.flush();
        out.close();
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

}


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

a = sorted([aa - i for i, aa in enumerate(a, start = 1)])
b = a[n//2] if n%2 > 0 else (a[n//2-1]+a[n//2])//2
ans = sum([abs(aa - b) for aa in a])
print(ans)


Measured memory_bytes: 26708
import sys
sys.setrecursionlimit(10**9)

def main():
    input = sys.stdin.readline

    mod = 10**9+7
    n = int(input())
    edges = [[] for i in range(n)]
    for i in range(n-1):
        x,y = map(int, input().split())
        x,y = x-1, y-1
        edges[x].append(y)
        edges[y].append(x)

    def rec(cur, prev=None):
        white = 1
        black = 1
        for to in edges[cur]:
            if to == prev:
                continue
            w,b = rec(to, cur)
            white *= (w+b)
            white %= mod
            black *= w
            black %= mod
        return white, black

    w, b = rec(0)
    print((w+b)%mod)

if __name__ == "__main__":
    main()

Measured memory_bytes: 117808
#include <stdio.h>

int main(void){
    //input 
    int N,K;
    scanf("%d%d",&N,&K);
    int h[N];
    for(int i = 0; i < N; i++)
    scanf("%d",&h[i]);

    //culcu
    int count = 0;
    for(int i = 0; i < N; i++){
        if(h[i]>=K){
            count ++;
        }
    }

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



    //printf("Nは%dKは%d\n",N,K);
    
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){

    ll n,dom,ans =0;
    cin >>n;
    if(n%2==1) {
        cout <<0<<"\n";
        return 0;
    }
    dom= 10;
    while((n/dom)!=0){
        ans+=n/dom;
        dom*=5;
    }
    cout << ans<<"\n";
    return 0;
}

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

pair<int, int> a[111111];
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		scanf("%d%d", &a[i].first, &a[i].second);
	sort(a, a + n);
	priority_queue<int> q;
	int x = 0, r = 0;
	for (int i = 1; i <= m; i++) {
		while (x < n&&a[x].first == i)
			q.push(a[x++].second);
		if (q.empty())
			continue;
		r += q.top();
		q.pop();
	}
	cout << r << endl;
	return 0;
}


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

namespace CSharpSample01
{
    
    class Program
    {
        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var dic_fact = new Dictionary<long, bool>();

            for(int i = 0; i <= 1; i++)
            {
                for (int j = 1; j <= Math.Sqrt(A[i]); j++)
                {
                    if (A[i] % j == 0)
                    {
                        if (!dic_fact.ContainsKey(j))
                        {
                            dic_fact[j] = true;
                        }
                        if (!dic_fact.ContainsKey(A[i] / j))
                        {
                            dic_fact[A[i] / j] = true;
                        }
                    }
                }
            }

            var dic_fact_sort = dic_fact.OrderByDescending(x => x.Key);

            
            long max = 1;

            foreach(var s in dic_fact_sort)
            {
                
                long val = s.Key;
                int cnt_not_divi = 0;

                for(int i = 0; i < N; i++)
                {
                    if(A[i] % val != 0)
                    {
                        cnt_not_divi++;
                    }
                }

                if(cnt_not_divi <= 1)
                {
                    max = val;                   
                    break;
                }

            }



            Console.WriteLine(max);

        }
    }
}


Measured memory_bytes: 28508
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, k, s;
    cin >> n >> k >> s;

    vector<int> v;
    if (s == INF) {
        rep(i, k) v.push_back(INF);
        rep(i, n-k) v.push_back(1);
    } else {
        rep(i, k) v.push_back(s);
        rep(i, n-k) v.push_back(INF);
    }

    rep(i, n) {
        if (i < n-1) cout << v[i] << " ";
        else cout << v[i] << endl;
    }
}


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

bool dp[100001] = {};

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

    vector<int> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];

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

    for(int i = v[0]; i <= k; i++){
        for(int j = 0; j < n && v[j] <= i; j++){
            if(!dp[i-v[j]]) dp[i] = true; // able to win
        }
    }

    cout << (dp[k] ? "First" : "Second") << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <numeric>
#include <math.h>
using namespace std;

int main(void){
    long H,N;
    cin >> H >> N;
    long sum = 0;
    for(int i =0; i < N; i++){
        long tmp = 0;
        cin >> tmp;
        sum += tmp;
    }
    if(sum >= H){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
gets
a = gets.split.map(&:to_i)

h = Hash.new(0)

a.each do |n|
    h[n] += 1
end

cnt = 0
h.each do |k,v|
    if v>k
      cnt += (v-k)
    elsif v<k
      cnt += v
    end
end

p cnt


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N-1);
  for (int i = 0; i < N-1; i++) {
    cin >> a.at(i);
  }
  map<int,int> score;
  for (int x: a) {
    if (score.count(x)) {
      score.at(x)++;
    }
    else {
      score[x] = 1;
    }
  }
  
  for (int i = 0; i < N; i++) {
    if (score.count(i+1)) {
      cout << score.at(i+1) <<endl;
    }
    else {
      cout << 0 <<endl;
    }
  }
  
}


Measured memory_bytes: 13556
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  S[K-1] = S[K-1] - 'A' + 'a';
  cout << S << endl;
}


Measured memory_bytes: 256
import java.util.Queue;
import java.util.ArrayDeque;

data class Point(val h:Int, val w:Int)

val dx = intArrayOf(-1, 1, 0, 0)
val dy = intArrayOf(0, 0, -1, 1)

fun main(args: Array<String>) {
    val (h, w, k) = readLine()!!.split(" ").map(String::toInt)
    var sh = 0
    var sw = 0
    var a = Array<String>(h, {""})
    for(i in 0 until h){
        a[i] = readLine()!!
        for(j in 0 until w){
            if(a[i][j].toString() == "S") {
                sh = i
                sw = j
            }
        }
    }
    var dist = Array(h, {Array(w, {1000})})
    var que = ArrayDeque<Point>()
    dist[sh][sw] = 0
    que.add(Point(sh, sw))
    while(que.isNotEmpty()){
       var top = que.poll()
       if(dist[top.h][top.w] < k){
           for(i in 0 until 4){
               val ch = top.h+dx[i]
               val cw = top.w+dy[i]
               if(ch >= 0 && ch < h && cw >= 0 && cw < w && a[ch][cw].toString() != "#"){
                   if(dist[ch][cw] > dist[top.h][top.w]+1){
                        dist[ch][cw] = dist[top.h][top.w] + 1
                        que.add(Point(ch, cw))
                   }
               }
           }
       } 
    }
    var ans = 1000
    Math.max(11, 10/2)
    for(i in 0 until h){
        for(j in 0 until w){
            if(dist[i][j] != 1000){
                ans = Math.min(ans, 1+(i+k-1)/k)
                ans = Math.min(ans, 1+(h-1-i+k-1)/k)
                ans = Math.min(ans, 1+(j+k-1)/k)
                ans = Math.min(ans, 1+(w-1-j+k-1)/k)
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 97524
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
		int H = in.nextInt();
		int W = in.nextInt();
		if(H==0&&W==0){
			break;
		}
		for(int i = 0; i<H ; i++){
			for(int j = 0; j<W ; j++){
				System.out.print("#");
			}
			System.out.println();
		}
		System.out.println();
		}
	}
	}

Measured memory_bytes: 33212
import java.util.*;

public class Main {
	public static void printArray(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + ", ");
		}
		System.out.println();
	}

	static int dp(int left, int right, int step, int[] V, int[][][] DP) {
		if (step == 0) {
			return 0;
		}
		if (left > right) {
			return 0;
		}
		if (DP[left][right][step - 1] >= 0) {
			return DP[left][right][step - 1];
		}
		int max = Math.max(
			dp(left + 1, right, step - 1, V, DP) + V[left],
			dp(left, right - 1, step - 1, V, DP) + V[right]
		);
		max = Math.max(max, 0);
		if (step >= 2) {
			int v2 = Math.max(
				dp(left + 1, right, step - 2, V, DP),
				dp(left, right - 1, step - 2, V, DP)
			);
			max = Math.max(max, v2);
		}
		DP[left][right][step - 1] = max;
		return max;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); // 50
		int K = sc.nextInt(); // 100
		int[] V = new int[N];
		for (int i = 0; i < N; i++) {
			V[i] = sc.nextInt();
		}
		int[][][] DP = new int[N][N][K];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < K; k++) {
					DP[i][j][k] = -1;
				}
			}
		}

		int result = dp(0, N-1, K, V, DP);

		System.out.println(result);
	}
}


Measured memory_bytes: 24148
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, string> P;

int main() {
  int N;
  while(cin >>N && N){
    vector<string> s(N);
    vector< vector<int> > v(N);
    vector<int> cnt(31, 0);
    REP(i, N){
      int m;
      cin >>s[i];
      cin >>m;
      v[i] = vector<int>(m);
      REP(j, m){
        cin >>v[i][j];
        ++cnt[v[i][j]];
      }
    }
    vector<P> ans(N);
    REP(i, N){
      int r = 0;
      REP(j, v[i].size()) r += N - cnt[v[i][j]] + 1;
      ans[i] = P(r, s[i]);
    }
    SORT(ans);
    cout <<ans[0].first <<" " <<ans[0].second <<endl;
  }
  return 0;
}

Measured memory_bytes: 1248
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<functional>
#include<cmath>
#include<algorithm>
#define INF 999999999
typedef  long long ll;
 
int main() {
	ll a = 0, b = 0, c = 0,n = 0;
	char aa[4] = {};
	std::cin >> aa[0] >> aa[1] >> aa[2] >> aa[3];
	for (int i = 0; i < 4; i++) {
		if (aa[i] == '+') {
			n++;
		}
		else {
			n--;
		}
	}
	std::cout << n << std::endl;
		
	return 0;
}

Measured memory_bytes: 256
import numpy as np
a = np.array([2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367])
candidate = int(input())


while True:
  if ((candidate / a[a<candidate]) % 1 == 0).any():
    candidate += 1
  else:
    break
print(candidate)

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

#define PI 3.14159265358979323846

#define ll long long int
#define ff first
#define ss second
#define int long long int
#define pb push_back

#define N 10000010
#define MOD 1000000007

int bexp(int a, int b)
{
    int res = 1;
    while(b)
    {
        if(b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n;
    cin >> n;
    cout << 1 - n << endl;
    return 0;
}


Measured memory_bytes: 3560
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
			String line = reader.readLine();
			for(int i = 0; i < line.length(); i++){
				System.out.print("x");
			}
			System.out.println("");
		}catch(IOException e){
			System.out.println(e);
		}
	}
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9)+1;
const LL LLINF = LL(1e18)+1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    char c; cin >> c;
    cout << char(c+1) << endl;

}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <functional>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

pll ar[100500];


int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    int n;
    cin >> n;
    forn(i, n)
        cin >> ar[i].first >> ar[i].second;
    sort(ar, ar + n, [](pll a, pll b) { return a.first + a.second > b.first + b.second; });
    ll ans = 0;
    forn(i, n) {
        if (i & 1)
            ans -= ar[i].second;
        else
        ans += ar[i].first;
    }
    cout << ans << '\n';

    return 0;
}

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

using namespace std;

int main(void)
{
    int N;

    scanf("%d", &N);

    int count = 0;
    vector<int> cities;
    vector<int> heroes;
    int city;
    int hero;
    for (int i = 0; i <= N; i++)
    {
        cin >> city;
        cities.push_back(city);
    }
    for (int i = 0; i < N; i++)
    {
        cin >> hero;
        heroes.push_back(hero);
    }

    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        if (cities.at(i) >= heroes.at(i))
        {
            sum += heroes.at(i);
        }
        if (cities.at(i) < heroes.at(i))
        {
            sum += cities.at(i);
            heroes.at(i) -= cities.at(i);

            if (cities.at(i + 1) <= heroes.at(i))
            {
                sum += cities.at(i + 1);
                cities.at(i + 1) = 0;
            }
            else
            {
                cities.at(i + 1) -= heroes.at(i);
                sum += heroes.at(i);
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

static class Extentions
{
    public static BigInteger Lcm(BigInteger x, BigInteger y)
        => x * y / BigInteger.GreatestCommonDivisor(x, y);
}

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var n = io.I;
        var t = io.Bs(n);

        var ans = t[0];
        for (var i = 1; i < n; i++) ans = Lcm(ans, t[i]);

        io.Write(ans);
    }
}

Measured memory_bytes: 13908
N = int(input())
coord = [list(map(int, input().split())) for i in range(N)]

# 初期値
t = x = y = 0
# 判定フラグ
flag = 0
for l in coord:
    dt, dx, dy = abs(l[0] - t), abs(l[1] - x), abs(l[2] - y)
    # dtが以前のdx, dyの合計値よりも小さいならば不可
    if dt < dx + dy:
        flag = 1
        break
    else:
        # dtの偶奇とdx, dyの和の偶奇は等しくなるはず
        # 等しくない場合
        if dt % 2 != (dx + dy) % 2:
            flag = 1
            break
        else:
            t, x, y = l[0], l[1], l[2]
            continue

if flag:
    print("No")
else:
    print("Yes")


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

int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  for(int i=0; i<N; i++){
    cin >> D.at(i);
  }
  int Ans=0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      Ans+=D.at(i)*D.at(j);
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
import copy
 
def main():
    N,A,B,K = map(int,input().split())
    
    MOD = 998244353
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
    invfac = copy.deepcopy(fac)
    
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
    
    invfac[-1] = pow(fac[-1],MOD-2,MOD)
    for i in range(N,0,-1):
        invfac[i-1] = (invfac[i]*i)%MOD
 
    def coef(x,y):
        num = (((fac[x]*invfac[y])%MOD)*invfac[x-y]%MOD)
        return num

    ans = 0
    for i in range(min(K//max(A,B),N)+1):
        rest = K-i*max(A,B)
        if rest%min(A,B) == 0:
            j = rest//min(A,B)
            if j <= N:
                ans += coef(N,i)*coef(N,j)
                ans %= MOD
            
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 27336
#include<stdio.h>
int main(void)
{
	int n;
    int a = 0;
	scanf("%d",&n);
    a = n % 10;
    if (a==3)printf("bon");
	else if (a == 0 || a == 1 || a == 6 || a == 8)printf("pon");
	else printf("hon");
	return 0;
}

Measured memory_bytes: 1732
def read():
    return [int(i) for i in input().split()]

def main():
    n, x = read()
    a = read()
    a.sort()

    ans = 0
    for i in a:
        x -= i
        if x >= 0:
            ans += 1

    if x > 0:
        ans -= 1
    print(ans)

main()


Measured memory_bytes: 3060
let n = stdin.ReadLine() |> int
let s = [| for _ in 1.. n -> stdin.ReadLine()|]

let combi2 x =int64 x * int64 (x-1L) / 2L
//s |> Seq.map (fun str -> str.ToCharArray() |> Seq.countBy(fun x -> x ))
s |> Seq.map (fun str -> str.ToCharArray() |> Array.sort)
//|> Seq.countBy (fun x -> x |> Set.ofSeq)
|> Seq.countBy (fun x -> x)
//|> Seq.fold (fun map cArray ->
//    if map |> Map.containsKey cArray then map.Add(cArray,map.[cArray]+1) else map.Add(cArray,1) ) Map.empty
|> Seq.sumBy (fun (_, count) -> combi2 <| int64 count)
//|>Seq.sumBy (fun pair -> combi2 <| int64 pair.Value)
|> stdout.WriteLine

Measured memory_bytes: 38576
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int check(int a,int b){
	int sum=a%10+b%10;
	while(a/10){
		a/=10;
		sum+=a%10;
	}
	while(b/10){
		b/=10;
		sum+=b%10;
	}
	return sum;
}
int main(){
	int n;
	cin>>n;
	int res=INF;
	rb(i,1,n-1){
		int a,b;
		a=i;
		b=n-i;
		res=min(res,check(a,b));
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main(): 
    s = list(input().rstrip())
    t = input().rstrip()
    for i in range(len(s)):
        if t == "".join(s):
            print("Yes")
            exit()
        else:
            tmp=s.pop(0)
            s.append(tmp)
    print("No")



if __name__=="__main__":
    main()

Measured memory_bytes: 8968
import sys
sys.setrecursionlimit(10**6)
n = int(input())
tree = [[] for i in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    tree[u-1].append((v-1,w))
    tree[v-1].append((u-1,w))
vis = [False]*n
color = [0]*n

def dfs_rec(now):
    for node,w in tree[now]:
        if not vis[node]:
            vis[node] = True
            if w%2==0:
                color[node] = color[now]
            else:
                color[node] = 1-color[now]
            dfs_rec(node)
    return
vis[0] = True
dfs_rec(0)
for c in color:
    print(c)


Measured memory_bytes: 80048