akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <string>
#include <set>
#define eps 1e-9
#define llint long long

using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> State;

int h, w;
int sx, sy, gx, gy;
int x, y, dir, ans;
char c[55][55];
int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
string s;
set<State> S;
bool unreach;

bool parseProgram(int &p, bool);

bool parseMove(int &p, bool pass)
{
	if(pass){
		p++;
		return false;
	}
	
	int nx = x, ny = y;
	if(s[p] == '>') dir = (dir+3)%4;
	if(s[p] == '^') nx = x + dx[dir], ny = y + dy[dir];
	if(s[p] == '<') dir = (dir+1)%4;
	if(s[p] == 'v') nx = x - dx[dir], ny = y - dy[dir];
	if(c[nx][ny] != '#') x = nx, y = ny;
	p++;
	ans++;
	return (x == gx && y == gy);
}

bool check(string &s)
{
	char C = s[0]; bool neg = false;
	if(C == '~'){
		neg = true;
		C = s[1];
	}
	
	bool ret;
	if(C == 'E') ret = (dir == 0);
	if(C == 'N') ret = (dir == 1);
	if(C == 'W') ret = (dir == 2);
	if(C == 'S') ret = (dir == 3);
	if(C == 'C') ret = (c[x+dx[dir]][y+dy[dir]] == '#');
	if(C == 'T') ret = true;
	
	if(neg) ret = !ret;
	return ret;
}

bool parseWhile(int &p, bool pass)
{
	p++;
	string cond;
	if(s[p] == '~') cond += s[p], p++;
	cond += s[p], p++;
	
	set<State> S;
	while(1){
		if(S.count(make_pair(make_pair(x, y), dir))){
			unreach = true; return true;
		}
		S.insert(make_pair(make_pair(x, y), dir));
		/*if(ans > 10000){
			unreach = true; return true;
		}*/
		if(!check(cond) || pass) break;
		int pre_p = p;
		if(parseProgram(p, 0)) return true;
		p = pre_p;
	}
	parseProgram(p, 1);
	p++;
	return false;
}

bool parseIf(int &p, bool pass)
{
	p++;
	string cond;
	if(s[p] == '~') cond += s[p], p++;
	cond += s[p], p++;
	
	if(pass){
		parseProgram(p, 1);
		p++;
		return false;
	}
	
	if(check(cond)){
		if(parseProgram(p, 0)) return true;
	}
	else parseProgram(p, 1);
	p++;
	
	return false;
}

bool parseProgram(int &p, bool pass)
{
	while(1){
		//cout << p << " " << x << " " << y << " " << dir << endl;
		if(s[p] == '#' || s[p] == ']' || s[p] == '}') break;
		else if(s[p] == '['){
			if(parseIf(p, pass)) return true;
		}
		else if(s[p] == '{'){
			if(parseWhile(p, pass)) return true;
		}
		else{
			if(parseMove(p, pass)) return true;
		}
	}
	return false;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> h >> w;
	{
		for(int y = 1; y <= h; y++){
			for(int x = 1; x <= w; x++){
				cin >> c[x][y];
				if(c[x][y] == 's'){
					sx = x, sy = y;
					c[x][y] = '.';
				}
				if(c[x][y] == 'g'){
					gx = x, gy = y;
					c[x][y] = ',';
				}
			}
		}
	}
	cin >> s;
	s += "#";
	
	int p = 0; x = sx, y = sy, dir = 1;
	if(parseProgram(p, 0) && !unreach) cout << ans << endl;
	else cout << -1 << endl;
	
	return 0;
}


Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
int n,a,b;
int main(){
  // freopen("input.txt","r",stdin);
   	cin >> n >> a >> b;
   	cout << min(a,b) << " ";
   	if(n - a >= b)cout << 0 << endl;
   	else cout << b - n + a << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
      int n,m;
      double sum=0,count=0;
     cin>>n>>m;
     int a[n];

     for(int i=0;i<n;i++)
     {
          cin>>a[i];
          sum=sum+a[i];
     }
     double d=sum/(4*m);

     for(int i=0;i<n;i++)
     {

          if(a[i]>=d)
               count++;
     }
     if(count>=m)
          cout<<"Yes";
     else
          cout<<"No";
     return 0;
}

Measured memory_bytes: 256
import math

N, K = map(int, input().split())

prob=0
for dice_num in range(1, N+1):
    if K>dice_num:
        pwr=math.ceil(math.log2(K/dice_num))
        prob+=(1/2)**pwr/N
    else:
        prob+=1/N
print(prob)



Measured memory_bytes: 2940
#include <stdio.h>
#define N 305
int n;char s[N][N*2];
inline bool check(int x) {
	for(int i=0;i<n;++i) {
		for(int j=i+1;j<n;++j) {
			if(s[i][j+x]!=s[j][i+x]) return false;
		}
	}
	return true;
}
int main() {
	char *t;int ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;++i) {
		t=s[i];
		scanf("%s",t);
		for(int j=0;j<n;++j) t[n+j]=t[j];
	}
	for(int j=0;j<n;++j) if(check(j)) ans+=n;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long unsigned llu;
typedef pair<ll, ll> P;//change when necessary
typedef long double ld;
#define mp make_pair
#define N ll(1e5 + 5)//change it
#define M ll(1)
const ll OO = 1e18;
const ll md = 1e9 + 7;
ll X[] = { 0,0,1,-1 }, Y[] = { 1,-1,0,0 };
void fast()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
set<ll>s;
set<ll>::iterator it;
ll n, a[N], x, y, mx;
int main()
{
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]),mx = max(mx, a[i]);

	for (int i = 0; i < n;i++)
		if (max(mx / 2 - x, x - mx / 2) > max(mx / 2 - a[i], a[i] - mx / 2))
			x = a[i];

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

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
#define MOD 1000000007

int main(int argc, char const *argv[]) {
  int a,b,w;
  std::cin >> w >> a >> b;

  cout << max(0,abs(b-a)-w) << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
n, x = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
_sum = max(0, a_ls[0] - x)
last = min(x, a_ls[0])
for a in a_ls[1:]:
    if last + a > x:
        _sum += last + a - x
        last = x - last
    else:
        last = a
print(_sum)

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

int main() {
  int N, K, ans = 0;
  cin >> N >> K;
  vector<int> vec(N);
  rep(i,N) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  rep(i,K) {
    ans += vec.at(i);
  }
  cout << ans;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

const i64 MOD = 1'000'000'007;

struct mint {
  long long x;
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// Factorials over ModInts.
struct Factorials {
  // factorials and inverse factorials.
  vector<mint> fact, ifact;

  // n: max cached value.
  Factorials(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }

  // Combination (nCk)
  mint C(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }

  // Permutation (nPk)
  mint P(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[n - k];
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<i64> a(n);
  for (auto& x : a) cin >> x;
  sort(a.begin(), a.end());
  mint ans = 0;
  mint cx = 0;
  Factorials fs(n);
  REP(i, n - k + 1) {
    cx += fs.C(k - 2 + i, i);
    ans += cx * a[k - 1 + i];
    ans -= cx * a[n - k - i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 5556
from sys import exit
from itertools import accumulate,chain
n,*s=open(0).read().split()
t=[2*i.count("(")-len(i) for i in s]
if sum(t)!=0:
    print("No");exit()
#pypyではinitialだめ
st=[[min(accumulate(s_,lambda a,b: a+(1 if b=="(" else -1),initial=0)),t_] for s_,t_ in zip(s,t)]

now=0
v=list(filter(lambda x:x[1]>=0,st))
w=list(filter(lambda x:x[1]<0,st))
v.sort()
w.sort(key=lambda z:z[1]-z[0])

for c in chain(v[::-1],w[::-1]):
    if now+c[0]<0:
        print("No");exit()
    now+=c[1]
print("Yes")

Measured memory_bytes: 127300
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int64_t A, B;
	int K;
	cin >> A >> B >> K;
	set<int> s;

	rep(i, K) {
		if (A+i<=B) s.insert(A+i);
		if (B-i>=A) s.insert(B-i);
	}
	for (auto val : s) cout << val << endl;
}

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

constexpr ll INF = ll(1e+18) + 1;

int main() {
    int A, B, C;
    string ans = "NO";

    cin >> A >> B >> C;

    rep(b, B) {
        if ((A*b)%B == C) {
            ans = "YES";
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3600
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{   
	    Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w= sc.nextInt();
		long dp[] = new long[w+1];
		for(int i = 0; i < n; i++)
		{   
		    int cw = sc.nextInt();
		    long cv = sc.nextLong();
		    
		    for(int we = w-cw; we >= 0; we--)
		    {
		        dp[we+cw] = Math.max(dp[we+cw],dp[we]+cv);
		    }
		}
		long ans = 0;
		for(int i = 0; i <= w; i++)
		{
		    ans = Math.max(ans,dp[i]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22736
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {
	long l;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		l = Long.parseLong(in.readLine());

	}

	void calc() {
		long vol = l * l * l;
		double v = (double) vol / 27.0;
		System.out.println(v);
	}

	void showResult() {
	}

}


Measured memory_bytes: 21076
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define MAX 1000001

//int solve(int data[],int size);

int main()
{
    int k,ans=0;
    int i,j;
    int a=7;
	scanf("%d",&k);
	for(i=1;i<=MAX;i++)
    {
	    a=a%k;
	    if(a==0)break;
	    else a=a*10+7;
    }
	if(i>1000000)i=-1;
	printf("%d",i);
}


Measured memory_bytes: 1732
ss = list(input())

cnt = 0
i = 1
while True:
	#print(i, ss)
	if i >= len(ss):
		break
	if ss[i-1] != ss[i]:
		ss.pop(i-1)
		ss.pop(i-1)
		cnt += 2
		if i > 1:
			i -= 1
	else:
		i += 1

print(cnt)

Measured memory_bytes: 3956
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> V(N), C(N);
    int ans = 0;
    rep(i, N){
        cin >> V[i];
    }
    rep(i, N){
        cin >> C[i];
    }
    rep(i, N) ans += max(0, V[i] - C[i]);
    cout << ans;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
int main(){
	int a,b,c;
	scan(a);scan(b);scan(c);
	if((a<=b&&a>=c)||(a>=b&&a<=c)){
		prin(abs(a-b)+abs(a-c));
	}
	else if((b<=a&&b>=c)||(b<=c&&b>=a)){
		prin(abs(b-a)+abs(b-c));
	}
	else{
		prin(abs(c-a)+abs(b-c));
	}
	return 0;
}


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

#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 rep0c(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep1c(i, n) for (int i = 1; i <= (int)(n); i++)
#define repc0(n, i) for (int i = (int)(n); i >= 0; i--)

using namespace std;
typedef long long ll;

int N, K;
string S;

void solve() {
  char past = '1';
  int past_count = 0;
  vector<int> zeros, ones;
  rep(i, N) {
    char current = S[i];
    if(past != current) {
      if(past == '1') ones.push_back(past_count);
      else zeros.push_back(past_count);
      past = current;
      past_count = 0;
    }
    past_count++;
  }
  if(past == '1') ones.push_back(past_count);
  else {
    zeros.push_back(past_count);
    ones.push_back(0);
  }
  K = min((int)zeros.size(), K);
  int maxv = 0;
  int ends = ((int)zeros.size())-K+1;
  rep(i, ends) {
    int sum = ones[i+K];
    for(int j=i; j<i+K; j++) sum += ones[j] + zeros[j];
    maxv = max(maxv, sum);
  }
  cout << maxv << endl;
}

int main() {
  cin >> N >> K >> S;
  solve();
  return 0;
}


Measured memory_bytes: 1020
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 200000

int n;
long a[MAXN], b[MAXN];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%ld", &a[i]);
	return 1;
}

void init() {
}

//[0,p) & [p,n)
long diff(long *b, int n, int p) {
	return abs((b[n]-b[p]) - (b[p]-b[0]));
}

void calc(long *a, long *b, int n, int &p, long *m) {
	long s = b[n]-b[0];
	while (p<n-1 && (b[p]-b[0])*2 < s) p++;
	if (p>0 && diff(b, n, p-1) < diff(b, n, p)) p--;
	m[0] = b[p]-b[0];
	m[1] = b[n]-b[p];
}

long solve() {
	b[0] = 0;
	for (int i=0; i<n; i++)
		b[i+1] = b[i] + a[i];
	int f=1, g=1;
	long m[4];
	long r = INT_MAX;
	for (int k=2; k<=n-2; k++) {
		calc(a, b, k, f, m);
		g = max(1, g-k);
		calc(a+k, b+k, n-k, g, m+2);
		//p('k', k+1, 'f', f+1, 'g', g+1, 'm', m[0], m[1], m[2], m[3]);
		g += k;
		sort(m, m+4);
		r = min(r, m[3]-m[0]);
	}
	return r;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

//#include "All.h"

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")

using ll = long long int;

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll N, M, K;
ll A[200010], B[200010];
ll a[200010] = {}, b[200010] = {};
ll ans = 0;
ll ai = 0, bi = 0;

int main() {
    cin >> N >> M >> K;
    A[0] = 0;
    a[0] = 0;
    B[0] = 0;
    b[0] = 0;
    REP(i, 1, N + 1 + 1) {
        if (i != N + 1) {
            cin >> A[i];
            a[i] = a[i - 1] + A[i];
        }
        else a[i] = (ll)1e17;

        if (a[i] > K && a[i - 1] <= K) {
            ai = i - 1;
        }
    }
    REP(i, 1, M + 1 + 1) {
        if (i != M + 1) {
            cin >> B[i];
            b[i] = b[i - 1] + B[i];
        }
        else b[i] = (ll)1e17;

        if (b[i] > K && b[i - 1] <= K) {
            bi = i - 1;
        }
    }
    /*
    for (int i = 0; i <= N + 1; i++) {
        cout << "a:" << a[i] << endl;
    }
    for (int i = 0; i <= M + 1; i++) {
        cout << "b:" << b[i] << endl;
    }
    */
    ans = ai;
    ll bii = 0;
    int L = ai + 1;
    //if (A[1] > K && B[1] > K) {
    //    cout << 0 << endl;
    //    return 0;
    //}
    //std::cout << ai << " " << bi << endl;
    //cout << endl;
    for (int i = 0; i < L; i++) {
        //どんどん引いてく
        while (true) {
            //std::cout << ai - i << " " << bii << endl;
            //if (K < a[ai - i] + b[0]) break;
            if ((K < a[ai - i] + b[bii] || bii == bi)) {
                if (K < a[ai - i] + b[bii]) bii--;
                if (ai - i + bii > ans) {
                    ans = ai - i + bii;
                    //std::cout << a[ai - i] + b[bii] << endl;
                }
                break;
            }
            else {
                bii++;
            }
        }
    }

    std::cout << ans << endl;

}

/*
5 4 1
1000000000 1000000000 1000000000 1000000000 1000000000
1 1000000000 1000000000 1000000000

5 4 1
1 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000
*/


Measured memory_bytes: 9888
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b = a;
    sort(all(b));
    int ans = b[n - 1] - b[0], pos = 0;
    while (pos < n)
    {
        vector<int> v, w;
        int len = 0, m = b[pos];
        rep(i, n)
        {
            if (a[i] >= m)
            {
                len++;
                v.push_back(a[i]);
                if (a[i] == m)
                    pos++;
            }
            else
            {
                sort(all(v));
                rep(j, len - k + 1) w.push_back(v[j]);
                len = 0;
                v.clear();
            }
        }
        sort(all(v));
        rep(j, len - k + 1) w.push_back(v[j]);
        if (w.size() < q)
            continue;
        sort(all(w));
        ans = min(ans, w[q - 1] - w[0]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
void main()
{
    auto buf = readln.chomp.split.to!(size_t[]);
    auto stores = new Store[buf[0]];
    foreach (ref elem; stores)
        elem = readln.chomp.store;
    stores.sort();
    auto rest = buf[1];
    ulong answer;
    while (rest)
    {
        auto store = stores.front;
        auto buy = store.stock.min(rest);
        answer += buy * store.price;
        rest -= buy;
        stores.popFront;
    }
    answer.writeln;
}

struct Store
{
    ulong price;
    uint stock;
    int opCmp(Store rhs)
    {
        return cast(int)(price - rhs.price);
    }
}

auto store(string line)
{
    auto buf = line.chomp.split;
    return Store(buf[0].to!ulong, buf[1].to!uint);
}


Measured memory_bytes: 4860
/**
 *   @FileName	c.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.16 19:23:46
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n,m,x;cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    constexpr long long LLINF = 1e18 + 1;
    ll ans = LLINF;
    for (int i = 0; i < (1<<n); i++) {
        ll sum_c = 0;
        vector<ll> sum_a(m);
        for (int j = 0; j < n; j++) {
            if (i & (1<<j)) {
                sum_c += c[j];
                for (int d = 0; d < m; d++) {
                    sum_a[d] += a[j][d];
                }
            }
        }
        bool ok = true;
        for (int j = 0; j < m; j++) {
            if (sum_a[j] < x) ok = false;
        }
        if (ok) ans = min(ans,sum_c);
    }
    if (ans == LLINF) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <algorithm>
#include <set>
#include <cstring>

#define MOD (1000000007)

typedef long long lint;

using namespace std;

lint perm[100001];
lint a[100001];

int bit[100001], n;

int sum(int i)
{
	int s = 0;
	while (i > 0){
		s += bit[i];
		i -= i & -i;
	}
	return (s);
}

void add(int i, int x)
{
	while (i <= n){
		bit[i] += x;
		i += i & -i;
	}
}

int main()
{
	int m;
	perm[0] = 1;
	for (int i = 1; i <= 100000; i++){
		perm[i] = i * perm[i - 1];
		perm[i] %= MOD;
	}
	
	while (scanf("%d", &n) && n){
		for (int i = 0; i < n; i++){
			a[i] = i;
		}
		
		scanf("%d", &m);
		
		for (int i = 0; i < m; i++){
			int s, t;
			scanf("%d %d", &s, &t);
			swap(a[--t], a[--s]);
		}
		memset(bit, 0, sizeof(bit));
		lint res = 0;
		for (int i = 0; i < n; i++){
			int idx = 0;
			res = (res + (a[i] - sum(a[i] + 1)) * perm[n - i - 1]) % MOD;
			add(a[i] + 1, 1);
		}
		
		printf("%lld\n", res);
	}
	
	return (0);
}

Measured memory_bytes: 2988
N=int(input())
A=list(map(int,input().split()))

AM=max(A)+1
B=[0]*AM
#Aから要素を取り出す
for i in A:
  #要素 i ごとに、倍数に1を足して行く。この数が、A内の他の要素で割り切れる回数を示すことになる。
  
  for j in range(i,AM,i):
    B[j]+=1
x=0
for i in A:
  if B[i]==1:
    x+=1
    
print(x)

Measured memory_bytes: 32204
#include <stdio.h>
#include <iostream>
#include <string>
int main(void)
{
	char A[10];
	char B[10];
	char C[10];
	std::cin >> A >> B >> C;
	A[0] = A[0] - 32;
	B[0] = B[0] - 32;
	C[0] = C[0] - 32;
	std::cout << A[0] << B[0] << C[0];

	return 0;
}
	

		
	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String str1 = sc.next();
		String str2 = sc.next(); 
		String s = str1 + str2;
		int i = Integer.parseInt(s);
		for(int j = 1;j<1000;j++ ) {
			if(j*j==i) {
				System.out.println("Yes");
				return;
				
			}
			
		}System.out.println("No");
		
	}

}


Measured memory_bytes: 21844
import numpy as np

N = int(input())
A = [int(x) for x in input().split()]
A = np.array(A)
index = [i for i in A if i % 2 == 0]
t = 0

for i in range(len(index)):
  if (index[i] % 3 == 0) or (index[i] % 5 == 0):
    t += 1
  else:
    pass

if t == len(index):
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 14428
#include <bits/stdc++.h>
const int mod=1e9+7;
using LL=long long;
using namespace std;
namespace ndifix{

}//end of namespace ndifix

int main(){
  int n;cin>>n;
  vector<int> a(n+1),b(n);
  for(int i=0;i<n+1;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];

  LL ans=0;
  for(int i=0;i<n;i++){
    if(a[i]<=b[i]){
      ans+=a[i];
      b[i]-=a[i];
      a[i]=0;
      ans+=min(a[i+1],b[i]);
      a[i+1]-=min(a[i+1],b[i]);
      b[i]=0;
    }
    else{
      ans+=b[i];
    }
    
    //for(int i=0;i<=n;i++)cout<<a[i]<<" ";cout<<endl;
    //for(int i=0;i<n;i++)cout<<b[i]<<" ";cout<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
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; }

string s, t;

int main() {
    cin >> s >> t;
    int slen = s.length();
    bool flg = true;
    for(int i = 0; i < slen; ++i) {
        if(s.at(i) != t.at(i)) {
            flg = false;
            break;
        }
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

int LCS(string s,string t){
  int n=s.size(),m=t.size();
  vector<vector<int>>dp(n+1,vector<int>(m+1));
  for(int i=0;i<n;++i){
    for(int j=0;j<m;++j){
      if(s[i]==t[j])dp[i+1][j+1]=dp[i][j]+1;
      else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
    }
  }
  return dp[n][m];
}


void solve(){
  int t;
  cin>>t;
  while(t--){
    string s,t;
    cin>>s>>t;
    cout<<LCS(s,t)<<"\n";
  }
}

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



Measured memory_bytes: 6912
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

int main(){
    ll n;
    cin>>n;
    set<ll> divs;
    for(ll x=1;x*x<=n;x++){
        if(n%x==0){
            divs.insert(x);
            divs.insert(n/x);
        }
    }
    
    ll res=0;
    for(auto v:divs){
        ll m=v-1;
        if(m==0) continue;
        if(n%m==n/m) res+=m;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double dp[3000][3000],n;
double arr[3000];
double f(ll i,ll h)
{
if(i==n&&h>=(n+1)/2)
return 1;
if(i==n)return 0;
if(dp[i][h]!=-1)
return dp[i][h];
dp[i][h]=(1-arr[i])*f(i+1,h)+arr[i]*f(i+1,h+1);

//cout<<i<<" "<<h<<"\t";
//cout<<dp[i][h]<<"\n";
return dp[i][h];
}
int main()
{
cin>>n;
ll i,j;
for(i=0;i<n;i++)
{
cin>>arr[i];
for(j=0;j<=n;j++)
dp[i][j]=-1;
}
double a=f(0,0);
printf("%.10lf",a);

return 0;
}

Measured memory_bytes: 70784
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/28 12:07:25 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	ll	n;
	cin >> n;
	vector<ll>	V(n);
	unordered_map<ll, int>	M;
	rep(i, n)
	{
		int	x;
		cin >> x;

		V.at(i) = x;
		M[x]++;
	}
	if (M.size() == 1 && M[0])
	{
		cout << "Yes" << endl;
		return ;
	}
	if (M.size() == 2 && M[0] * 3 == n)
	{
		cout << "Yes" << endl;
		return ;
	}
	if (M.size() != 3 || n % 3)
	{
		cout << "No" << endl;
		return ;
	}
	int a;
	a = M.begin()->second;
	for (auto itr = M.begin(); itr != M.end(); itr++)
	{
		if (itr->second != a)
		{
			cout << "No" << endl;
			return;
		}
	}
	n = 0;
	for (auto itr = M.begin(); itr != M.end(); itr++)
		n ^= itr->first;
	if (n != 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}
// END

int		main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 4260
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long LL;

int main(){
  int N;
  string S1,S2;
  cin >> N;
  cin >> S1;
  cin >> S2;

  if(N==1){
	cout << 3 << endl;
	return 0;
  }

  LL sum=6;
  
  for(int i=2;i<N;i++){
	if((S1[i-1]==S2[i-1])&&(S1[i]==S2[i])){
	  sum*=2;
	}
	else if((S1[i-1]==S2[i-1])&&(S1[i]!=S2[i])){
	  sum*=2;
	  i++;
	}
	else if((S1[i-2]==S1[i-1])&&(S1[i]==S2[i])){
	}
	else if((S1[i-2]==S1[i-1])&&(S1[i]!=S2[i])){
	  sum*=3;
	  i++;
	}
  }
  
  cout << sum%1000000007 << endl;

  return 0;
}

Measured memory_bytes: 256
S=input()
ans=0
if len(S)==1:
    print(S)
else:
    for i in range(2**(len(S)-1)):
        done=0
        b=bin(i)[2:].zfill(len(S)-1)
        for j in range(len(S)-1):
            if b[j]=="1":
                ans+=int(S[done:j+1])
                done=j+1
        ans+=int(S[done:])
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
using namespace std;

int N;
int a[maxn];
int main(){
	// debug;
	ios;

	cin>>N;
	for(int i = 0;i<N;i++) cin>>a[i];
	sort(a,a+N);
	for(int i = 1;i<N;i++){
		if(a[i] == a[i-1]) {
			cout<<"NO"<<'\n';
			return 0;
		}
	}
	cout<<"YES\n";

	return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n, k;
	cin >> n >> k;
	vi a(n);
	for (auto& x : a)
	{
		cin >> x;
		x++;
	}
	
	int csum = accumulate(a.begin(), a.begin() + k, 0);
	int max_sum = csum;
	for (int i = k; i < n; i++)
	{
		csum -= a[i - k];
		csum += a[i];
		max_sum = max(max_sum, csum);
	}
	cout << max_sum / 2.0;
	return 0;
}

Measured memory_bytes: 1024
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()
 
let util = ABC(stdin)
  
let N, K = util.Scan2 int
let hs = [| for i in 1..N -> stdin.ReadLine() |> int |] |> Array.sort
[  for i in 0..N-K -> hs.[i+K-1] - hs.[i] ]
|> List.min
|> printfn "%d"
 
util.Close()

Measured memory_bytes: 21976
#include<stdio.h>
#include<iostream>
#include <cmath>

using namespace std;

int main(){
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>> k;
  cout<<a[k-1];
  
  return 0;
}

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

n, m = [int(x) for x in input().split()]
items = []
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    c = [int(x) for x in input().split()]
    c_ = sum([1 << (x - 1) for x in c])
    items.append([a, c_])

dp = [[float("inf")]*2**n for _ in range(m + 1)]
for i in range(m + 1):
    dp[i][0] = 0

for i in range(1, m + 1):
    a, c_ = items[i - 1]
    # 鍵を使わない
    for j in range(2**n):
        dp[i][j] = dp[i - 1][j]
    # 鍵を使うときと使わないときの比較
    for j in range(2**n):
        dp[i][j|c_] = min(dp[i][j|c_], dp[i - 1][j] + a)

ans = float("inf")

for i in range(1, m + 1):
    ans = min(ans, dp[i][-1])

if ans != float("inf"):
    print(ans)
else:
    print(-1)

Measured memory_bytes: 170348
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(int argc, char* argv[])
{
	string s;
	cin>>s;
	int sLen=s.length()+1;
	char *s1 = new char[sLen];
	memset(s1,'\0',sLen);
	char *pStr = (char*)s.c_str();
	int i=0;
	while (*pStr != '\0'){
		if (*pStr != 'B'){
			s1[i++] += *pStr;
		}else{
			if (i>0){
				i--;
				s1[i]='\0';
			}
		}
		pStr++;
	}
	cout<<s1<<endl;
	delete[] s1;
	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
	ans += len(set([A[i], B[i], C[i]])) - 1

print(ans)


Measured memory_bytes: 10600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
typedef long long int LL;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;

LL n;

int is_753(LL m)
{
	bool flag=true;
	map<int,int>ma;
	ma[3]=0,ma[5]=0,ma[7]=0;
	while(m>0)
	{
		int a=m%10;
		if(a!=3 && a!=5 && a!=7)
		{
			flag=false;
			break;
		}
		else ma[a]++;
		m/=10;
	}
	if(flag && ma[3]>0 && ma[5]>0 && ma[7]>0)return 1;
	else return 0;
}

LL dfs(LL m)
{
	if(m>n)return 0;
	else return is_753(m)+dfs(10*m+3)+dfs(10*m+5)+dfs(10*m+7);
}
	
int main()
{
	cin>>n;
	cout<<dfs(0)<<"\n";
	return 0;
}

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

/*
	Name:A - DDCC Finals
	Author: Xia Ruize
	Date:
*/

/*
bool is_prime(int x)
{
	if(x<2)
		return false;
	for(int i=2;i*i<=x;i++)
	{
		if(x%i==0)
		{
			return false;
		}
	}
	return true;
}
*/

int main()
{
	int a,b;
	cin>>a>>b;
	int ans=0;
	if(a==1)
		 ans+=300000;
	if(a==2)
		ans+=200000;
	if(a==3)
		ans+=100000;
	if(b==1)
		 ans+=300000;
	if(b==2)
		ans+=200000;
	if(b==3)
		ans+=100000;
	if(a==1&&b==1)
	{
		ans+=400000;
	}
	cout<<ans<<endl; 
	return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

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

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 1003;

vector<ll> fact;

void init(ll N){
  fact.resize(N+1);
  fact[0]=1;
  rep(i,N)  fact[i+1]=((i+1)*fact[i])%lmod;
}

ll ppow(ll a,ll b){
  // aのb乗を求める
  ll res = 1;
  while(b){
    if(b%2) res=(res*a)%lmod;
    a=(a*a)%lmod;
    b>>=1;
  }
  return res;
}

ll imod(ll n){
  // nのmodの逆元を求める
  ll P=lmod;
  return ppow(n,P-2);
}

ll comb_mod(ll n,ll k){
  //nまで埋めた階乗テーブルを渡す
  return (fact[n] * imod(fact[k]) % lmod) * imod(fact[n-k]) % lmod ;
  //nCk % mod を返す
}

int N,a,b,c,d;
ll dp[MAX_N][MAX_N];

int main(){
  cin >> N >> a >> b >> c >> d;
  init(N+2);
  dp[0][0] = 1LL;
  REP(i,1,b-a+2){
    rep(j,N+1){
      dp[i][j] += dp[i-1][j];
      int e = a+i-1;
      for(int f=c; f<=d && e*f<=j;f++){
        dp[i][j] += dp[i-1][j-e*f]*fact[N-j+e*f]%lmod*imod(fact[f]*fact[N-j]%lmod*ppow(fact[e],f)%lmod);
        dp[i][j] %= lmod;
      }
    }
  }
  // rep(i,4){
  //   rep(j,10) cout << dp[i][j] << " ";
  //   cout << "" << endl;
  // }
  cout << dp[b-a+1][N] << endl;
  return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>
#include <string.h>
 
int main(void)
{
  int b, t, s = 0, v = 0;
  char c1[101], c2[101];
  scanf("%d", &b);
  while(b--){
    scanf("%s%s", c1, c2);
    t = strcmp(c1, c2);
    if(!t) s++,v++;
    else if(t > 0) s += 3;
    else if(t < 0) v += 3;
  }
  printf("%d %d\n", s, v);
  return 0;
}


Measured memory_bytes: 2052
from collections import *
def gcd(a,b):
    if a%b==0:return(b)
    else:return(gcd(b,a%b))

def soinsuu(n):
    visited=defaultdict(int)
    for i in range(2,round(n**.5)+1):
        while n%i==0:
            n//=i
            visited[i]+=1
    if n>1:
        visited[n]+=1
    return(visited)

N=int(input())
A=list(map(int,input().split()))
visited=set()
flg=False
for a in A:
    for i in soinsuu(a):
        if i in visited:
            flg=True
            break
        else:
            visited.add(i)

    if flg:
        break
else:
    print("pairwise coprime")
    exit()

n=A[0]
for a in A[1:]:
    n=gcd(n,a)



if n>1:
    print("not coprime")
else:
    print("setwise coprime")


Measured memory_bytes: 187568
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<math.h>
//#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define ull unsigned long long
#define INF 1e9
#define eps 1e-6
#define PI acos(-1.0)
#define M 10010
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int, int>P;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;

char s[maxn], t[maxn];
int vis[26];
int cnt[26];
map<char,char>mp;

int main() {
	IOS;
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt","w",stdout);
	//a = 999999866000004473;
	//b = 999999822000007597;
    cin >> s >> t;
    int len = strlen(s);
    for(char i ='a'; i <= 'z' ; ++i)
        mp[i] = i;
  // for(char i ='a'; i <= 'z' ; ++i)
     // cout << mp[i];
    for(int i = 0; i < len;++i){
        if(mp[s[i]]!= t[i]){
            if(mp[s[i]] != s[i]){
            cout << "No";
            return 0;
        }
            if(vis[t[i]-'a']){
               cout <<"No";
               return 0;

            }
            mp[s[i]] = t[i];
        }
        vis[t[i]-'a']=1;
    }
     for(char i ='a'; i <= 'z' ; ++i)
        mp[i] = i;
    for(int i = 0; i < len;++i){
        if(mp[t[i]]!= s[i]){
            if(mp[t[i]] != t[i]){
            cout << "No";
            return 0;
        }
            if(cnt[s[i]-'a']){
               cout <<"No";
               return 0;

            }
            mp[t[i]] = s[i];
        }
        cnt[s[i]-'a']=1;
    }
    cout << "Yes" ;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

template <class T>
struct segtree {
    int n;
    T def = 0;
    vector<T> node, lazy;
    vector<bool> flag;
    function<T(T, T)> f = [](T a, T b) { return max(a, b); };  // node-node
    function<T(T, T)> g = [](T a, T b) { return a + b; };      // node-lazy if add a + b

    segtree(int _n) {
        n = 1;
        while (n < _n) n *= 2;
        node.resize(2 * n - 1, def);
        lazy.resize(2 * n - 1);
        flag.resize(2 * n - 1, false);
    }
    segtree(vector<T> a) {
        n = 1;
        while (n < a.size()) n *= 2;
        node.resize(2 * n - 1, def);
        lazy.resize(2 * n - 1);
        flag.resize(2 * n - 1, false);
        for (int i = 0; i < a.size(); i++) node[i + n - 1] = a[i];
        for (int i = n - 2; i >= 0; i--)
            node[i] = f(node[i * 2 + 1], node[i * 2 + 2]);
    }

    inline void eval(int k, int l, int r) {
        if (!flag[k]) return;
        node[k] = g(node[k], lazy[k]);
        if (r - l > 1) {
            lazy[k * 2 + 1] = g(lazy[k * 2 + 1], lazy[k]);
            lazy[k * 2 + 2] = g(lazy[k * 2 + 2], lazy[k]);
            flag[k * 2 + 1] = flag[k * 2 + 2] = true;
        }
        lazy[k] = 0;
        flag[k] = false;
    }
    inline void update(int a, int b, T v, int k, int l, int r) {
        eval(k, l, r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] = g(lazy[k], v);
            flag[k] = true;
            eval(k, l, r);
        } else {
            update(a, b, v, 2 * k + 1, l, (l + r) / 2);
            update(a, b, v, 2 * k + 2, (l + r) / 2, r);
            node[k] = f(node[2 * k + 1], node[2 * k + 2]);
        }
    }
    inline T get(int a, int b, int k, int l, int r) {
        if (r < 0) r = n;
        eval(k, l, r);
        if (b <= l || r <= a) return def;
        if (a <= l && r <= b) return node[k];
        T vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = get(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
    inline void update(int a, int b, T v) {
        update(a, b, v, 0, 0, n);
    }
    inline T get(int a, int b) {
        return get(a, b, 0, 0, n);
    }
    inline T get(int a) {
        return get(a, a + 1, 0, 0, n);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<pair<ll, ll>>> x(n + 2);
    rep(i, 0, m) {
        ll l, r, a;
        cin >> l >> r >> a;
        x[r].emplace_back(l, a);
    }
    segtree<ll> st(n + 2);
    rep(i, 1, n + 1) {
        ll tmp = 0;
        if (i) tmp = max(tmp, st.get(0, i));
        st.update(i, i + 1, tmp);
        for (auto p : x[i]) {
            st.update(p.first, i + 1, p.second);
        }
    }
    cout << max(0ll, st.get(0, n + 2)) << endl;
    return 0;
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
#define PI 3.14159265
using namespace std;


const int MAX_CHAR = 26; 
const int MAX_FACT = 20; 
ll fact[MAX_FACT]; 
  
// utility for calculating factorials 
void precomputeFactorials() 
{ 
    fact[0] = 1; 
    for (ll i = 1; i < MAX_FACT; i++){
        fact[i] = fact[i - 1] * i;
        //cout << i << "||" << fact[i] << endl; 
    }
}

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    return gcd(b, a%b);
}

vector <string> getWords(string s){
    string cur = "";
    vector <string> vec;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == ' '){
            vec.push_back(cur);
            cur = "";
        } else cur += s[i];
    }
    vec.push_back(cur);
    return vec;
}

int vis[123456], par[123456];

vector <vector <int> > vec;

int main(){
    int n, m;
    cin >> n >> m;
    vec.resize(n+1);

    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        vec[u].push_back(v);
         vec[v].push_back(u);
    }
 

    queue <int> q;

    q.push(1);
    vis[1] = 1;
   while(!q.empty()){
         int u = q.front();
         q.pop();
         for(auto x:vec[u]){
             if(!vis[x]){
                par[x] = u;
                vis[x] = 1;
                q.push(x);
             }
         }
   }
   for(int i = 1; i <= n; i++){
       if(!vis[i]){
           cout << "No";
           return 0;
       }
   }

   cout << "Yes" << endl;
   for(int i = 2; i <= n; i++) cout << par[i] << endl;
}
   


Measured memory_bytes: 10528