akhauriyash/Code-Regression huggingface dataset:
#define ENABLE_DEBUG 0
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define REP(i, k) for (decltype(k) i = 0; i < k; i++)
#define LOOP(k) REP (ngtkana_is_a_genius, k)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
auto cmx = [](auto& x, auto y){ if (x<y) { x=y; return true; } return false; };
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    auto make_dp = [&] (auto seq, bool sort) {
        usize sz = seq.size();
        usize Sz = 1u << sz;
        vec<diag_pair<u64>> ans;
        for (u64 i=0; i<Sz; i++) {
            diag_pair<u64> now;
            for (u64 j=0; j<sz; j++) if (i>>j&u64{1u}) {
                now.first += seq.at(j).first;
                now.second += seq.at(j).second;
            }
            ans.push_back(now);
        }
        if (!sort) return ans;
        std::sort(ALL(ans));
        {
            vec<diag_pair<u64>> swp;
            for (auto [w, v]: ans) {
                if (swp.empty() || swp.back().second < v) swp.emplace_back(w, v);
            }
            swp.swap(ans);
        }
        return ans;
    };

    u64 n;
    std::cin >> n;
    vec<diag_pair<u64>> wv(n+1);
    for (usize i=1; i<=n; i++) {
        u64 v, w; std::cin >> v >> w;
        wv.at(i) = {w, v};
    }
    DEBUG(wv);

    u64 lmax = std::min(n, u64{1<<11});
    auto sorted = vec<vec<diag_pair<u64>>>(lmax + 1);
    for (u64 i=1; i<=lmax; i++) {
        vec<diag_pair<u64>> seq;
        u64 x = i;
        for (; x; x>>=1) {
            DEBUG(x);
            seq.push_back(wv.at(x));
        }
        sorted.at(i) = make_dp(seq, true);
    }
    DEBUG(lmax, sorted);

    usize q; std::cin >> q;
    LOOP (q) {
        u64 x, W; std::cin >> x >> W;
        vec<diag_pair<u64>> right;
        u64 lx = 0;
        for (; x; x>>=1) {
            DEBUG(x);
            if (x<=lmax) {
                lx = x;
                break;
            }
            right.push_back(wv.at(x));
        }
        auto Right = make_dp(right, true);
        DEBUG(x, lx, W, wv, sorted.at(lx), Right);
        assert(lx!=0);

        u64 ans = 0;
        for (auto&& [w, v]: Right) if (w <= W) {
            DEBUG(w, v, W-w+1);
            auto it = std::lower_bound(ALL(sorted.at(lx)), std::make_pair(u64{W-w+1}, u64{0}));
            assert(it!=sorted.at(lx).begin());
            it--;
            DEBUG(*it);
            cmx(ans, v + it->second);
        }
        std::cout << ans << '\n';
    }
}



Measured memory_bytes: 50648
#include <iostream>
#include <cstring>
#include <vector>
#include <cctype>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep(i, n) for( int i = 0; i < n; i++ )
typedef vector<int> vec;

int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double dist = (sqrt)((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    // cout << dist << endl;
    printf("%.6f\n", dist);
}

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

int main() {
  int a,b;
  cin >> a >>b;
  int saidai = a+(a-1);
  saidai = max(saidai,a+b);
  saidai = max(saidai,b+(b-1));
  cout << saidai << endl;
}
  
  
  
  
  
  /*
	int a,b,c,d,e,f,k;
  	cin >> a >>b >> c >>d >>e >>k;
  if(a-b<=k && a-c<=k && a-d<=k && a-e<=k && b-c<=k && b-d<=k && b-e<=k && c-d<=k "Yay!"<<endl;
     else cout << ":("<<emdl;
}
 
 */

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

// ------------------------

void solve() {
    int N, K; cin >> N >> K;
    vector<double> e_value(N);
    rep(i, N){
        int p;
        cin >> p;
        e_value[i] = (p + 1) / 2.0;
    }

    //累積和の計算
    vector<double> s(N+1, 0);
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + e_value[i];

    double res = 0;
    for (int i = 0; i <= N-K; ++i) {
        double val = s[K+i] - s[i];
        if (res < val) res = val;
    }

     cout << std::fixed << std::setprecision(11) <<  res << "\n";
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using sint = int64_t;

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	auto const N = read<sint>();
	auto Ls = read_vector<sint>(N);

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

	sint n_tris = 0;
	for (sint i = 0; i < N - 2; ++i) {
		for (sint j = i + 1; j < N - 1; ++j) {
			sint l_min = abs(Ls[i] - Ls[j]);
			sint l_max = Ls[i] + Ls[j];
			auto bgn = upper_bound(Ls.begin() + j + 1, Ls.end(), l_min);
			auto end = lower_bound(bgn, Ls.end(), l_max);
			n_tris += distance(bgn, end);
		}
	}

	writeln(n_tris);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}




const int m =2019;
int main()
{
ll n;
cin>>n;
vector<ll>v(n);
rep(i,n){
    cin>>v[i];
}
ll a,b,c;
ll ans=0;
rep(i,n){
    a=v[i];
    for(ll j=i+1;j<n;j++){
        b=v[j];
        for(ll k=j+1;k<n;k++){
            c=v[k];
            if(a<b+c&&b<a+c&&c<a+b){
                if(a!=b&&b!=c&&a!=c){
                ans++;}
            }
        }
    }
}
cout<<ans<<endl;
}



Measured memory_bytes: 3632
from collections import deque
while True:
    W, H = map(int, input().split())
    if W==0 and H==0:
        break
    #それぞれのマスの上下左右の壁があるかどうかを記録
    grid = [ [ [0]*4 for _ in range(W)] for _ in range(H)] 
    #print(grid)
    #壁を埋める
    for i in range(H):
        grid[i][0][0] = 1
        grid[i][-1][1] = 1
    
    for i in range(W):
        grid[0][i][2] = 1
        grid[-1][i][3] = 1
    
    #入口と出口は空ける
    # grid[0][0][2] = 0
    # grid[-1][-1][3] = 0  

    #入力受取 
    for i in range(2*H-1):
        a = list(map(int, input().split()))
        #縦の壁
        if i%2==0:
            for j in range(W-1):
                if a[j] == 1:
                    grid[i//2][j][1] = 1
                    grid[i//2][j+1][0] = 1
        #横の壁
        else:
            for j in range(W):
                if a[j] == 1:
                    grid[i//2][j][3] = 1
                    grid[i//2+1][j][2] = 1
        
    #print(grid)

    dist = [[-1]*W for _ in range(H)]
    dist[0][0] = 0
    #print(dist)

    que = deque()
    que.append([0,0])

    #左右上下 y,x
    d = [[0,-1],[0,1],[-1,0],[1,0]]

    while que:
        #print(que)
        y,x = que.popleft()
        for i in range(4):
            if grid[y][x][i] == 0:
                dy = y + d[i][0]
                dx = x + d[i][1]
                if dist[dy][dx] == -1:
                    que.append([dy,dx])
                    dist[dy][dx] = dist[y][x]+1
    
    if dist[-1][-1] == -1:
        print(0)
    else:
        print(dist[-1][-1]+1)


Measured memory_bytes: 6204
A = [list(map(int,input().split())) for i in range(3)]

C = [[0,0,0] for i in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for k in range(3):
        for l in range(3):
            if A[k][l] == b:
                C[k][l] = 1
flag = False
for i in range(3):
    if C[0][i] == C[1][i] == C[2][i] == 1:
        flag = True
for i in range(3):
    if C[i][0] == C[i][1] == C[i][2] == 1:
        flag = True
if C[0][0] == C[1][1] == C[2][2] == 1:
    flag = True
if C[2][0] == C[1][1] == C[0][2] == 1:
    flag = True

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

Measured memory_bytes: 3064
n = int(input())
t, x, y = 0, 0, 0

for i in range(0, n):
    t_next, x_next, y_next = map(int, input().split())
    xy_diff = abs(x_next-x)+abs(y_next-y)
    t_diff = t_next - t
    if(xy_diff > t_diff or (xy_diff - t_diff)%2!=0):
        print('No')
        exit(0)
    else:
        t, x, y = t_next, x_next, y_next

print('Yes')


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n + 2, 0);
	vector<pair<int, int> > cnt(n, { 0,0 });
	bool flag = false;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (a[i]) flag = true;
	}
	if (flag) {
		int tmp = 0;
		for (int i = 1; i <= n; ++i) {
			if (a[i - 1] > a[i]) {
				while (i != n && a[i] == a[i + 1]) i++;
				if (i != n + 1 && a[i] < a[i + 1]) cnt[tmp++] = make_pair(a[i], 1);
			}
			if (a[i - 1] < a[i]) {
				//if (a[i - 1] == 0) cnt[tmp++] = make_pair(0, 1);
				while (i != n && a[i] == a[i + 1]) i++;
				if (a[i] > a[i + 1]) cnt[tmp++] = make_pair(a[i], -1);
			}
		}
		sort(cnt.begin(), cnt.end());
		int sum = 1, ans = 1;
		for (int i = 0; i < n; ++i) {
			sum += cnt[i].second;
			ans = max(ans, sum);
		}
		cout << ans << endl;
	} else cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 3896
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vi a(n);
    rep(i, n) cin >> a[i];
    int totalSwapTime = 0;
    for (;;) {
      int st = 0;
      loop(i, 1, n) {
        if (a[i - 1] <= a[i]) continue;
        swap(a[i - 1], a[i]);
        st++;
      }
      totalSwapTime += st;
      if (!st) break;
    }
    cout << totalSwapTime << endl;
  }
}

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}

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

    string acgt = "ACGT";
    string S; cin >>S;

    int max_len = 0, len = 0;
    for (auto c: S) {
        if (acgt.find(c) != string::npos) {
            len++;
        } else {
            chmax(max_len, len);
            len = 0;
        }
    }
    chmax(max_len, len);

    cout << max_len << endl;
}


Measured memory_bytes: 256
def comb(n, r, p):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    return fac[n] * (facinv[r] * facinv[n - r] % p) % p


def comb_pre(N, p):
    for i in range(2, N + 1):
        fac.append(fac[i - 1] * i % p)
        inv.append(-inv[p % i] * (p // i) % p)
        facinv.append(facinv[-1] * inv[-1] % p)


fac = [1, 1]
facinv = [1, 1]
inv = [0, 1]

N, K = map(int, input().split())
MOD = 1_000_000_007
comb_pre(N + 1, MOD)
for i in range(1, K + 1):
    tmp = comb(N - K + 1, i, MOD)
    tmp %= MOD
    tmp *= comb(K - 1, i - 1, MOD)
    tmp %= MOD
    print(tmp)


Measured memory_bytes: 9332
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long k = sc.nextLong();
        int cnt = 0;
        boolean same = true;
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(0) != s.charAt(i + 1)) {
                same = false;
            }
            if (s.charAt(i) == s.charAt(i + 1)) {
                cnt++;
                i++;
            }
        }
        if (same) {
            System.out.println(s.length() * k / 2);
            return;
        }
        long ans = k * cnt;
        if (s.charAt(0) == s.charAt(s.length() - 1)) {
            int a = 0;
            while (a < s.length() && s.charAt(0) == s.charAt(a)) {
                a++;
            }
            int b = 0;
            while (b < s.length() && s.charAt(s.length() - 1) == s.charAt(s.length() - b - 1)) {
                b++;
            }
            ans -= (k - 1) * (a / 2 + b / 2 - (a + b) / 2);
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 23124
import sys
from collections import deque, defaultdict

sys.setrecursionlimit(10**7)

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

G = defaultdict(lambda: deque())
color = [-1]*n

for _ in range(m):
    s, t = map(int, input().split())
    G[s].append(t)
    G[t].append(s)

def dfs(node, co):
    if color[node] != -1:
        return

    color[node] = co

    for n in G[node]:
        dfs(n, co)
        

c = 1
for node in G.keys():
    dfs(node, c)
    c += 1


q = int(input())
for _ in range(q):
    s, t = map(int, input().split())
    if color[s] != -1 and color[t] != -1 and color[s] == color[t]:
        print('yes')
    else:
        print('no')



Measured memory_bytes: 188148
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
int n,a[2001];
ll k,ans,cnt[2001];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for (int i=1;i<=n;++i) cin>>a[i];
	for (int i=1;i<=n;++i)
		for (int j=1;j<=n;++j)
		{
			if (a[i]>a[j] && i<j)
			{
				cnt[i]+=(((k+1)*k)/2)%MOD;
				cnt[i]%=MOD;
			}
			else if (a[i]>a[j] && i>j)
			{
				cnt[i]+=(((k-1)*k)/2)%MOD;
				cnt[i]%=MOD;
			}
		}
	for (int i=1;i<=n;++i)
	{
		ans+=cnt[i];
		ans%=MOD;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans = 0
for i in range(N):
  A = list(map(int,input().split()))
  s = sum([x * y for (x, y) in zip(A, B)])
  if s + C > 0:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

using namespace std;
using ll = long long;

int N;
int ans = 0;

void check(ll, int);
void dfs(ll x, int n)
{
	check(x, n);

	if (x <= n) {
		dfs(x*10+3, n);
		dfs(x*10+5, n);
		dfs(x*10+7, n);
	}
	return;
}

void check(ll x, int n)
{
	if (x <= n) {
		int a[10] = {};
		ll b = x;
		while (b > 0) {
			a[b % 10]++;
			b /= 10;
		}
		if (a[3] * a[5] * a[7] > 0)
			ans++;
	}
}

int main()
{
	cin >> N;
	string tmp = to_string(N);
	int keta = tmp.size() - 1;

	dfs(0, N);
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int main() {
  int N; cin >> N;
  vi A(N); rep(i,N) cin >> A.at(i);
  
  int ans = 0;
  rep(i,N) {
    ans = gcd(ans, A.at(i));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
N=int(input())
S=[0 for j in range(4)]
Sstr=["AC", "WA", "TLE", "RE"]
for i in range(N):
    inputS=input()
    if inputS=="AC":
        S[0]+=1
    elif inputS == "WA":
        S[1]+=1
    elif inputS == "TLE":
        S[2]+=1
    else:
        S[3]+=1
for i in range(4):
    print(Sstr[i] + " x " + str(S[i]))

Measured memory_bytes: 9208
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <chrono>
#include<map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef unsigned int ui;
typedef unsigned short us;
typedef unsigned long long ull;

using namespace std;


int inputValue() {
  int a;
  scanf("%d", &a);
  return a;
};
void inputVector(vector<int>* v) {
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  p->clear();
  p->shrink_to_fit();
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, ui r, ui c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}

template<template <class...> class Map, typename T_0, typename T_1, typename... Args>
void inputMap(Map<T_0, T_1, Args...>& mp) {
  T_0 a;
  T_1 b;
  while (cin >> a && a != -1) {
    cin >> b;
    mp.insert(make_pair(a, b));
  }
}
template<template <class...> class Vec1, template <class...> class Vec2, typename T, typename... Args1, typename... Args2>
void input2dPairVector(Vec1<Vec2<T, Args2...>, Args1...>& vec) {
  T a;
  T b;
  while (cin >> a && a != -1) {
    cin >> b;
    vec.push_back(vector<T>({ a - 1, b - 1 }));
  }
}
template<template <class...> class Vec1, template <class...> class Vec2, typename T, typename... Args1, typename... Args2>
void input2dPairVector(Vec1<Vec2<T, Args2...>, Args1...>& vec, ull size) {
  T a;
  T b;
  for (size_t i = 0; i < size; i++) {
    scanf("%d %d", &a, &b);
    vec.push_back(vector<T>({ a - 1, b - 1 }));
  }
}

template<template <class...> class Vec, typename T, typename U, typename... Args>
void numberToBoolenVector(Vec<T, Args...>& vec, U a) {
  ui i = 0;
  T amari;
  do {
    if (a % (ull)pow(2, i + 1)) {
      amari = 1;
      vec.push_back(amari);
      a -= (ull)pow(2, i);
    }
    else {
      amari = 0;
      vec.push_back(amari);
    }
    i++;
  } while (a);
}

template<template <class...> class Vec, typename T, typename... Args>
ull boolenVectorToNumber(Vec<T, Args...>& vec) {
  ull r = 0;
  for (size_t i = 0; i < vec.size(); i++)
  {
    r += vec[i] * (ull)pow(2, i);
  }
  return r;
}

int main(int argc, const char * argv[]) {
  ull a, p;
  scanf("%lld %lld", &a, &p);
  ull kotae;
  kotae = (3 * a + p) / 2;
  printf("%lld", kotae);
}


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

int main()
{
  int a,b,c,d;
  int res=INF;
  cin >> a>>b>>c>>d;

  res = min(a+c,b+d);
  res = min(res, a+d);
  res = min(res, b+c);

  cout << res << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,k,q,f[100005];
int main()
{
    cin>>n>>k>>q;
    int x;
    for(int i=0;i<q;++i)
    {
        cin>>x;
        f[x]++;
    }
    for(int i=1;i<=n;++i)
    {
        if(f[i]+k-q<=0)cout<<"No\n";
        else cout<<"Yes\n";
    }
    return 0;
}


Measured memory_bytes: 1024
//in the name of god
#include <bits/stdc++.h>

using namespace std;
#define F first
#define S second

int n;
pair <int, int> d[100];

int main()
{
    cin >> n;
    for(int i = 0; i < n; i ++)
    {
        cin >> d[i].F >> d[i].S;
    }

    int checkcont = 0;
    for(int i = 0; i < n; i ++)
    {
        if(d[i].F == d[i].S)
        {
            checkcont ++;
        }

        else
        {
            checkcont = 0;
        }

        if(checkcont == 3)
        {
            cout << "Yes" << '\n';
            return 0;
        }
    }

    cout << "No" << '\n';
    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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;
}

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

const int inf=100000000;



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

    int r;
    cin>>r;
    int d;
    cin>>d;
    int c[100];
    cin>>c[0];

    for(int i=0; i<10; i++)
    {
        c[i+1]=r*c[i]-d;
        cout<<c[i+1]<<endl;
    }
    cout<<endl;
    
    return 0;

}

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

using namespace std;

int main() {

    long n;
    cin >> n;
    long arr[n];
    for(long i=0;i<n;i++){
        cin >> arr[i];
    }
    long k=1,count =0;;
    for(long i=0;i<n;i++){
        if(arr[i]==k){
            k++;
        }else{
            count++;
        }
    }
    if(count == n){
        cout << -1;
    }else{
    cout << count;}

}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <math.h>
#include <iomanip>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n;
   	cin>>n;
   	int d[n];
   	for(int i=0;i<n;++i){cin>>d[i];}
   	sort(d,d+n);
   	int tmp,ans;
   	ans=0;
   	tmp=d[0];ans++;
   	for(int i=1;i<n;++i){if(d[i]>tmp){ans++;tmp=d[i];}}
   	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long
int swap(int* x, int* y){
  int work = *x;
  *y=*x;
  *x=work;
}

int main(){
  int N;
  cin >> N;
  int p[N+1];
  for(int i = 1; i<N+1; ++i){
    cin >> p[i];
  }
  int count=0;

  for(int i = 1; i<N; ++i){
    if(p[i] == i){
      swap(&p[i], &p[i+1]);
        count += 1;
        ++i;
    }
  }
  if(p[N] == N){
    count += 1;
  }
  cout << count;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std ;
template< class T > inl T read() {
	T x = 0 ; int f = 1 ; char k = getchar() ;
	for( ; k > '9' || k < '0'; k = getchar() ) if( k == '-' ) f = -1 ;
	for( ; k >= '0' && k <= '9'; k = getchar() ) x = x * 10 + k - '0' ;
	return x * f ;
}
template< class T > inl T read( T &x ) { return x = read<T>() ; }
int _num, _buf[20];
template< class T > il print( T x ) {
   	if( x == 0 ) return putchar( '0' ) ,void() ;
	if( x < 0 ) putchar( '-' ), x = -x ;
	while( x ) _buf[++_num] = x % 10, x /= 10 ;
	while( _num ) putchar( _buf[_num--] + '0' ) ;
}
ll mul( ll a, ll b, ll mod ) { long double c = 1. ; return ( a * b - (ll)( c * a * b / mod ) * mod ) % mod ; }
it qpow( int x, int m, int mod ) {
	int res = 1, bas = x ;
	while(m) {
		if( m & 1 ) res = ( 1ll * res * bas ) % mod ;
		bas = ( 1ll * bas * bas ) % mod, m >>= 1 ;
	}
	return res ;
}
const int N = 2e5 + 5 ;
int n, k, val[N];
inl bool chk( int len ) {
	int rest = k + n ;
	for( ri i = 1; i <= n; ++i )
		rest -= ( val[i] + len - 1 ) / len ;
	return rest >= 0 ;
}
int main() {
//	freopen( ".in", "r", stdin ) ;
//	freopen( ".out", "w", stdout ) ;
	n = read<int>(), k = read<int>() ;
	int l = 1, r = 0 ;
	for( ri i = 1; i <= n; ++i ) {
		val[i] = read<int>() ;
		r = std::max( r, val[i] ) ;
	}
	while( l < r ) {
		if( chk ( mid ) )
			r = mid ;
		else
			l = mid + 1 ;
	}
	print( mid ), puts( "" ) ;
	cerr << 1. * clock() / CLOCKS_PER_SEC << "\n" ;
	return 0;
}

Measured memory_bytes: 4544
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

typedef pair<int ,int> P;

vector<int> primes;

void init_prime() {
    while (primes.size() < 200000) {
        if (primes.size() == 0) {
            primes.push_back(2);
            continue;
        }
        for (int n=primes[primes.size()-1]+1; true; n++) {
            bool is_prime = true;
            for (int i=0; i<(int)primes.size(); i++) {
                if (n%primes[i] == 0) {
                    is_prime = false;
                    break;
                }
                if (primes[i]*primes[i] > n) {
                    break;
                }
            }
            if (is_prime) {
                primes.push_back(n);
                break;
            }
        }
    }
}

int matsuzaki(int n, int p) {
    int least;
    vector<int> m;
    for (least=0; primes[least]<=n; least++);
    for (int bigger=least; bigger<least+p; bigger++) {
        for (int smaller=least; smaller<=bigger; smaller++) {
            m.push_back(primes[smaller]+primes[bigger]);
        }
    }
    sort(m.begin(), m.end());
    return m[p-1];
}

int main()
{
    int n, p;
    init_prime();
    while (true) {
        cin >> n >> p;
        if (n < 0) {
            break;
        }
        cout << matsuzaki(n, p) << endl;
    }
    return 0;
}

Measured memory_bytes: 1984
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

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

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

    int n, x, t;
    cin >> n >> x >> t;

    int ans = (n/x) * t;

    if (n%x != 0) ans += t;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int a[1001][1001];
long long int dp[1001][1001];
int main()
{
    long long int i,j,k,n,m;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        string s;
        cin>>s;
        for(j=0;j<s.size();j++)
        {
            if(s[j]=='.')
            a[i][j]=1;
            else
            a[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(i=1;i<m;i++)
     if(a[0][i]==0)
      dp[0][i]=0;
     else
      dp[0][i]=dp[0][i-1];
    for(i=1;i<n;i++)
     if(a[i][0]==0)
      dp[i][0]=0;
     else
      dp[i][0]=dp[i-1][0];
     for(i=1;i<n;i++)
     {
         for(j=1;j<m;j++)
         {
             if(a[i][j]==0)
             dp[i][j]=0;
             else
             dp[i][j]=(dp[i-1][j]+dp[i][j-1]+mod)%mod;
         }
     }
     cout<<dp[n-1][m-1];
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
ll f(ll a, ll b) {
  string A, B;
  A = to_string(a);
  B = to_string(b);

  return max(A.length(), B.length());
}

int main() {
  ll n; cin >> n;
  ll minLen = 20;
  for(ll i = 1; i <= sqrt(n); ++i) {
    if(n % i == 0) {
      ll a, b;
      a = i, b = n / i;
      minLen = min(minLen, f(a, b));
    }
  }
  cout << minLen << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	string s;
	cin>>n;
	rep(j,0,n){
		cin>>s;
		string ans="";
		ans=ans+s[0];
		rep(i,0,s.size()/3){
			if(ans.find(s[3*i+3])!=string::npos) continue;
			if(s[3*i+2]=='>'){
				ans=ans+s[3*i+3];
			}else{
				ans=s[3*i+3]+ans;
			}
		}
		cout<<ans<<endl;
	}
}

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

using namespace std;
typedef long long int ll;

void disp(vector<vector<ll>>& m)
{
    for (int i=0;i<m.size();++i)
    {
        for (int j=0;j<m[0].size();++j)
        {
            cout<<m[i][j]<<" ";
        }
        cout<<endl;
    }
}

ll knap(vector<ll>& w,vector<ll>& v,ll B)
{
    ll M = 0;
    ll n = w.size();
    for (ll i:v) M+= i;
    ll inf = 0;
    for (ll i:w) inf+= i;
    ++inf;
    inf = B+1;

    vector<vector<ll>> dp(n+1);
    for (ll i=0;i<=n;++i)
    {
        vector<ll>* p = new vector<ll>(M+1,inf);
        dp[i] = *p;
    }

    for (ll idx=0;idx<=n;++idx)
    {
        dp[idx][0] = 0;
    }

    for (ll idx=1;idx<=n;++idx)
    {
        for (ll val=1;val<=M;++val)
        {

            ll dont = dp[idx-1][val];
            ll take = inf;
            if (val >= v[idx-1] && dp[idx-1][val-v[idx-1]] + w[idx-1] < inf) take = dp[idx-1][val-v[idx-1]] + w[idx-1];
            dp[idx][val] = min(dont,take);

        }
    }

    //disp(dp);
    ll ans = 0;
    for (ll i=0;i<=M;++i)
    {

        if (dp[n][i] < inf)
        {
            ans = i;
        }

    }

    return ans;
}

int main()
{
    ll n,B;
    cin>>n>>B;
    vector<ll> w(n);
    vector<ll> v(n);

    for (ll i=0;i<n;++i)
    {
        cin>>w[i];
        cin>>v[i];
    }

    cout<<knap(w,v,B)<<endl;

    return 0;
}


Measured memory_bytes: 158592
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0

for i in range(N):
    if A[i] > B[i]: ans += B[i]
    elif A[i+1] > (B[i] - A[i]):
        A[i+1] -= B[i] - A[i]
        ans += B[i]
    else:
        ans += A[i] + A[i+1]
        A[i+1] = 0
print(ans)

Measured memory_bytes: 18624
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int n;
    int m;
    int k;

    cin >> n;
    int card[n*2];
    int card_keep[n*2];
    for(int i = 0;i < n*2;i++){
      card[i] = i+1;
      card_keep[i] = i+1;
    }

    /*cout << endl;
    for(int i = 0;i < 2*n;i++){
      cout << card[i] << endl;    //card?¢????
    }
    cout << endl;*/

    cin >> m;
    int a;
    while(m--){
      cin >> k;
      a = 0;
      if(k == 0){
        for(int i = 0;i < n;i++){
          card_keep[a] = card[i];
          card_keep[a+1] = card[i+n];
          a += 2;
        }

        /*cout << endl;
        for(int i = 0;i < n*2;i++){
          cout << card_keep[i] << endl;    //??????????????£??????????¢????(keep)
        }
        cout << endl;*/

        for(int i = 0;i < 2*n;i++){
          card[i] = card_keep[i];
        }

        /*cout << endl;
        for(int i = 0;i < n*2;i++){
          cout << card[i] << endl;    //??????????????£??????????¢????
        }
        cout << endl;*/

      }
      //????????£?????????
      else {
        for(int i = 0;i < k;i++){
          card_keep[i] = card[i];
        }
        for(int i = 0;i < (2*n) - k;i++){
          card[i] = card[k+i];
        }
        for(int i = 0;i < k;i++){
          card[i+(2*n)-k] = card_keep[i];
        }

        /*cout << endl;
        for(int i = 0;i < 2*n;i++){
          cout << card[i] << endl;    //????????£??????????¢????
        }
        cout << endl;*/
      }
    }
    for(int i = 0;i < 2*n;i++){
      cout << card[i] << endl;
    }
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
//#define MAX(a,b) a>b?a:b
//#define MIN(a,b) a<b?a:b
int comp(const void*b, const void*a) {
	return *(int*)a - *(int*)b;
}
int main() {
	int n, m;
	while(~fscanf(stdin,"%d%d",&n,&m),n){
		int a[1000] = {},
			i,s,b;
		for (i = s = 0; i < n; s += a[i], i++) S(d, a[i]);
		qsort(a, n, sizeof(int), comp);
		for (i = m - 1, b = 0; i < n; i += m) b += a[i];
		P(d, s - b);
	}
	return 0;
}

Measured memory_bytes: 656
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)

ll N, M, A, B, C, D;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;


int main() {
	scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
	int cnt = 0;
	while(1) {
		if(cnt % 2) {
			A -= D;
		}
		else {
			C -= B;
		}
		if(C <= 0 || A <= 0) {
			break;
		}
		cnt++;
	}
	if(A <= 0) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3764
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1e9;

int main(){
  int n;
  while(cin >> n, n){
    vector< vector<int> > V(n, vector<int>(n));
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
        cin >> V[i][j];
    vector< vector<int> > A(n, vector<int>(n, 0));
    for(int i = 0; i < n; ++i){
      int m = INF;
      for(int j = 0; j < n; ++j){
        m = min(m, V[i][j]);
      }
      for(int j = 0; j < n; ++j){
        if(V[i][j] == m) ++A[i][j];
      }
    }
    for(int i = 0; i < n; ++i){
      int m = -1;
      for(int j = 0; j < n; ++j){
        m = max(m, V[j][i]);
      }
      for(int j = 0; j < n; ++j){
        if(V[j][i] == m) ++A[j][i];
      }
    }
    bool f = false;
    for(int i = 0; i < n; ++i){
      if(f) break;
      for(int j = 0; j < n; ++j){
        if(A[i][j] == 2){
          cout << V[i][j] << endl;
          f = true;
          break;
        }
      }
    }
    if(!f) cout << 0 << endl;
  }
}



Measured memory_bytes: 3060
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int x1 = n/500;
    int r = n%500;
    int x2 = r/5;
    System.out.println(1000*x1+5*x2);
  }
}

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

int main(){
int N, K;   cin >> N >> K;
vector<int> l(N);
for (int i = 0; i < N; i++) {
    cin >> l[i];
}
sort(l.begin(), l.end(), greater<int>());
int ans = 0;
for (int i = 0; i < K; i++) {
    ans += l[i];
}

cout << ans << endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)                                                                             
#define seg_size 524288
int main() {
	int a, b;
	cin >> a >> b;
	cout << a + (b - a) * 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>

using namespace std;

int main()
{
    u_int64_t L, R;
    cin >> L >> R;

    u_int64_t len = min(
        R - L + 1LL,
        (R - L + 1LL) % 2019LL + 2019LL);

    u_int64_t m = 2019LL;
    for (u_int64_t i = 0; i < len - 1LL; i++)
    {
        for (u_int64_t j = i + 1LL; j < len; j++)
        {
            u_int64_t l = L + i;
            u_int64_t r = L + j;
            u_int64_t prod = l * r % 2019LL;

            m = min(m, prod);
        }
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    S = input()
    N = len(S)
    s = {"A", "G", "C", "T"}
    ans = 0
    for i in range(N):
        for j in range(i, N):
            T = S[i:i+(j-i+1)]
            if all(t in s for t in T):
                ans = max(ans, len(T))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
    long long a, b; cin >> a >> b;
    if (a == 0) {
        b = ((b+1)/2%2) ^ ((b%2)?0:b);
        cout << b << endl;
        return 0;
    }

    a = ((a)/2%2) ^ (((a-1)%2)?0:a-1);
    b = ((b+1)/2%2) ^ ((b%2)?0:b);
    cout << (a ^ b) << endl;
    return 0;
}

Measured memory_bytes: 3624
n,m = map(int,input().split())
match = [2,5,5,4,5,6,3,7,6]
a = [int(i) for i in input().split()]

dp = [0]+[-1]*(n+1)

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

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

int main(){
    int N, M;
    cin >> N >> M;
    int road[60] = {0};

    for (int i=0; i<M; ++i) {
        int a, b;
        cin >> a >> b;

        road[a-1] += 1;
        road[b-1] += 1;
    }
    for (int i=0; i<N; ++i) cout << road[i] << endl;

    return 0;
}

Measured memory_bytes: 256
H,W = (int(i) for i in input().split())
li = []
for i in range(H):
    li.append(input())
gyou = [False for i in range(H)]
retsu = [False for i in range(W)]
for i in range(H):
    if '#' in list(li[i]):
        gyou[i] = True
        for j in range(W):
            if list(li[i])[j] == '#':
                retsu[j] = True
for i in range(H):
    l = []
    if gyou[i] == True:
        for j in range(W):
            if retsu[j] == True:
                l.append(list(li[i])[j])
    print(''.join(l))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

ll f(ll n){
    ll res = 1;
    for(int i=1;i<=n;i++){
        res = (res * i) % MOD;
    }
    return res;
}

int main(){
    int n,m;
    cin >> n >> m;
    ll ans = 0;
    if(n<m) swap(n,m);
    if(abs(n-m)>1){
        ans = 0;
    }
    else if(n==m){ // 2*n! * n!
        ll N = f(n);
        ans = (2LL * (N * N)%MOD)%MOD;
    }else{
        ans = (f(n) * f(n-1))%MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define N 200005
const ll INF = 1000000000000000001;
const ll MOD = 1000000007;

//vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
//ll vis[N] = {0}, par[N] = {0}, child[N] = {0},cnt = 0;


void solve(){
    string s, t; cin >> s >> t;
    ll ans = 0;
    for(ll i=0 ;i< s.size(); i++) if(s[i] != t[i]) ans ++;
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
   //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
   // }
    return 0;
}

Measured memory_bytes: 3720
n = input()
op_cnt = len(n) - 1
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt             #間を-で初期化
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"#bit探索の手法はここ

    formula = ""
    for x,y in zip(n, op + [""]):   #謎。
        formula += (x+y)
    if eval(formula) == 7:          #すごい
        print(formula + "=7")
        break                       #見つかったので爆破

Measured memory_bytes: 3064
#include<iostream>
#include <cmath>
using namespace std;
int main(){
  long double H;
  cin >> H;
  long n = 0;
  while(H > 1){
    H = floor(H/2);
    n++;
  }
  cout << long(pow(2, n+1)-1) << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100500;
vector < int > pos;
int dp[maxn], id[maxn];
int n, m;
int solve(int i){
    if(i == n) return 0;
    int &ret = dp[i];
    if(~ret) return ret;
    int ind = upper_bound(pos.begin(), pos.end(), i + m) - pos.begin();
    int p = pos[ind - 1];
    int a = n + 1, b = n + 1;
    if(p > i)
        a = 1 + solve(p);
    ind = upper_bound(pos.begin(), pos.end(), i) - pos.begin();
    if(pos[ind] > i && pos[ind] - i <= m)
        b = 1 + solve(pos[ind]);
    ret = min(a, b);
    id[ret] = min(id[ret], i);
    return ret;
}

void print(int i){
    if(i == n) return;
    cout << id[dp[i] - 1] - i << ' ';
    print(id[dp[i] - 1]);
}
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    string s;
    cin >> s;
    for(int i = 0 ; i <= n ; ++i)
        if(s[i] == '0')
            pos.push_back(i);
    for(int i = 0 ; i <= n ; ++i)
        dp[i] = -1;
    for(int i = 0 ; i <= n ; ++i)
        id[i] = n;
    int cnt = solve(0);
    if(cnt >= n + 1)
        return cout << -1 << '\n', 0;
    print(0);
    return 0;
}


Measured memory_bytes: 6600
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto x = readln.chomp.split.to!(int[]);
  if (x[0] * x[1] % 2) {
    writeln("Odd");
  } else {
    writeln("Even");
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer N = scan.nextInt();
        ArrayList<String> str = new ArrayList<String>();

        for(int i=0;i<N;i++){
            String s = strSort(scan.next());
            str.add(s);
        }

        Collections.sort(str);

        //for(int i=0;i<N;i++) System.out.println(str.get(i));

        long sum = 0;
        for(int i=0;i<N-1;i++){
            if(str.get(i).equals(str.get(i+1))){
                int counter = i;
                int num = 1;
                while(true){
                    //System.out.println("count");

                    if(counter<N-1){
                        if(str.get(counter).equals(str.get(counter+1))){
                            num++;
                            counter++;
                        }else{
                            break;
                        }
                    }else{
                        break;
                    }
                }             
                //System.out.println("num:" + num);   
                sum += calcCombination(num, 2);
                //System.out.println(sum);
                i=counter;
            }
        }

        System.out.println(sum);

    }

    static long calcCombination( int n, int m ) {
        if( n < m || m < 0 ) {
            return 0;
        }
        long c = 1;
        m = ( n - m < m ? n - m : m );
        for( int ns = n - m + 1, ms = 1; ms <= m; ns ++, ms ++ ) {
            c *= ns;
            c /= ms;
        }
        return c;
    }

    static long calcNumOfCombination(long n, long r){
        return factorial(n) / (factorial(r) * factorial(n-r));
    }
    static long factorial(long n){
        long answer = 1;
	while(n > 1){
	    answer *= n;
	    n--;
	}
        return answer;
    }

    public static String strSort(String str){
        char[] c = str.toCharArray();
        Arrays.sort(c);
        return new String(c);        
    }
}


Measured memory_bytes: 52008