akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  vector<pair<int, int>> a, b;
  int m = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;

    int t = 0, mint = 0;
    for (int j = 0; j < s.length(); j++) {
      if (s[j] == '(')
        t++;
      else
        t--;
      if (t < mint)
        mint = t;
    }

    if (t > 0)
      a.emplace_back(mint, t);
    else if (t < 0)
      b.emplace_back(mint, t);
    else if (mint < m)
      m = mint;
  }

  sort(a.begin(), a.end(), [&](pair<int, int> lhs, pair<int, int> rhs) {
    return lhs.first > rhs.first;
  });
  sort(b.begin(), b.end(), [&](pair<int, int> lhs, pair<int, int> rhs) {
    return lhs.second - lhs.first > rhs.second - rhs.first;
  });

  bool succ = true;
  int now = 0;
  for (auto it = a.begin(); it != a.end(); it++) {
    if (now + it->first < 0) {
      succ = false;
      break;
    }

    now += it->second;
  }

  if (now + m < 0) succ = false;

  for (auto it = b.begin(); it != b.end(); it++) {
    if (now + it->first < 0) {
      succ = false;
      break;
    }

    now += it->second;
  }

  if (succ && now == 0)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


Measured memory_bytes: 11400
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

llong dp[51][51][2501];

int main(){

  int n, a;
  scanf("%d %d", &n, &a);

  vector<int> v;
  SV(n,v);

  dp[0][0][0] = 1;
  REP(i,n){
    REP(j,n){
      REP(k,2501){
        dp[i+1][j][k] += dp[i][j][k];
        if(k-v[i] >= 0) dp[i+1][j+1][k] += dp[i][j][k-v[i]];
      }
    }
  }

  llong ans = 0;
  FOR(i,1,n+1){
     ans += dp[n][i][i*a]; 
  }

  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 50048
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    int x;cin>>x;
    int ans = 0;
    int rec=0,i=1;
    while(x>ans){
        ans += i;
        ++rec;
        ++i;
    }
    cout<<rec;
}

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

int N;
int A[100100];
int B[100100];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> A[i];
    rep(i, N) {
        if (i%2==0) B[0] += A[i];
        else B[0] -= A[i];
    }
    for (int i=1; i<N; i++) B[i] = 2*A[i-1]-B[i-1];
    rep(i, N) {
        if (i<N-1) cout << B[i] << " ";
        else cout << B[i] << endl;
    }
}

Measured memory_bytes: 2944
N = int(input())
x_list = list(map(int, input().split()))

def calc_cost(p):
    cost = 0
    for i in range(N):
        cost += (x_list[i] - p)**2
    return cost

ans = 9999999999
for x in range(101):
    ans = min(ans, calc_cost(x))
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;

    int n = s.size();
    vector<int> pii;
    for (int i = 0; i < n; )
    {
        pii.push_back(i);
        while (i < n && s[i] == 'R')
            i++;
        pii.push_back(i - 1);
        pii.push_back(i);
        while (i < n && s[i] == 'L')
            i++;
        pii.push_back(i - 1);
    }

    int ans[100000] = {};
    for (int i = 0; i < pii.size(); i += 4)
    {
        int a = pii[i], b = pii[i + 1], c = pii[i + 2], d = pii[i + 3];
        //cerr << a << ' ' << b << ' ' << c << ' ' << d << '\n';
        ans[pii[i + 1]] = (b - a + 2) / 2 + (d - c + 1) / 2;
        ans[pii[i + 2]] = (b - a + 1) / 2 + (d - c + 2) / 2;
    }
    for (int i = 0; i < n; i++)
        cout << ans[i] << " \n"[i == n - 1];

    return 0;
}


Measured memory_bytes: 3008
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int A[101010];
vector<int> PS[101010];
int ok[101010];
int Q;
//---------------------------------------------------------------------------------------------------
void _main() {
	rep(i, 2, 101010) A[i] = i;
	rep(p, 2, 101010) for (int x = p; x < 101010; x += p) if (A[x] % p == 0 and p < A[x]) PS[x].push_back(p);
	rep(p, 2, 101010) {
		int tot = 1;
		fore(x, PS[p]) {
			tot *= x;
			if (p * 2 <= tot) {
				ok[p] = 1;
				break;
			}
		}
	}
	rep(p, 2, 101010) ok[p] += ok[p - 1];

	cin >> Q;
	rep(q, 0, Q) {
		int n; cin >> n;
		printf("%d\n", ok[n]);
	}
}





Measured memory_bytes: 13768
#include<iostream>
using namespace std;
#define MAX 100
#define INFTY 1<<21
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

int prim()
{
    int u,minv;
    int d[MAX],p[MAX],color[MAX];

    for(int i=0;i<n;i++)
    {
        d[i]=INFTY;
        p[i]=-1;
        color[i]=WHITE;
    }

    d[0]=0;
    while(1)
    {
        minv=INFTY;
        u=-1;
        for(int i=0;i<n;i++)
        {
            if(minv>d[i] && color[i]!=BLACK)
            {
                u=i;
                minv=d[i];
            }
        }
        if(u==-1)break;

        color[u]=BLACK;
        for(int v=0;v<n;v++)
        {
            if(color[v]!=BLACK && M[u][v]!=INFTY)
            {
                if(d[v]>M[u][v])
                {
                    d[v]=M[u][v];
                    p[v]=u;
                    color[v]=GRAY;
                }
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(p[i]!=-1)sum+=M[i][p[i]];
    }
    return sum;
}

int main()
{
    cin >> n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            int e;
            cin >>e;
            if(e==-1)
            {
                M[i][j]=INFTY;
            }
            else
            {
                M[i][j]=e;
            }
        }
    }

    cout << prim() << endl;
    return 0;
}



Measured memory_bytes: 3096
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var sum, before int
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		if before < a {
			sum += a - before
		}
		before = a
	}
	fmt.Println(sum)
}


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

int N;
vector<vector<int>> A(2, vector<int>(101, 0));
vector<vector<int>> dp(2, vector<int>(101, 0));
int ans = 0;

void rec(int y = 0, int x = 0, int count = A[0][0]){
    
    if(y == 1 && x == N - 1){
        ans = max(ans, count);
    }
    
    if(dp[y][x] != 0 && dp[y][x] >= count) return;
    dp[y][x] = count;
    
    if(y + 1 < 2) rec(y + 1, x, count + A[y + 1][x]);
    if(x + 1 < N) rec(y, x + 1, count + A[y][x + 1]);
    
    return;
}

int main(void){
    
    cin >> N;
    for(int i = 0; i < 2; ++i) for(int j = 0; j < N; ++j) cin >> A[i][j];
    
    rec();
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$n = (int)$input[0];
$x = (int)$input[1];

$input = explode(' ', trim(fgets(STDIN)));
$ls = [];
foreach ($input as $v) {
	$ls[] = (int)$v;
}

$cnt = 1;
$at = 0;
for ($i=0; $i < $n; $i++) { 
	$at += $ls[$i];
	if ($at > $x) {
		break;
	}
	++$cnt;
}
echo $cnt;

Measured memory_bytes: 4728
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<vector>
#include<list>
#include<map>
#include<unordered_map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

#define ld  long double
#define ll  long long int
#define ull unsigned long long int
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,s,n) for(int i=s;i<n;i++)
#define endl "\n"

const ll INF = 1LL << 60;
const ld EPS = 1e-11;

//切り上げ整数除算
int divRoundUp(const int& a, const int& b) { return (a + b - 1) / b; }
//四捨五入
int roundOff(const double& a) { return (int)(a + 0.5); }
// r の(誤差付きの)符号に従って, -1, 0, 1 を返す.
int sgn(const ld& r) { return (r > EPS) - (r < -EPS); }
// a, b の(誤差付きの)大小比較の結果に従って, -1, 0, 1 を返す.
int sgn(const ld& a, const ld& b) { return sgn(a - b); }
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; }

using namespace std;

inline void Main() {
	int K; cin >> K;
	int S; cin >> S;
	int cnt = 0;
	for (int X = K; X >= 0; --X) {
		if (X > S)continue;
		for (int Y = K; Y >= 0; --Y) {
			if (X + Y > S)continue;
			int Z = S - X - Y;
			if (0 <= Z && Z <= K)
				++cnt;
		}
	}
	cout << cnt << endl;
}

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

	Main();

	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <cstddef>
#include <iostream>
#include <vector>

int n;
const int nmax = 100005;

std::array<int, nmax> a; // 1-origin
std::vector<int> lis;

int LIS1()
{
    std::array<int, nmax> L, P;
    // L[i]: length of partial LIS whose last element is a[i];
    // P[i]: index of next-to-last element of partial LIS whose last element is a[i]

    L[0] = 0;
    P[0] = -1;
    for (size_t i = 1; i <= n; ++i)
    {
        size_t longest_index = 0;
        for (size_t j = 1; j <= i - 1; ++j)
        {
            if (a[j] < a[i] && L[j] > L[longest_index])
            {
                longest_index = j;
            }
        }
        L[i] = L[longest_index] + 1;
        P[i] = longest_index;
    }

    size_t i{};
    int length = 0;
    for (size_t j = 1; j <= n; ++j)
    {
        if (L[j] > length)
        {
            length = L[j];
            i = j;
        }
    }
    while (i > 0)
    {
        lis.push_back(a[i]);
        i = P[i];
    }
    std::reverse(lis.begin(), lis.end());

    return length;
}

int LIS2()
{

    for (size_t i = 1; i <= n; ++i)
    {
        if (lis.empty() || a[i] > lis.back())
        {
            lis.push_back(a[i]);
        }
        else
        {
            auto itr = std::lower_bound(lis.begin(), lis.end(), a[i]);
            *itr = a[i];
        }
    }

    return lis.size();
}

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

    a.fill(0);
    for (size_t i = 1; i <= n; ++i)
    {
        std::cin >> a[i];
    }

    std::cout << LIS2() << std::endl;
    // for (auto elm : lis)
    // {
    //     std::cout << elm << std::endl;
    // }
}



Measured memory_bytes: 3716
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 13:24:45 2019

@author: Yamazaki Kenichi
"""

N,K = map(int,input().split())
A = list(map(int,input().split()))
def int2bin(n):
    return '{:040b}'.format(n)
a = list(map(int2bin, A))
k = int2bin(K)
res = 0
flg = False
for i in range(40):
    counta = 0
    for elem in a:
        if elem[i] == '1':
            counta += 1
        check = True if counta<N/2 else False
    if flg:
        if check:
            res += pow(2,39-i)
        continue
    if check and k[i]=='1':
        res += pow(2,39-i)
    else:
        if k[i]=='1':
            flg = True
ans =0
for elem in A:
    ans += elem^res
print(ans)


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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  vector<int> a(n+5), b(n+1);
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];

  i64 ans = 0;
  rep(i, n) {
    i64 x = min(b[i], a[i]);
    ans += x;
    b[i] -= x;

    x = min(b[i], a[i+1]);
    ans += x;
    a[i+1] -= x;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll N;
  cin >> N;
  ll H[N];
  rep(i, N) cin >> H[i];

  ll hmax = H[0];
  ll ans = 1;
  repi(i, 1, N){
    if(H[i] >= hmax){
      hmax = H[i];
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			if (!sc.hasNext()) {
				break;
			}
			double v = sc.nextDouble();
			int ret = 0;
			for (int i = 1;; i++) {
				ret = i;
				if (v > Math.sqrt(2 * 9.8 * (5 * i - 5))) {
					continue;
				}
				break;
			}
			System.out.println(ret);
		}

	}

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

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    string s;cin>>s;
    int n = s.size();
    int s_cnt = 0,t_cnt = 0;
    rep(i,n){
        if(s[i]=='S'){
            s_cnt++;
        }
        else{
            if(s_cnt > t_cnt)t_cnt++;
        }
    }
    cout << n - t_cnt*2 << endl;
}



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

using namespace std;

int main(){
    string f,s;
    cin>>f>>s;
    int correct=0;
    for(int i=0; i<3; i++){
        if(f[i]==s[i]){
            correct++;
        }
    }
    cout<<correct<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll minus = 0, ans = 0;
  rep(i, n) {
    ll b;
    cin >> b;
    a[i] -= b;
    if(a[i] < 0) {
      minus += a[i];
      ans++;
    }
  }
  sort(all(a), greater<ll>());
  rep(i, n) {
    if(minus >= 0) break;
    minus += a[i];
    ans++;
  }
  if(minus < 0) ans = -1;
  cout << ans << endl;
}

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

int main()
{
	string S;
	cin >> S;

	int N = S.size();
	map<char, int> mp;
	for( int i = 0; i < N; i++ ) {
		mp[ S[i] ]++;
	}
	string ans = "YES";
	if( abs( mp['a'] - mp['b'] ) > 1 ) ans = "NO";
	if( abs( mp['b'] - mp['c'] ) > 1 ) ans = "NO";
	if( abs( mp['c'] - mp['a'] ) > 1 ) ans = "NO";

	cout << ans << endl;
}


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

int main() {
  int n;cin>>n;
  ll ans=0;
  rep(i,n){
    int a;cin>>a;
    while(1){
      if(a%2==1)break;
      a/=2;ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

struct UnionFind{

    std::vector<int> data;
    // dataの各要素について
    // 負の値:その集合のルートであること示す。また、その絶対値は集合の要素数となっている。
    // 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない

    //初期化 size:最大要素数
    UnionFind(int size): data(size, -1) {}
    
    // 集合を併合する
    // すでに同じ集合だった場合は、falseが返る
    bool unite(int x, int y){
        x=root(x);
        y=root(y);
        if( x != y ){
            // 要素数の大きな方へ合併するためのswap
            if( data[y] < data[x] ) std::swap(x, y);
            // 要素数を加算する
            data[x] += data[y];
            // yの属する集合のルートをxに変更
            data[y] = x;
        }
        return x!=y;
    }

    // 同じ集合かどうか判定
    bool find(int x, int y){
        return root(x) == root(y);
    }

    // 集合の識別番号を返す
    int root(int x){
        // 負の値を持つものがその集合のルート
        // 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く)
        return (data[x] < 0)? x : data[x]=root(data[x]);
    }

    // 集合の要素数を返す
    int size(int x){
        return -data[ root(x) ];
    }
};

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

    rep(i, m){
        int a, b;
        cin  >> a >> b;
        a--; b--;
        uf.unite(a,b);
    }

    int ans = 0;
    rep(i, n){
        int t = uf.size(i);
        ans = max(ans, t);
        //cout << t << endl;
    }

    cout << ans << endl;
}



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

int main() {

  vector<vector<int>> c(3,vector<int>(3));

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }

  string answer = "Yes";

  int d1 = c[0][0] - c[1][0];
  if (d1 != (c[0][1] - c[1][1]) || d1 != (c[0][2] - c[1][2])) {
    answer = "No";
  }

  int d2 = c[1][0] - c[2][0];
  if (d2 != (c[1][1] - c[2][1]) || d2 != (c[1][2] - c[2][2])) {
    answer = "No";
  }

  int d3 = c[0][0] - c[0][1];
  if (d3 != (c[1][0] - c[1][1]) || d3 != (c[2][0] - c[2][1])) {
    answer = "No";
  }

  int d4 = c[0][1] - c[0][2];
  if (d4 != (c[1][1] - c[1][2]) || d4 != (c[2][1] - c[2][2])) {
    answer = "No";
  }

  cout << answer << endl;

}

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

int main(){
        int h,w,m,i,ht,wt,hmax=0,wmax=0,hcnt=0,wcnt=0,bcnt=0;
        cin >> h >> w >> m;
        vector<int> bh(h);
        vector<int> bw(w);
        vector<pair<int,int>> vp(m);
        for(i=0;i<m;++i){
                cin >> ht >> wt;
                --ht; --wt;
                ++bh.at(ht);
                ++bw.at(wt);
                hmax = max(hmax,bh.at(ht));
                wmax = max(wmax,bw.at(wt));
                vp.at(i) = make_pair(ht,wt);
        }
        for(i=0;i<h;++i) if(bh.at(i)==hmax) ++hcnt;
        for(i=0;i<w;++i) if(bw.at(i)==wmax) ++wcnt;
        for(i=0;i<m;++i){
                ht = vp.at(i).first;
                wt = vp.at(i).second;
                if(bh.at(ht)==hmax&&bw.at(wt)==wmax) ++bcnt;
        }
        if(hcnt*wcnt-bcnt==0) cout << hmax+wmax-1 << endl;
        else cout << hmax+wmax << endl;
        return 0;
}

Measured memory_bytes: 7992
open Batteries

let ( ++ ) x y = int_of_char x + y |> char_of_int

let () =
  Scanf.scanf "%s\n" String.to_list
  |> List.sort_uniq compare
  |> List.fold_left (fun x y -> if x = y then x ++ 1 else x) 'a'
  |> (fun x -> if x > 'z' then "None" else String.of_char x)
  |> print_endline


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll N, x; cin >> N >> x;
    vector<ll> a(N);
    for(int i=0; i<N; ++i) cin >> a[i];
    vector<vector<ll>> b(2020, vector<ll>(2020, 1LL<<59));
    
    for(int i=0; i<N; ++i) b[i][0] = a[i];
    for(int i=0; i<N; ++i){
        for(int j=1; j<N; ++j){
            b[i][j] = min(b[i][j-1], a[(i+N-j)%N]);
        }
    }

    ll ans = 1LL<<59;

    for(int k=0; k<N; ++k){
        ll tmp = x*k;
        for(int i=0; i<N; ++i){
            tmp += b[i][k];
        }
        chmin(ans, tmp);
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 34304
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MOD=998244353;
map<string,int> mem;

int solve(string s) {
	int len=SZ(s); if(len==0) return 1;
	if(mem.count(s)) return mem[s];
	int ret=(ll)(s[0]=='0'?1:2)*solve(s.substr(1))%MOD;
	FORE(sublen,1,len) {
		for(int times=2;times*sublen<=len;++times) {
			string ns(sublen,'1');
			REP(i,times) REP(j,sublen) if(s[i*sublen+j]=='0') ns[j]='0';
			ret=(ret+(ll)solve(ns)*solve(s.substr(times*sublen)))%MOD;
		}
	}
	return mem[s]=ret;
}

void run() {
	string s; cin>>s;
	//s=string(100,'?'); REPSZ(i,s) s[i]=rand()%2?'0':'1';
	int ans=solve(s);
	printf("%d\n",ans);
}

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


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

using namespace std;
using ll = long long;

#define reps(i,s,n) for(ll (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

const ll mod = 1e9+7;

vector<ll> fac(100011);
vector<ll> ifac(100011); 

ll mpow(ll x,ll n){
    ll ret = 1;
    while(n != 0){
        if(n & 1) ret = ret*x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return ret;
}

ll comb(ll a, ll b){ 
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> vec(n+1,0);

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

    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<100010; i++){
        fac[i+1] = fac[i]*(i+1) % mod; 
        ifac[i+1] = ifac[i]*mpow(i+1, mod-2) % mod; 
    }

    ll tmp1 = 0,tmp2 = 0;
    ll tot1 = 0,tot2 = 0;
    ll ans = 0;
    rep(i,n){
        tmp1 = (a[i] * comb(i,k-1)) % mod;
        tot1 = (tot1 + tmp1) % mod;
    }
    rep(i,n){
        tmp2 = (a[i] * comb(n-i-1,k-1)) % mod;
        tot2 = (tot2 + tmp2) % mod;
    }
    ans = (tot1 - tot2 + mod) % mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
# https://atcoder.jp/contests/agc013/tasks/agc013_a
# 単調性を愚直に調べれば良い #と思ったけどこれはめんどいぞ
from itertools import groupby
N = int(input())
A = list(map(int, input().split()))
B = []
for key, v in groupby(A):
    B.append(key)

# /\か\/となる個数を見つければ良い？違う
diff = []
for i in range(len(B) - 1):
    diff.append(1 if B[i] < B[i + 1] else -1)

# 初めて符号が変わった瞬間のものは考慮しない
nums = []
for d, v in groupby(diff):
    nums.append(len(list(v)))

# print(nums)
is_can_del = 0
ans = 0
for n in nums:
    if n == 1 and is_can_del == 1:
        is_can_del = 0
    else:
        ans += 1
        is_can_del = 1
if is_can_del == 0:
    ans += 1
print(ans)
# diff = []
# for i in range(len(A) - 1):
#     if A[i] == A[i + 1]:
#         # diff.append(0)
#         pass
#     elif A[i] < A[i + 1]:
#         diff.append(1)
#     else:
#         diff.append(-1)
# print(diff)
# print(list(groupby(diff)))


# 前処理として増加なのか減少なのかを記録


Measured memory_bytes: 103008
from fractions import gcd  # for python 3.5, use math.gcd


def main():
    A, B, C, D = list(map(int, input().split(' ')))
    gcd_cd = gcd(C, D)
    lcm_cd = C * D // gcd_cd
    A -= 1
    a = A - A // C - A // D + A // lcm_cd
    b = B - B // C - B // D + B // lcm_cd
    print(b - a)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef vector<ll> vll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};

class Sparse_Segment_Tree{
  public:
    ll n_;
    unordered_map<ll, int> lazy2;

    Sparse_Segment_Tree(void){
      n_=1;
      return;
    };

    ~Sparse_Segment_Tree(void){
      return;
    };

    inline ll get_hash(ll l, ll r){
      return l*2000000001 + r;
    }

    //[a,b)の範囲に対してxを作用させる
    void rangeupdate2(ll a, ll b, int x, ll l, ll r){
      if(a<=l && r<=b){
        chmin(lazy2[get_hash(l,r)], x);
      }else{
        if(a<(l+r)/2) rangeupdate2(a, b, x, l, (l+r)/2);
        if((l+r)/2<b) rangeupdate2(a, b, x, (l+r)/2, r);
      }
      return;
    }

    void rangeupdate2(ll a, ll b, int x){
      while(n_<=b) n_<<=1;
      rangeupdate2(a, b, x, 0, n_);
      return;
    }

    int pointquery(ll a, ll l, ll r){
      int tmp = 0;
      if(lazy2.find(get_hash(l,r))!=lazy2.end()) tmp = lazy2[get_hash(l,r)];
      if(r-l<=1) return tmp;
      if(a<(l+r)/2) return min(tmp, pointquery(a, l, (l+r)/2));
      return min(tmp, pointquery(a, (l+r)/2, r));
    };

    int pointquery(ll a){
      if(a<0){
        fprintf(stderr, "Segment_Tree Search Space Error\n");
        fprintf(stderr, "Desired:\n");
        fprintf(stderr, "%lld <= %lld\n", 0, a);
        exit(0);
      }else if(n_<=a){
        return 0;
      }
      return pointquery(a, 0, n_);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, Q;
  cin >> N >> Q;

  Sparse_Segment_Tree que;

  ll Shift = 1000000001;

  ll S, T, X;
  REP(i,N){
    cin >> S >> T >> X;
    que.rangeupdate2(S-X+Shift, T-X+Shift, X-Shift);
  }

  ll D;
  REP(i,Q){
    cin >> D;
    ll X = que.pointquery(D+Shift)+Shift;
    if(X==Shift) X=-1;
    cout << X << "\n";
  }

  return 0;
}

Measured memory_bytes: 118096
import sys
input = sys.stdin.readline


N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

Cl = [-1]*N
C = [[0], []]
q = [0]
c = 0
Cl[0] = 0
while q:
    qq = []
    c ^= 1
    for p in q:
        for np in graph[p]:
            if Cl[np]  == -1:
                Cl[np] = c
                C[c].append(np)
                qq.append(np)
    q = qq

if len(C[0]) > len(C[1]):
    C = [C[1], C[0]]

c0 = (N+2)//3
c1 = (N+1)//3
c2 = N//3
Co = [[], [], []]
if len(C[0]) < c1:
    R = set(C[0])
    for r in R:
        Co[2].append(r)
    for p in range(N):
        if p in R:
            continue
        elif len(Co[0]) < c0:
            Co[0].append(p)
        elif len(Co[1]) < c1:
            Co[1].append(p)
        else:
            Co[2].append(p)
# elif len(C[1]) < c1:
#     R = set(C[1])
#     for r in R:
#         Co[2].append(r)
#     for p in range(N):
#         if p in R:
#             continue
#         elif len(Co[0]) < c0:
#             Co[0].append(p)
#         elif len(Co[1]) < c1:
#             Co[1].append(p)
#         else:
#             Co[2].append(p)
else:
    R2 = set(C[1])
    for p in range(N):
        if p in R2: # larger
            if len(Co[0]) < c0:
                Co[0].append(p)
            else:
                Co[2].append(p)
        else: # smaller
            if len(Co[1]) < c1:
                Co[1].append(p)
            else:
                Co[2].append(p)

ans = [None]*N
for i, n in enumerate(Co[0]):
    ans[n] = 3*i+1
for i, n in enumerate(Co[1]):
    ans[n] = 3*i+2
for i, n in enumerate(Co[2]):
    ans[n] = 3*i+3


print(*ans)

Measured memory_bytes: 100032
#include <iostream>
#include <cstdio>
#define N 2005
using namespace std;

long long n, m, M=1e9+7, a[N], b[N], d[N][N];
int main() {
	long long i, j;
	cin >> n >> m;
	for(i=1; i<=n; i++) cin >> a[i];
	for(i=1; i<=m; i++) cin >> b[i];
	for(i=0; i<=n; i++) for(j=0; j<=m; j++) {
		if(i<1 || j<1) d[i][j] = 1;
		else d[i][j] = (d[i-1][j] + d[i][j-1] - (a[i]==b[j] ? 0 : d[i-1][j-1]) + M) % M;
	}
	cout << d[n][m];
	return 0;
}


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

int main() {
    int a;
    int b;
    int c;
    int d;

    scanf("%d%d%d%d", &a, &b, &c, &d);
    if(abs(a - c) <= d || abs(a - b) <= d && abs(b - c) <= d) {
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
int n,a[N],pre[N],bk[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    pre[1]=a[1];
    bk[n]=a[n];
    for(int i=2;i<=n;i++) pre[i]=max(pre[i-1],a[i]);
    for(int i=n-1;i>=1;i--) bk[i]=min(bk[i+1],a[i]);
    bool flag=true;
    for(int i=1;i<=n;i++)
        if((a[i]&1)^(i&1)) flag=false;
    for(int i=2;i<n;i++)
        if(a[i]!=i&&a[i-1]!=i-1&&a[i+1]!=i+1) flag=false;
    //for(int i=2;i<n;i++)
    //    if(a[i]==i&&a[i-1]!=i-1&&a[i+1]!=i+1&&(pre[i-1]<i||bk[i+1]>i)) flag=false;
    for(int i=1;i<n;i++)
        if(a[i]==i&&a[i+1]==i+1&&pre[i]!=i) flag=false;
    for(int i=2;i<n;i++)
        if(a[i]!=i&&pre[i-1]>a[i]&&bk[i+1]<a[i]) flag=false;
   // for(int i=2;i<=n;i++) pre[i]=min(pre[i-1],a[i]);
    //for(int i=n-1;i>=1;i--) bk[i]=max(bk[i+1],a[i]);
    //for(int i=1;i<=n;i++)
    //    if(i<a[i]&&pre[i-1]>a[i]) flag=false;
    //for(int i=n-1;i>=1;i--)
    //    if(i>a[i]&&bk[i+1]<a[i]) flag=false;
    printf(flag?"Yes\n":"No\n");
}


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

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

  vector<int> d(N);
  int sum_d = 0;

  REP(i, N) {
    cin >> d[i];
    sum_d += d[i];
  }

  int ans = 0;
  REP(i, N) ans += d[i] * (sum_d - d[i]);

  cout << ans / 2 << endl;

  return 0;
}

Measured memory_bytes: 256
def solve(x):

    a = -1000
    while a <= 1000:
        b = -1000
        while b < 1000 :
            if x + b **5 == a**5:
                break
            else:
                b += 1
        if x + b **5 == a**5:
            break
        else:
            a+=1

    return "{0} {1}".format(a,b)

if __name__ == "__main__":
    x = int(input())
    print(solve(x))

Measured memory_bytes: 9096
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
LL n,mod,len,asd=0;
char ss[400022];
LL cou[200022],cun[200022];
int main()
{
	n=read();mod=read();
	scanf("%s",ss);len=strlen(ss);
	if(mod==2)
	{
		for(int i=0;i<len;++i)
		{
			if(!((ss[i]-'0')&1))asd+=i+1;
		}
		printf("%lld\n",asd);
		return 0;
	}
	if(mod==5)
	{
		for(int i=0;i<len;++i)
		{
			if(((ss[i]-'0')==0)||((ss[i]-'0')==5))asd+=i+1;
		}
		printf("%lld\n",asd);
		return 0;
	}
	reverse(ss,ss+len);
	LL bas=1;
	LL kk=0;
	for(int i=0;i<len;++i)
	{
		kk=(kk+(ss[i]-'0')*bas)%mod;
		asd+=cou[kk]++;
		if(kk==0)asd++;
		bas=(bas*10)%mod;
	}
	printf("%lld\n",asd);
}//

Measured memory_bytes: 512
#include<iostream>
#include<stdlib.h>

using namespace std;

void get_digit(int a,int b){
  int sum = a+b;
  int digit=0;

  while(sum != 0){
    sum /= 10;
    digit++;
  }

  cout <<digit << "\n";
}

int main(){
  int i=0;
  int input=-1;
  int a=-1,b=-1;

  while(cin >> input ){
    i++;
    if(i == 1){
      a = input;
    }else if(i == 2){
      b = input;
      i=0;
    }
    if(i == 0){
      get_digit(a,b);
      a = -1;
      b= -1;
    }
  }

  return 0;
}



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

int main(){
  int n;
  cin >> n;
  string s=to_string(n);
  int m=0;
  for(int i=0;i<s.size();i++)m+=s.at(i)-'0';
  cout << (n%m==0?"Yes":"No") << endl;
}

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

unsigned solve(const std::vector<unsigned> w, const unsigned k){
	const unsigned limit_weight = std::accumulate(w.begin(),w.end(),unsigned(0));
	unsigned max_weight = *std::max_element(w.begin(),w.end());
	if(k == 1) return limit_weight;
	if(w.size() <= k) return max_weight;

	unsigned step = limit_weight/k;

	auto is_valid_division = [&w,&k](unsigned current_max_weight){
		size_t i = 0;
		auto rest = k;
		while(rest-- > 0){
			unsigned sum = 0;
			for(;i<w.size() && sum + w[i] <= current_max_weight;++i){
				sum += w[i];
			}
		}
		return (i == w.size());
	};

	FORWARD:
	for(; !is_valid_division(max_weight);max_weight += step);

	if(is_valid_division(max_weight-1) || !is_valid_division(max_weight+1)){
		step = (step/10 != 0 ? step/10 : 1);
		for(; is_valid_division(max_weight);max_weight -= step);
		if(step != 1){
			step = (step/10 != 0 ? step/10 : 1);
			goto FORWARD;
		}
		else{
			max_weight++;
		}
	}

	return max_weight;
}

int main(){
	std::ios::sync_with_stdio(false);
	{
		std::vector<unsigned> w;
		unsigned k;
		{
			unsigned n;
			std::cin >> n >> k;
			w.reserve(n);

			{
				unsigned buf;
				for(unsigned i=0;i<n;++i){
					std::cin >> buf;
					w.push_back(buf);
				}
			}
		}
		std::cout << solve(w,k) << std::endl;
	}
}

Measured memory_bytes: 3576
import math

H, W = map(int, input().split())
if H == 1 or W == 1:
  print("1")
  exit()
result = 0
yoko_1 = 0
yoko_2 = 0

if W%2 == 0:
  yoko_1 = int(W/2)
  yoko_2 = int(W/2)
else:
  yoko_1 = int(math.floor(W/2+0.5))
  yoko_2 = int(math.floor(W/2-0.5))
  
tate_1 = 0
tate_2 = 0

if H%2 == 0:
  tate_1 = int(H/2)
  tate_2 = int(H/2)
else:
  tate_1 = int(math.floor(H/2+0.5))
  tate_2 = int(math.floor(H/2-0.5))

result = yoko_1 * tate_1 + yoko_2 * tate_2

print(int(result))

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


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >>d;
    int p = (a-1)/d + 1;
    int q = (c-1)/b + 1;
    if(q <= p) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll l,r;
  cin >> l >> r;
  ll ans=MAX;
  REP(x,l,r+1) {
    REP(y,x+1,r+1) {
      ans=min(ans,x*y%2019);
      if(!ans) goto end;
    }
  }
 end:;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,K;
    cin >> A >> B >> C >> K; 
  if(K <= A){
    cout << K << endl; 
  }
  else if(K > A && K - A <= B){   
    cout << A << endl;
  }
  else {
      cout << 2 * A - K + B << endl;
  }
     
}

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N, A, B, ans;
    scanf("%d %d %d", &N, &A, &B);
    if ( N * A <= B ) printf("%lld\n", N * A);
    else printf("%d\n", B);
    return 0;
}

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



const int MAX = 10000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
  
  
int main(){
  long long int x, y;
  long long int n, k, ans;
  
  cin >> x >> y;
  if((2*x-y)%3!=0 || (-x+2*y)%3!=0){
    cout << 0 << endl;
  }
  else{
    COMinit();
    n = (x+y)/3;
    k = (2*x-y)/3;
    ans = COM(n,k);
    cout << ans << endl;
  }
}

Measured memory_bytes: 234624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e,k;
  cin >>a>>b>>c>>d>>e>>k;
  if(e-a<=k){
    cout <<"Yay!"<<endl;
  }
  else{
    cout <<":("<<endl;
  }
}
    
    

Measured memory_bytes: 384
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

signed main(){
    ll n;
    
    cin >> n;
    ll a[n] = {};
    
    rep(i,0,n) cin >> a[i];
    
    repr(i,0,n+1){
        ll cnt = 0;
        rep(j,0,n){
            if(a[j] >= i) cnt++;
        }
        if(cnt >= i){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define llong long long
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 1e6;
const llong P = 1e9+7;
const llong INV3 = 333333336ll;
llong fact[N+3],finv[N+3];

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++) {if(y&(1ll<<i)) {ret = ret*cur%P; y-=(1ll<<i);} cur = cur*cur%P;}
	return ret;
}
llong comb(llong x,llong y) {return x<0||y<0||x<y?0ll:fact[x]*finv[y]%P*finv[x-y]%P;}

llong f[N+3][3];
int n;

void updsum(llong &x,llong y) {x = x+y>=P?x+y-P:x+y;}

int main()
{
	fact[0] = 1ll; for(int i=1; i<=N; i++) fact[i] = fact[i-1]*i%P;
	finv[N] = quickpow(fact[N],P-2); for(int i=N-1; i>=0; i--) finv[i] = finv[i+1]*(i+1)%P;
	scanf("%d",&n);
	f[0][0] = 1ll;
	for(int i=1; i<=n; i++) for(int j=0; j<3; j++) for(int k=0; k<3; k++) {if(k!=j) updsum(f[i][j],f[i-1][k]);}
	llong ans = 0ll;
	for(int i=1; i<=n; i++)
	{
		llong cur = f[i][1]*comb(n,i)%P*finv[i]%P*fact[i-1]%P; updsum(ans,cur);
	}
	ans = ans*finv[n]%P*fact[n-1]%P*quickpow(INV3,n)%P;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 39296
import functools
import sys

n, m = map(int, input().split())
a = list(map(lambda x: x // 2, map(int, input().split())))

# A[0]を素因数分解して2で割り切れる回数を数える
div = 0

a_0 = a[0]
while a_0 % 2 == 0:
    a_0 /= 2
    div += 1

# print("count = " + str(div))#

# Aのすべての整数がA[0]と同じ回数2で割り切れるか調べる
for i in range(1, len(a)):
    div2 = 0
    tmp_a = a[i]
    while tmp_a % 2 == 0:
        tmp_a /= 2
        div2 += 1
    # print("A[" + str(i) + "] count = " + str(div2))#
    if div2 != div:
        print("0")
        sys.exit()


def gcd(x, y):
    if x == 0:
        return y

    return gcd(y % x, x)


def least_common_multiple(iter):
    '''
    最小公倍数を返す
    '''
    lcm = lambda x, y: x * y // gcd(x, y)
    return functools.reduce(lcm, iter)


lc = least_common_multiple(a)
ans = 0
a = 1

ans = m // lc
if ans == 0:
    print(0)
    sys.exit()
if ans % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + 1)


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

int main()
{
    int a, b;
    cin >> a >> b;

    if ((a * b) % 2 == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }

    return 0;
}

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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i < (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p,)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do{ cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << setprecision(20);
    }
} iosetup;

// YOUR CODE GOES HERE ↓↓↓
const int inf = 1000000000;
int H, W, K;
int D[800][800];
int D2[800][800];
char G[800][800];
queue<pair<int, int>> que_tourist;
queue<pair<int, int>> que;
const int dx[] = { 1, 0, -1, 0 };
const int dy[] = { 0, 1, 0, -1 };
bool in_i(int i){ return 0 <= i && i < H; }
bool in_j(int j){ return 0 <= j && j < W; }

void bfs_tourist(){
    while(que_tourist.size()){
        pair<int, int> pa = que_tourist.front();
        que_tourist.pop();
        que.push(pa);
        int i = pa.first, j = pa.second;
        if(D[i][j] == K)continue;
        rep(k, 4){
            int ni = i + dx[k], nj = j + dy[k];
            if(in_i(ni) && in_j(nj) && G[ni][nj] != '#' && chmin(D[ni][nj], D[i][j] + 1)){
                que_tourist.push(make_pair(ni, nj));
            }
        }
    }
}

void bfs(){
    while(que.size()){
        pair<int, int> pa = que.front(); que.pop();
        int i = pa.first, j = pa.second;
        rep(k, 4){
            int ni = i + dx[k], nj = j + dy[k];
            if(in_i(ni) && in_j(nj) && chmin(D[ni][nj], D[i][j] + 1)){
                que.push(make_pair(ni, nj));
            }
        }
    }
}

int ans = inf;
void takeans(){
    rep(i, H){
        chmin(ans, D[i][0]);
        chmin(ans, D[i][W - 1]);
    }
    rep(i, W){
        chmin(ans, D[0][i]);
        chmin(ans, D[H - 1][i]);
    }
}

int main(){

    cin >> H >> W >> K;
    rep(i, H)rep(j, W){
        cin >> G[i][j];
        if(G[i][j] == 'S')que_tourist.push(make_pair(i, j));
        else D[i][j] = inf;
    }

    bfs_tourist();
    takeans();
    rep(i, H)rep(j, W)chmax(D[i][j], K);
    bfs();
    takeans();
    cout << (ans + K - 1) / K << endl;

}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

void leave(string message) {
    cout << message << endl;
    exit(0);
}

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

    vector<lint> a(n);
    for(auto& elem : a)  cin >> elem;
    for(auto& elem : a)  elem = elem / 2;

    lint lcm = 1;
    for(lint i=0; i<n; i++) {
        lcm = a[i] / __gcd(a[i], lcm) * lcm;
    }

    for(lint i=0; i<n; i++) {
        if((lcm/a[i])%2 == 0)  leave("0");
    }    

    // (2*lcm)*i + lcm が何個入るか
    lint ans = floor((double)(m-lcm) / (2*lcm));
    cout << ++ans << endl;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        x: [usize; 5],
    }

    for (i, n) in x.into_iter().enumerate() {
        if n == 0 {
            echo!(i + 1);
        }
    }
}


Measured memory_bytes: 2136