akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int mod = 1000000007;
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int k = sc.nextInt();
        long[] a0 = new long[x];
        long[] b0 = new long[y];
        long[] c0 = new long[z];
        for (int i=0;i<x;i++) a0[i] = sc.nextLong();
        for (int i=0;i<y;i++) b0[i] = sc.nextLong();
        for (int i=0;i<z;i++) c0[i] = sc.nextLong();
        Arrays.sort(a0);
        Arrays.sort(b0);
        Arrays.sort(c0);
        long[] a = new long[x];
        long[] b = new long[y];
        long[] c = new long[z];
        for (int i=0;i<x;i++) a[i] = a0[x-1-i];
        for (int i=0;i<y;i++) b[i] = b0[y-1-i];
        for (int i=0;i<z;i++) c[i] = c0[z-1-i];
        int kx = Math.min(x,k);
        int ky = Math.min(y,k);
        int kz = Math.min(z,k);
        long[] ab0 = new long[kx*ky];
        long[] ab = new long[kx*ky];
        int index = 0;
        for(int i=0;i<kx;i++) {
            for(int j=0;j<ky;j++) {
                ab0[index] = a[i]+b[j];
                index++;
            }
        }
        Arrays.sort(ab0);
        for(int i=0;i<kx*ky;i++) ab[i] = ab0[kx*ky-1-i];
        int kxy = Math.min(k,kx*ky);
        long[] abc0 = new long[kxy * kz];
        index = 0;
        for(int i=0;i<kxy;i++) {
            for(int j=0;j<kz;j++) {
                abc0[index] = ab[i] + c[j];
                index++;
            }
        }
        Arrays.sort(abc0);
        for(int i=0;i<k;i++) {
            System.out.println(abc0[kxy*kz-1-i]);
        }
    }
    public static int modPow(int value,int exponent,int mod) {
        if (exponent == 0) return(1);
        if (exponent == 1) return(value%mod);
        long longValue = (long) value;
        int res = exponent%2;
        int q = exponent/2;
        long answer = 1;
        if(res == 1) answer *= longValue;
        longValue *= longValue;
        longValue %= mod;
        answer = (answer * ((long) modPow((int) longValue, q, mod)))%mod;
        return((int) answer);
    }
}   

Measured memory_bytes: 88740
bingo = [input().split() for _ in range(3)]

n = int(input())

nums = [input() for _ in range(n)]

check = [[] for _ in range(3)]

for i in range(3):
    for j in range(3):
        if bingo[i][j] in nums:
            check[i].append(True)
        else:
            check[i].append(False)

ANS = "No"

for i in range(3):
    if (check[i][0]) and (check[i][1]) and (check[i][2]):
        ANS = "Yes"
for i in range(3):
    if (check[0][i]) and (check[1][i]) and (check[2][i]):
        ANS = "Yes"
if (check[0][0]) and (check[1][1]) and (check[2][2]):
    ANS = "Yes"
if (check[0][2]) and (check[1][1]) and (check[2][0]):
    ANS = "Yes"

print(ANS)


Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 998244353;
int main() {
	ll n, a, b, c, d, e;cin >> n >> a >> b >> c >> d >> e;
	ll mi = min({a,b,c,d,e});
	ll sum = (n / mi);
	if (n % mi != 0) sum++;
	cout << sum + 4 << endl;
}

Measured memory_bytes: 256
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	nk := getIntList(scanner)
	n := nk[0]
	k := nk[1]
	s := getNextLine(scanner)
	var prev byte
	prev = '1'
	var switched []int
	switched = append(switched, 0)
	for i := 0; i < n; i++ {
		if prev != s[i] {
			switched = append(switched, i)
			prev = s[i]
		}
	}
	switched = append(switched, n)
	max := 0
	l := len(switched)
	for i := 0; i < l-1; i += 2 {
		last := l - 1
		if i+2*k+1 <= l-1 {
			last = i + 2*k + 1
		}
		if max < switched[last]-(switched[i]) {
			max = switched[last] - (switched[i])
		}
	}
	fmt.Println(max)
}


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

if n>=2 and m>=2:
    print(n*m - (n-2)*2 - (m-2)*2 - 4)
elif n==1 and m==1:
    print(1)
elif n==1 and m>=2:
    print(m-2)
else:
    print(n-2)

Measured memory_bytes: 3060
import sys

h, w = map(int, input().split())
s = [list(x.rstrip()) for x in sys.stdin.readlines()]
dp = [[10**6]*w for _ in range(h)]
if s[0][0] == "#":
    dp[0][0] = 1
else:
    dp[0][0] = 0

for j in range(h):
    for i in range(w):
        for k in range(2):
            nx, ny = i + (k + 1)%2, j + k%2
            if nx >= w or ny >= h:
                continue
            else:
                add = 0
                if s[ny][nx] == "#" and s[j][i] == ".":
                    add = 1
                dp[ny][nx] = min(dp[ny][nx], dp[j][i] + add)
print(dp[h-1][w-1])

Measured memory_bytes: 9312
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<int, int> P;

// 奇数の人は奇数、偶数の人は偶数番目にはいる

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  int N = S.size();
  int ans[N];
  FOR(i,0,N) ans[i] = 0;

  int cnt[2];
  cnt[0] = 0;
  cnt[1] = 0;
  // ->
  FOR(i,0,N) {
    if (S[i] == 'R') {
      cnt[i%2]++;
    } else {
      ans[i] += cnt[i%2];
      ans[i-1] += cnt[(i-1)%2];
      cnt[0] = 0;
      cnt[1] = 0;
    }
  }


  // <-
  for(int i = N - 1; i >= 0; i--) {
    if (S[i] == 'L') {
      cnt[i%2]++;
    } else {
      ans[i] += cnt[i%2];
      ans[i+1] += cnt[(i+1)%2];
      cnt[0] = 0;
      cnt[1] = 0;
    }
  }

  FOR(i,0,N) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 D,G;
    cin >> D >> G;
    vector<i64> p(D),c(D);
    rep(i,0,D) cin >> p[i] >> c[i];

    static i64 dp[11][2000];
    fill_n((i64*)dp,11*2000,0);
    rep(i,0,p[0]) dp[0][i]=100*i;
    dp[0][p[0]]=100*p[0]+c[0];
    rep(i,0,D-1){
        rep(j,0,1001){
            rep(k,0,p[i+1]+1){
                dp[i+1][j+k]=max(dp[i+1][j+k],dp[i][j]+100*(i+2)*k+(k==p[i+1]?c[i+1]:0));
            }
        }
    }

    i64 ans=inf64;
    rep(i,0,2000) if(dp[D-1][i]>=G){
        cout << i << endl;
        return;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int main(void){
		int n;
		cin >> n;
		double *a = new double[n];
		for(int i = 0;i < n;i++){
				cin >> a[i];
		}
		for(int j = 0;j < n-1;j++){
				cout << a[n-1-j] << " ";
		}
		cout << a[0] << endl;
		return 0;
}

Measured memory_bytes: 1284
# C - Same Integers
# https://atcoder.jp/contests/abc093/tasks/arc094_a

nums = list(map(int,input().split()))
abc= sum(nums)
X = max(nums)


if X%2 != abc%2:
    X += 1
print((3*X - abc)//2)


# 増加させるかず -> 3X - abc
# 捜査回数      -> (3X - abc) //2



Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#define _USE_MATH_DEFINES // M_PI????????????????????????
#include<math.h>
#include<queue>
#pragma warning(disable:4996)
using namespace std;

static const int N=100;
static const int INFTY = (1<<21);

int n,M[N][N];
int d[N]; // ?????¢??§?¨??????¶??????????????????

void bfs(int s){
	queue<int> q;
	q.push(s);
	for(int i=0; i<n; i++) d[i] = INFTY;
	d[s] = 0;
	int u;
	while( !q.empty() ){
		u = q.front();
		q.pop();
		for(int v=0; v<n; v++){
			if( M[u][v]==0 ) continue;
			if( d[v]!=INFTY ) continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for(int i=0; i<n; i++){
		cout << i+1 << " " << ( (d[i]==INFTY)?(-1):d[i] ) << "\n";
	}
}

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

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++) M[i][j] = 0;
	}
	for(int i=0; i<n; i++){
		cin >> u >> k;
		u--;
		for(int j=0; j<k; j++){
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	bfs(0);
	return 0;
}

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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int n;
	cin >> n;
	int sum = 0;
	int m = n;
	for(int i = 0; i < 8; i++){
		sum += m % 10;
		m /= 10;
		if(m == 0)break;
	}

	if(!(n % sum))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define HpOut(S) cout << setprecision(20) << S << endl;
#define print(x) cout << (x) << endl;
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

 
int main(void){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N, K, L; cin >> N >> K >> L;
    UnionFind uf1(N), uf2(N);
    rep(i,K){
      int a,b; cin >> a >> b; --a, --b;
      uf1.merge(a,b);
    }
    rep(i,L){
      int a,b; cin >> a >> b; --a, --b;
      uf2.merge(a,b);
    }
    using pint = pair<int,int>;
    map<pint, int> ma;
    rep(v,N){
      pint p = {uf1.root(v), uf2.root(v)};
      ma[p]++;
    }
    rep(v,N){
      pint p = {uf1.root(v), uf2.root(v)};
      cout << ma[p] << " ";
    }
}

Measured memory_bytes: 13568
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	long long A[2], K;

	cin >> A[0] >> A[1] >> K;

	for(int i = 0; i<K; i++){
		int x = i % 2; 
		if(A[x] % 2 == 1){
			A[x]--;
		}
		A[1-x] += A[x]/2;
		A[x] /= 2;
	}

	cout << A[0] << " "<< A[1] << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
typedef int fuko[yuzu<<1|10];
struct _bit{
fuko c;
void init(){memset(c,0,sizeof c);}
void add(int x){for (;x<=yuzu<<1;x+=x&-x) c[x]++;}
int query(int x){
  int llx=0;
  for (;x;x&=x-1) llx+=c[x]; 
  return llx;
  }
}my_;
fuko b,a;
bool judge(int x,int n,int i=1){
my_.init();
for (;i<=n;++i) b[i]=b[i-1]+(a[i]>=x?1:-1);
ll llx=0;
for (i=0;i<=n;++i) llx+=my_.query(b[i]+yuzu),my_.add(b[i]+yuzu);
return llx>=1ll*n*(n+1)/4;
}
int main(){
int i,n=read(),l=0,r=0;
for (i=1;i<=n;++i) r=max(a[i]=read(),r);
for (;l<=r;){
  int mid=l+r>>1;
  judge(mid,n)?l=mid+1:r=mid-1;
  }
write(l-1);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;

int main() {
  cin >> N;
  vector<vector<int>> G(N);
  vector<bitset<20>> C(N - 1, 0);
  unordered_map<int, unordered_map<int, int>> edge;
  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
    edge[a][b] = i;
    edge[b][a] = i;
  }

  int M;
  cin >> M;

  function<bool(int, int, int, int)> append = [&](int u, int v, int p, int c) {
    if (u == v) return true;

    bool found = false;
    for (auto w : G[u]) {
      if (w == p) continue;
      bool goodPath = append(w, v, u, c);
      if (goodPath) C[edge[u][w]].set(c);
      found |= goodPath;
    }
    return found;
  };

  rep(i, M) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    append(u, v, -1, i);
  }

  vector<vector<ll>> dp((1 << M), vector<ll>(N, 0));
  dp[0][0] = 1;
  rep(i, N - 1) rep(s, (1 << M)) {
    dp[s | int(C[i].to_ulong())][i + 1] += dp[s][i];  // B
    dp[s][i + 1] += dp[s][i];                         // W
  }

  cout << dp[(1 << M) - 1][N - 1] << endl;

  return 0;
}


Measured memory_bytes: 450816
import itertools
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
num = 0
for v in list(itertools.permutations(range(1,N+1))):
    num += 1
    if list(v) == P:
        A = num
    elif list(v) == Q:
        B = num
    else:
        pass
try:
    print(abs(A-B))
except:
    print(0)

Measured memory_bytes: 8052
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

ll fact[100005];
ll inv[100005];

ll ncr(int n, int r){
  if(n<0 || r<0 || r>n)return 0;
  if(r > n/2)r=n-r;
  return fact[n]*inv[n-r]%MOD*inv[r]%MOD;
}

ll  beki(int a,int n){
  ll ret=1;
  ll t=a;
  while(n>0){
    if(n&1)ret=ret*t%MOD;
    t=t*t%MOD;
    n=n>>1;
  }
  return ret;
}

void init(int n){

  fact[0]=inv[0]=1;

  for(int i=1;i<=n;i++)
    fact[i]=fact[i-1]*i%MOD;

  inv[n]=beki(fact[n],MOD-2);

  for(int i=n-1;i>=1;i--)
    inv[i]=((i+1)*inv[i+1])%MOD;
}

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n+1);
  vector<vi> ord(n);
  rep(i,n+1){
    cin>>a[i];
    a[i]--; 
    ord[a[i]].push_back(i);
  }
  int p,q;
  rep(i,n)if(ord[i].size()==2){
    p=ord[i][0];
    q=n-ord[i][1];
  }
 
  n++;
 
  init(n+1);


  for(i=1;i<=n;i++){
    ll ans=ncr(n,i);
    ans=(ans-ncr(p+q,i-1)+MOD)%MOD;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 8828
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
// const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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 int MOD = 998244353;

struct mint{ // auto MOD int
  ll x;
  mint(ll x=0) : x((x%MOD+MOD)%MOD){}  //コンストラクタ
  mint operator-() const { return mint(-x); } //符号変換
  mint operator+(const mint &a) const { return mint(*this) += a; } //算術演算子
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  mint pow(ll n) const {  //繰り返し累乗
    if(!n) return 1;
    mint a = pow(n>>1);
    a *= a;
    if(n&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(MOD-2); } // for prime mod
  mint& operator+=(const mint a){ if((x+=a.x) >= MOD) x-=MOD;  return *this; } //代入演算子
  mint& operator-=(const mint a){ if((x+=MOD-a.x) >= MOD) x-=MOD;  return *this; }
  mint& operator*=(const mint a){ (x *= a.x) %= MOD;  return *this; }
  mint& operator/=(const mint a){ return (*this) *= a.inv(); }
  friend ostream& operator<<(ostream &stout, const mint &tmp){ stout << tmp.x; return stout; }
};

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,k; cin >> n >> k;
  vi l(k),r(k);
  rep(i,k) cin >> l[i] >> r[i];
  vector<mint> dp(n+1),dpsum(n+1);
  dp[1] = dpsum[1] = 1;
  for(int i = 2; i <= n; i++){
    rep(j,k){
      int li = i-r[j];
      int ri = i-l[j];
      if(ri < 0) continue;
      chmax(li,1);
      dp[i] += dpsum[ri]-dpsum[li-1];
    }
    dpsum[i] = dpsum[i-1]+dp[i];
  }
  cout << dp[n];
  return 0;
}


Measured memory_bytes: 6380
#include <iostream>
using namespace std;
int main(){
        int N;
        int array[100];
        cin >> N;
        for(int i=0 ; i<N ; i++ )
                cin >> array[i];
        int counter=0;
        for(int i=0 ;i<N ; i++ ){
                int now=i;
                for(int j=i+1 ;j<N ; j++ )
                        if(array[j]<array[now])
                                now=j;
                if(now!=i){
                        int tmp=array[now];
                        array[now]=array[i];
                        array[i]=tmp;
                        counter++;
                }
        }
        for(int i=0 ; i<N ; i++ ){
                cout << array[i];
                if(i<N-1)
                        cout<<" ";
        }
        cout << endl << counter << endl;
        return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<map>
#define ll long long
using namespace std;
int n;
map<ll,ll>cnt;
int main()
{
	ll ans=0;
	cin>>n;
	int i;
	for(i=1;i<=n;i++)
	{
		ll a;
		scanf("%lld",&a);
		ans+=cnt[a-i];
		cnt[-a-i]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 25992
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair
typedef long long LL;
#define EPS (1e-6)
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef pair<int,int> P;

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);
  int INF = 1000000;

  int xm = 2;
  int ym = 2;

  int paper[10+xm+xm][10+ym+ym];
  memset(paper,0,sizeof(paper));

  int x,y,size;
  char buf;
  while(cin>>x>>buf>>y>>buf>>size){
    x += xm;
    y += ym;

    paper[x][y]++;

    switch(size){
    case 3:
      paper[x-2][y]++;
      paper[x+2][y]++;
      paper[x][y-2]++;
      paper[x][y+2]++;

    case 2:
      paper[x-1][y-1]++;
      paper[x+1][y+1]++;
      paper[x+1][y-1]++;
      paper[x-1][y+1]++;      

    case 1:
      paper[x-1][y]++;
      paper[x+1][y]++;
      paper[x][y-1]++;
      paper[x][y+1]++;
      break;
    }
  }


  int m=0;
  int white=0;
  for(int i=xm; i<10+xm; i++){
    for(int j=ym; j<10+ym; j++){
      m = max( paper[i][j], m);
      if(paper[i][j]==0)
	white++;
    }
  }

  cout << white << endl << m << endl;

  return 0;
}

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


def gcd(a, b):
    if b > 0:
        return gcd(b, a % b)
    else:
        return a


# リスト内の全要素の最大公約数
if len(a) == 1:
    print(a[0])
else:
    element = gcd(a[0], a[1])
    if len(a) == 2:
        print(element)
    else:
        for i in range(2, n):
            element = gcd(element, a[i])
        print(element)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long

using namespace std;

int a[300005],n,k,len,del;

int main(){
  cin>>k>>n;
  if (k==1){
    for (RG int i=1;i<=(n+1)>>1;++i) printf("%d ",1);
    return 0;
  }
  if (!(k&1)){
    printf("%d ",k>>1);
    for (RG int i=2;i<=n;++i) printf("%d ",k);
    return 0;
  }
  if (n==1) printf("%d",(k+1)>>1),exit(0); del=n>>1;
  for (RG int i=1;i<=n;++i) a[i]=(k+1)>>1; len=n;
  for (;del;--del){
    //for (RG int i=1;i<=len;++i) printf("%d ",a[i]); puts("");
    if (len==n){
      if (a[len]!=1) --a[len]; else --len;
    } else{
      if (a[len]!=1){
	--a[len];
	for (;len!=n;++len) a[len+1]=k;
      } else --len;
    }
  }
  for (RG int i=1;i<=len;++i) printf("%d ",a[i]); return 0;
}


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

int n;
int k;

#define MAX 300002

vector<int> ans;
long long int sz[MAX];
long long int m2[MAX];
void output() {
	while (ans.back() == 0) {
		ans.pop_back();
	}
	for (int i = 0; i < ans.size(); i++) {
		if (i)printf(" ");
		printf("%d", ans[i]);
	}
	puts("");
}
inline void dfs(int b,int pr=-1) {
	if (b == n) {
		return;
	}
	if (ans.size() == b) {
		ans.push_back(0);
	}
	int j = 0;
	if (pr == -1) {
		j = ans[b];
	}
	for (j; j <= k; j++) {
		if (j == 0) {
			continue;
		}
		if (j != ans[b]) {
			ans[b] = j;
			output();
			exit(0);
		}
		dfs(b+1, pr);
	}
	ans.pop_back();
}
int main() {
	cin >> k >> n;
	if (k % 2==0) {
		cout << k/2;
		for (int j = 1; j < n; j++) {
			printf(" %d", k);
		}
		puts("");
		return 0;
	}
	sz[n] = 1;
	m2[n] = 1;
	long long int MX = 5000000;
	for (int j = n - 1; j >= 0; j--) {
		sz[j] = sz[j + 1] * k;
		sz[j]++;
		sz[j] = min(sz[j], MX);
		m2[j] = m2[j + 1] * k;
		m2[j]++;
		m2[j] %= 2LL;
	}
	long long int minu = 0;
	long long int ID = 0; 
	for (int j = 0; j < n; j++) {
		if (m2[j]==0) {
			minu++;
		}
		if (sz[j+1]<MX) {
			ID = sz[j+1]*k;
			if (m2[j] == 0) {
				minu--;
			}
			ID++;
			ID++;
			ID /= 2LL;
			ID -= minu;
			while (1) {
				if (ID == 1) {
					break;
				}
				ID--;
				for (int go = 1; go <= k; go++) {
					if (ID > sz[j + 1]) {
						ID -= sz[j + 1];
					}
					else {
						ans.push_back(go);
						break;
					}
				}
				j++;
			}
			break;
		}
		else {
			ans.push_back((k + 1) / 2);
			continue;
		}
	}
	if (m2[0]==0) {
		dfs(0);
	}
	output();
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int x = 0;
  int max = 0;

  for (int i = 0; i < N; i++)
  {
    if (S.at(i) == 'I'){
      x += 1;
    }
    else if (S.at(i) == 'D')
    {
      x -= 1;
    }

    if (x > max) max = x;
    
  }
  cout << max << endl;
}

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

int main(){
  
  int N,a,b,c,d;
  
  cin >> N;
  
  a = N/1000;
  b = (N-a*1000)/100;
  c = (N-a*1000-b*100)/10;
  d = N-a*1000-b*100-c*10;
  
  if (a == b && b == c || b == c && c == d ){
    
    cout << "Yes" << endl;
    
  } else {
    
    cout << "No" << endl;
    
  }
}

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

int main(){
  int N,n;
  int s =0;
  int Max = 0;
  cin >> N;
  for(int i = 0;i < N;i++){
    cin >> n;
    if(n > Max){
      Max = n;}
    s += n;
  }
  if(s-Max > Max){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.util.*;

import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ2207();
	}
	class AOJ2207{
		int N;
		final int INF=1<<29;
		AOJ2207(){
			while(sc.hasNext()){
				N=sc.nextInt();
				if(N==0)	break;
				solve();
			}
		}
		void solve(){
			ArrayList<Edge> es=new ArrayList<Edge>();
			HashMap<String,Integer> map=new HashMap<String,Integer>();
			int kind=0;
			for(int i=0; i<N; ++i){
				sc.nextInt();
				String as=sc.next();
				int a=-1;
				if(map.containsKey(as))	a=map.get(as);
				else{
					a=kind;
					map.put(as, kind);
					++kind;
				}
				sc.next();
				int c=Integer.parseInt(sc.next().substring(3));
				String bs=sc.next();
				int b=-1;
				if(map.containsKey(bs))	b=map.get(bs);
				else{
					b=kind;
					map.put(bs, kind);
					++kind;
				}
				es.add(new Edge(a,b,c));
				es.add(new Edge(b,a,-c));
			}
//			System.out.println(es);

			bellmanFord bf=new bellmanFord(map.size(), es);
			for(int i=0; i<map.size(); ++i)if(bf.shortestPath(i)==null){
				System.out.println("No");
				return;
			}
			System.out.println("Yes");
		}
		class bellmanFord{
			final int INF=1<<29;
			int V,E;
			ArrayList<Edge> es;
			int[] d;
			bellmanFord(int V,ArrayList<Edge> es){
				this.V=V; this.es=es; this.E=es.size();
			}
			// startから到達可能な負の閉路があればnull．それ以外はstartからの最短経路．
			int[] shortestPath(int start){
				d=new int[V];
				for(int i=0; i<V; ++i)	d[i]=INF;
				d[start]=0;
				for(int i=1; i<=V; ++i){
					boolean update=false;
					for(Edge e:es){
						if(d[e.from]<INF && d[e.to]>d[e.from]+e.cost){
							d[e.to]=d[e.from]+e.cost;
							update=true;
							if(i==V)	return null;
						}
					}
					if(!update)	break;
				}
				return d;
			}
		}
		class Edge implements Comparable<Edge>{
			int from,to,cost;
			Edge(int from,int to,int cost){
				this.from=from;	this.to=to;	this.cost=cost;
			}
			@Override public int compareTo(Edge e){
				return this.cost-e.cost;
			}
			@Override public String toString(){
				return from+"->"+to+":"+cost;
			}
		}
	}
}

Measured memory_bytes: 42296
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int N,K;in(N,K);
  int c=0;
  while(N){
    N/=K;
    c++;
  }
  out(c);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, k;

	cin>>n>>k;

	if(n%k){
		cout<<1<<endl;
	} else{
		cout<<0<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
    //    #include <boost/multiprecision/cpp_int.hpp>
        #include<functional>
      #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define  mp make_pair
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------


signed main(){
int n;
	cin>>n;
	int q,w;
	cin>>q>>w;
	
	for(int i=2;i<=n;i++){
		int t,a;
		cin>>t>>a;
		
		int d=q/t,dd=w/a;
		if(q%t!=0) d++;
		if(w%a!=0) dd++;
		
		int r=max(d,dd);
		q=r*t,w=r*a;
	}
	
	
	cout<<q+w<<endl;
	return 0;
}

//printf("%.10f\n",ans);


Measured memory_bytes: 256
/** MIT License Copyright (c) 2018 Vasilyev Daniil **/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template<typename T> using v=vector<T>;
#define int long long
typedef string str;
typedef vector<int> vint;
#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define pb push_back
#define sz(a) ((int)(a).size())
const long long inf=4611686018427387903;//2^62-1
#if 0 //FileIO
ifstream fin ("input.txt" );
ofstream fout("output.txt");
#define get fin>>
#define put fout<<
#else
#define get cin>>
#define put cout<<
#endif
#define eol put endl
void read(){}             template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get   (arg)     ;read(args...) ;}
void print(){}            template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put   (arg)<<" ";print(args...);}
void debug(){cout<<endl;} template<typename Arg,typename... Args> void debug(Arg  arg,Args...  args){cout<<(arg)<<" ";debug(args...);}
int getInt(){int a; get a; return a;}
//code goes here
void run(){
    int n;
    get n;
    if (n<1000)put "ABC";
    else put "ABD";
}
int32_t main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll x, y, z;
  cin >> x >> y >> z;
  ll ans = 0;
  while (x > y + z) {
    x -= y + z;
    ans++;
  }
  if (x < z) ans--;
  cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

def GCD(a, b):
    if(a < b):
        temp = a
        a = b
        b = temp
    a = a % b
    if(a == 0):
        return b
    else:
        return GCD(a, b)

class point:
    def __init__(self, x ,y):
        self.x = x
        self.y = y

n = int(input())
names = []

for i in range(n):
    names += [input()]

march = 'MARCH'
count = []
for i in range(5):
    count += [0]

for i in range(n):
    for j in range(5):
        if(names[i][0] == march[j]):
            count[j] += 1

ans = 0
for i in range(5):
    for j in range(5):
        for k in range(5):
            if(i < j and j < k):
                ans += (count[i] * count[j] * count[k])

print(ans)

Measured memory_bytes: 19016
#include <bits/stdc++.h>
using namespace std;
int st[4] ;
double n;
double dp[305][305][305];
double solve(int a , int b , int c){
	if(a+b+c==0)return 0.0;
	if(dp[a][b][c] >=-0.5)
		return dp[a][b][c];

	double ret = 0 , val = (double)n / (a + b + c);
	if(a){
		ret +=( solve(a-1 , b , c) + val) *a / (a + b + c);
	}if(b){
		ret += (solve(a + 1 , b - 1 , c) + val) * b/(a + b + c);
	}if(c){
		ret += (solve(a , b + 1 , c - 1 ) + val) * c/(a + b +c);
	}
	return dp[a][b][c] = ret;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int xx ;
	cin>>xx;
	n =xx;
	for(int i = 0; i< xx; i++){
		int x ;
		cin>>x;
		st[x]++;
	}
	for(int i = 0;i <= n ; i++)
		for(int j = 0; j <= n ; j++)
			for(int k = 0; k <= n ; k++)
				dp[i][j][k] = -1;
	cout<<fixed<<setprecision(12)<<solve(st[1] , st[2] , st[3]);
	return 0;
}


Measured memory_bytes: 219520
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int x;
    scanf("%d", &x);
    int ans=lcm(x, 360) / x;
    printf("%d\n", ans);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


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

using namespace std;

int n, top, a[300100], f[300100], pre[300100];

void Input()
{
    ios_base::sync_with_stdio(0);       cin.tie(0);

    cin >> n;
    for (int i=1; i<=n; i++)
    {
        int x;      cin >> x;
        a[x]++;
    }

    for (int i=1; i<=n; i++)
        if (a[i] > 0) f[++top] = a[i];

    sort(f + 1, f + top + 1);
    for (int i=1; i<=top; i++)
        pre[i] = pre[i-1] + f[i];
}

bool check(int t, int k)
{
    int l = -1, r = top + 1;
    while (r - l > 1)
    {
        int mid = (l + r) >> 1;

        if (f[mid] < t) l = mid;
            else r = mid;
    }

    int sum = pre[l] + (top - l)*t;
    if (sum/t < k) return false;
    return true;
}

void Process()
{
    for (int i=1; i<=n; i++)
    {
        int l = 0, r = 1000000;

        while (r - l > 1)
        {
            int mid = (l + r) >> 1;
            if (check(mid, i)) l = mid;
                else r = mid;
        }

        cout << l << endl;
    }
}

int main()
{
    Input();
    Process();
    return 0;
}


Measured memory_bytes: 4224
package main

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

const (
	A = iota
	B
	C
	D
	E
	F
	G
	H
	I
)

func operate(x int) int {
	if x < 400 {
		return A
	} else if x < 800 {
		return B
	} else if x < 1200 {
		return C
	} else if x < 1600 {
		return D
	} else if x < 2000 {
		return E
	} else if x < 2400 {
		return F
	} else if x < 2800 {
		return G
	} else if x < 3200 {
		return H
	} else {
		return I
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	a := make([]int, n)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Ints(a)

	aggregate := make(map[int]int)
	for i := range a {
		aggregate[operate(a[i])] = aggregate[operate(a[i])] + 1
	}

	min := len(aggregate)
	for k := range aggregate {
		if k == I {
			min = min - 1
			break
		}
	}
	if min < 1 {
		min = 1
	}

	max := 0
	for k := range aggregate {
		if k == I {
			max = max + aggregate[k]
			continue
		}
		max = max + 1
	}

	fmt.Printf("%d %d\n", min, max)
}


Measured memory_bytes: 640
def five_transportations(n,a):
    min_a = min(a)
    rem = n
    count = 0
    mod = -(-rem//min_a)
    mod += 5 - 1
    return mod
if __name__ == '__main__':
    n = int(raw_input())
    a = [int(raw_input()) for i in range(5)]

    print five_transportations(n,a)

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

    int n;
    cin >> n;
    map<string, int> inputed_string_and_count;

    for (int i = 0; i < n; i++)
    {
        string input;
        cin >> input;
        inputed_string_and_count[input] += 1;
    }

    int max = 0;
    for (auto entry : inputed_string_and_count)
    {
        if (max < entry.second)
            max = entry.second;
    }

    for (auto entry : inputed_string_and_count)
    {
        if (entry.second == max)
            cout << entry.first << endl;
    }
}

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

int main()
{
  int A, B;
  int ans;
  
  cin >> A >> B;
  if (A < 10 && B < 10) {
    ans = A * B;
  }
  else {
    ans = -1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  long long H=1000000001;
  cin>>N>>K;
  vector<long long>vec(N);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
  }
  sort(vec.begin(),vec.end());
  for(int X=0;K+X-1<N;X++){
    if(vec.at(K+X-1)-vec.at(X)<H){
      H=vec.at(K+X-1)-vec.at(X);
    }
  }
  cout<<H<<endl;
}

Measured memory_bytes: 3980
S = input()
L = S[:len(S)//2]
R = S[(len(S)+1)//2:]

L1 = L[:len(L)//2]
L2 = L[(len(L)+1)//2:]
R1 = R[:len(R)//2]
R2 = R[(len(R)+1)//2:]

if (L1==L2[::-1]) and (R1==R2[::-1]) and (L==R[::-1]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void)
{
int a,b,c;
cin >>a;
cin >>b;
cin >>c;
if(b<a){
    int temp=a;
    a=b;
    b=temp;
}
if(c<b){
    int temp=b;
    b=c;
    c=temp;
}
if(b<a){
    int temp=b;
    b=a;
    a=temp;
}
cout<<a<<" "<<b<<" "<<c<<endl;
}


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

using ll = long long;
const long long INF = (1LL << 32);

class BellmanFord {
    class Edge {
        public:
        int u, v, w;
        Edge(int source, int target, int weight) {
            u = source;
            v = target;
            w = weight;
        }
    };

    private:
    vector<long long> d;
    vector<Edge> edges;

    public:
    BellmanFord(int n) { d.resize(n, INF); }

    void add_edge(int u, int v, int w) {
        Edge e(u, v, w);
        edges.push_back(e);
    }

    void set_distances(int sp) {
        d[sp] = 0;
        for (int i = 0; i < d.size(); ++i) {
            for (Edge e : edges) {
                if (d[e.u] < INF && d[e.u] + e.w < d[e.v]) {
                    d[e.v] = d[e.u] + e.w;
                }
            }
        }
    }

    long long get_distance(int node) { return d[node]; }

    bool has_negative_cycle() {
        for (Edge e : edges) {
            if (d[e.u] < INF && d[e.u] + e.w < d[e.v]) {
                return true;
            }
        }
        return false;
    }
};

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

    int V, E, r;
    cin >> V >> E >> r;

    BellmanFord bf(V);

    for (int i = 0; i < E; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        bf.add_edge(s, t, w);
    }

    bf.set_distances(r);

    if (bf.has_negative_cycle()) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {
        for (int i = 0; i < V; ++i) {
            ll d = bf.get_distance(i);
            if (d < INF)
                cout << d << endl;
            else
                cout << "INF" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3208
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim a As Integer = NextInt()
        Dim b As Integer = NextInt()
        Dim c As Integer = NextInt()
        Dim k As Long = CLng(NextString())

        Dim ans As Integer = a - b
        If k Mod 2 <> 0 Then ans *= -1
        WriteLine(ans)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


Measured memory_bytes: 19920
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    bool OK=true;
    for(int i=0;i<s.length();i++){
        if(i%2==0) if(s[i]!='R'&&s[i]!='U'&&s[i]!='D') OK=false;
        if(i%2==1) if(s[i]!='L'&&s[i]!='U'&&s[i]!='D') OK=false;
    }
    if(OK) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
} 

Measured memory_bytes: 3612
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h =  new int[n];
        for (int i = 0;i<n;i++) {
            h[i] = sc.nextInt();
        }
        int max = h[0];
        int ans = 1;
        for (int i = 1; i < n; i++) {
            if (max <= h[i]) ans++;
            max = Math.max(max, h[i]);
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

typedef long long ll;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> xs, ys, zs;
	map<int, int> xp, yp, zp;
	int x1[60], x2[60], y1[60], y2[60], z1[60], z2[60], xm[110], ym[110], zm[110];
	ll ans = 0;
	for(int i = 0; i < N; ++i){
		scanf("%d%d%d%d%d%d", &x1[i], &y1[i], &z1[i], &x2[i], &y2[i], &z2[i]);
		xs.push_back(x1[i]);
		xs.push_back(x2[i]);
		ys.push_back(y1[i]);
		ys.push_back(y2[i]);
		zs.push_back(z1[i]);
		zs.push_back(z2[i]);
	}
	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());
	sort(zs.begin(), zs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	ys.erase(unique(ys.begin(), ys.end()), ys.end());
	zs.erase(unique(zs.begin(), zs.end()), zs.end());
	
	for(int i = 0; i < 2 * N; ++i){
		if(xs.size() > i){
			xm[i] = xs[i];
			xp[xs[i]] = i;
		}
		if(ys.size() > i){
			ym[i] = ys[i];
			yp[ys[i]] = i;
		}
		if(zs.size() > i){
			zm[i] = zs[i];
			zp[zs[i]] = i;
		}
	}
	int cnt[110][110][110] = {0};
	for(int i = 0; i < N; ++i)
		for(int j = xp[x1[i]]; j < xp[x2[i]]; ++j)
			for(int k = yp[y1[i]]; k < yp[y2[i]]; ++k)
				for(int l = zp[z1[i]]; l < zp[z2[i]]; ++l)
					cnt[j][k][l]++;
					
	for(int i = 0; i < xs.size() - 1; ++i)
		for(int j = 0; j < ys.size() - 1; ++j)
			for(int k = 0; k < zs.size() - 1; ++k)
				if(cnt[i][j][k] >= K)
					ans += ((ll)(xm[i + 1] - xm[i]) * (ll)(ym[j + 1] - ym[j]) * (zm[k + 1] - zm[k]));
	
	cout << ans << endl;	
	return 0;
}

Measured memory_bytes: 6480
//Hina Arare
//https://atcoder.jp/contests/abc073/tasks/abc073_b

#include <cstdio>

int main()
{
  int N;
  int num = 0;
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
  {
    int l, r;
    scanf("%d", &l);
    scanf("%d", &r);
    num += r - l + 1;
  }
  printf("%d\n", num);
}


Measured memory_bytes: 128
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

N = int(input())
T = [int(input()) for i in range(N)]

ans = 1
for value in range(0, N):
    ans = lcm(ans, T[value])

print(ans)

Measured memory_bytes: 3060