akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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

class UnionFind{
    std::vector<int> par;
    std::vector<int> rank;
    std::vector<int> membnum;

public:
    UnionFind(){}
    UnionFind(int n): par(n), rank(n), membnum(n){
        for(int i(0); i < n; ++i){
            par[i] = i;
            rank[i] = 0;
            membnum[i] = 1;
        }
    }

    void resize(int n){
        int m(par.size());
        par.resize(n);
        rank.resize(n, 0);
        membnum.resize(n, 1);
        for(int i(m); i < n; ++i) par[i] = i;
    }

    int find(int x){
        if(x == par[x]) return x;
        else return par[x] = find(par[x]);
    }

    bool unit(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;

        if(rank[x] < rank[y]){
            par[x] = y;
            membnum[y] += membnum[x];
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) ++rank[x];
            membnum[x] += membnum[y];
        }
        return true;
    }

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

    int howmany(int x){ //同じグループに属すものの個数(自分を含む)
        return membnum[find(x)];
    }
};





int main(){
    int N, K, L; std::cin >> N >> K >> L;
    UnionFind car(N), rail(N);
    {
        int p, q;
        for(int i(0); i < K; ++i){
            std::cin >> p >> q; --p; --q;
            car.unit(p, q);
        }
    }
    {
        int r, s;
        for(int i(0); i < L; ++i){
            std::cin >> r >> s; --r; --s;
            rail.unit(r, s);
        }
    }
    std::map<std::pair<int, int>, int> mp;
    for(int i(0); i < N; ++i){
        ++mp[{car.find(i), rail.find(i)}];
    }
    for(int i(0); i < N; ++i){
        if(i) std::cout << " ";
        std::cout << mp[{car.find(i), rail.find(i)}];
    }
    std::cout << "\n";
    return 0;
}


Measured memory_bytes: 16640
from itertools import combinations

n, a, q, ms, cache = int(input()), list(map(int, input().split())), input(), map(int, input().split()), {}

l = set(sum(t) for i in range(n) for t in combinations(a, i + 1))

for m in ms:
    print('yes' if m in l else 'no')

Measured memory_bytes: 7804
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int count = 0;
  int max = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
      count++;
    }
    else{
      if(count>max) max=count;
      count = 0;
    }
  }
  if(count>max) max=count;
  cout << max << "\n";
}

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

typedef long long ll;

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

int main() {
  ll a, b;
  while (cin >> a >> b) {
    if (a < b) swap(a, b);
    ll g = gcd(a, b);
    cout << g << " " << (a*b)/g << endl;
  }
}

Measured memory_bytes: 1152
H,W,N = map(int, input().split())
r,c = map(int, input().split())
S = input()
T = input()

y,x = r,c
# Taka: R, Aoki: L
for si,ti in zip(S,T):
    if si == "R":
        x += 1
    if x > W:
        print("NO")
        exit()
    if ti == "L" and x > 1:
        x -= 1

y,x = r,c
# Taka: L, Aoki: R
for si,ti in zip(S,T):
    if si == "L":
        x -= 1
    if x < 1:
        print("NO")
        exit()
    if ti == "R" and x < W:
        x += 1

y,x = r,c
# Taka: U, Aoki: D
for si,ti in zip(S,T):
    if si == "U":
        y -= 1
    if y < 1:
        print("NO")
        exit()
    if ti == "D" and y < H:
        y += 1

y,x = r,c
# Taka: U, Aoki: D
for si,ti in zip(S,T):
    if si == "D":
        y += 1
    if y > H:
        print("NO")
        exit()
    if ti == "U" and y > 1:
        y -= 1

print("YES")


Measured memory_bytes: 3888
N=int(input())
mo=[]
for _ in range(N):
    x,u=input().split()
    x=float(x)
    mo.append([x,u])
okz=0
for i in mo:
    if i[1]=="JPY":
        okz +=i[0]
    else:
        okz += i[0]*380000

print(okz)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <complex>
using namespace std;

const double EPS = 1e-10;
const double PI = 3.14159265358979;

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    vector<complex<int> > cp(n);
    for (int i = 0; i < n; ++i)
      cin >> cp[i].real() >> cp[i].imag();

    double ans = 0.0;
    vector<int> visited(n, 0);
    complex<int> p(0, 0), dv(0, 1);
    for ( ; ; ) {
      int minIndex = -1;
      double minAngle = 1e10, minDistance = 1e10;
      for (int i = 0; i < n; ++i) {
	if (visited[i])
	  continue;

	complex<int> v = cp[i] - p;
	double angle = atan2(v.real()*dv.imag()-v.imag()*dv.real(), v.real()*dv.real()+v.imag()*dv.imag());
	if (angle+EPS < minAngle) {
	  minIndex = i;
	  minAngle = angle;
	  minDistance = hypot(cp[i].real()-p.real(), cp[i].imag()-p.imag());
	} else if (abs(angle-minAngle) < EPS) {
	  double dist = hypot(cp[i].real()-p.real(), cp[i].imag()-p.imag());
	  if (dist < minDistance) {
	    minIndex = i;
	    minDistance = dist;
	  }
	}
      }

      if (minIndex == -1)
	break;

      ans += minDistance;
      dv = cp[minIndex] - p;
      p = cp[minIndex];
      visited[minIndex] = 1;
    }
    printf("%.1f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    double a,mi=1000000,ma=0;
    while(cin>>a){
        mi=min(mi,a);
        ma=max(ma,a);
    }
    cout<<ma-mi<<endl;
    return 0;
}


Measured memory_bytes: 3072
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int K = sc.nextInt();

		TreeMap<Character, Integer> map = new TreeMap<>();
		TreeMap<String, Integer> ansMap = new TreeMap<>();

		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (map.containsKey(c)) {
				int cnt = map.get(c);
				map.put(c, cnt+1);
			} else {
				map.put(c, 0);
			}
		}
		for (int i = 0; i < s.length(); i++) {

			char c = s.charAt(i);

			for (int j = 1; j <= K; j++) {
				if (i + j > s.length()) {
					break;
				}
				String can = s.substring(i, i+j);
				if (ansMap.containsKey(can)) {
					int cnt = ansMap.get(can);
					ansMap.put(can, cnt+1);
				} else {
					ansMap.put(can, 0);
				}
			}
		}
		int cnt = 0;
		String ans = "";
		for (Map.Entry<String, Integer> e : ansMap.entrySet()) {
			cnt++;
			if (cnt == K) {
				ans = e.getKey();
				break;
			}
		}
		System.out.println(ans);
	}
}


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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int H, W, D;
int A;
vector<P> grid(90100);
vector<vector<int> > v(90100);

int main() {
  // 入力
  cin >> H >> W >> D;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A;
      grid[A] = P(i + 1, j + 1);
    }
  }

  // 前処理
  for (int i = 1; i <= D; i++) {
    int sum = 0;
    v[i].push_back(sum);
    for (int j = i + D; j <= H * W; j += D) {
      sum += abs(grid[j].first - grid[j-D].first) + abs(grid[j].second - grid[j-D].second);
      v[i].push_back(sum);
    }
  }

  // 解答
  int Q;
  cin >> Q;
  int l, r;
  for (int i = 0; i < Q; i++) {
    cin >> l >> r;

    int idx = (l % D == 0 ? D : l % D);
    if (idx == D) {
      cout << v[idx][r/D-1] - v[idx][l/D-1] << endl;
    } else {
      cout << v[idx][r/D] - v[idx][l/D] << endl;
    }
  }

  // // debug
  // for (int i = 1; i <= D; i++) {
  //   for (int j = 0; j < v[i].size(); j++) {
  //     cout << v[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  return 0;
}


Measured memory_bytes: 6016
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        int[] num = new int[N];
        for(int i=0; i<N-1; i++){
            num[nextInt()-1] += 1;
        }
        for(int i=0; i<N; i++){
            println(num[i]);
        }
    }

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

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

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 64928
#include<iostream>
#include<string>
using namespace std;
int main(){
    int N;
    string S;
    cin >> N >> S;
    
    string answer = "No";
    
    int K = N / 2;

    if(N % 2 == 0 && S.substr(0, K) == S.substr(K, K)){
        answer = "Yes";
        }
    
    cout << answer << endl;
    return 0;
        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  X first
#define  Y second

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;

int a[maxN];
int b[maxN];
int main()
{
	int n;
	scanf("%d",&n);
	unordered_map<int,int> mp;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		mp[a[i]]++;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
	{
		if(mp[a[i]] > 1)
		{
			b[i] = 1;
		}
	}
	int y = a[n];
	for(int i=1;i<n;i++)
	{
		int x = a[i];
		while(x<=y)
		{
			int pos = lower_bound(a+i+1,a+n+1,x)-a;
			if(pos == n+1)
				break;
			else
			{
				if(a[pos] == x)
				{
					b[pos] += 1;
				}
			}
			x += a[i];
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++)
	{
		if(!b[i])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12904
#include<bits/stdc++.h>
using namespace std;
#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 chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int a;
  string s;
  cin>>a>>s;
  if(a<3200)s="red";
  cout<<s<<endl;
  return(0);
}


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

int main() {
	string st;
	cin >> st;
	bool ok = true;
	vector<int> alp(26);
	for (int i = 0; i < 26; i++) {
		alp[i] = 0;
	}

	for (int i = 0; i < st.size(); i++) {
		if (st.at(i) == 'a') alp.at(0)++;
		if (st.at(i) == 'b') alp.at(1)++;
		if (st.at(i) == 'c') alp.at(2)++;
		if (st.at(i) == 'd') alp.at(3)++;
		if (st.at(i) == 'e') alp.at(4)++;
		if (st.at(i) == 'f') alp.at(5)++;
		if (st.at(i) == 'g') alp.at(6)++;
		if (st.at(i) == 'h') alp.at(7)++;
		if (st.at(i) == 'i') alp.at(8)++;
		if (st.at(i) == 'j') alp.at(9)++;
		if (st.at(i) == 'k') alp.at(10)++;
		if (st.at(i) == 'l') alp.at(11)++;
		if (st.at(i) == 'm') alp.at(12)++;
		if (st.at(i) == 'n') alp.at(13)++;
		if (st.at(i) == 'o') alp.at(14)++;
		if (st.at(i) == 'p') alp.at(15)++;
		if (st.at(i) == 'q') alp.at(16)++;
		if (st.at(i) == 'r') alp.at(17)++;
		if (st.at(i) == 's') alp.at(18)++;
		if (st.at(i) == 't') alp.at(19)++;
		if (st.at(i) == 'u') alp.at(20)++;
		if (st.at(i) == 'v') alp.at(21)++;
		if (st.at(i) == 'w') alp.at(22)++;
		if (st.at(i) == 'x') alp.at(23)++;
		if (st.at(i) == 'y') alp.at(24)++;
		if (st.at(i) == 'z') alp.at(25)++;
	}
	for (int i = 0; i < 26; i++) {
		if (alp[i] % 2 != 0) {
			ok = false;
		}
	}
	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

using VI = vector <int> ;
using VVI = vector <VI> ;

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

    if ((str.size() % 2) || str.size() < 2) {
        cout << "No" << endl;
    } else {
        bool pass = true;
        for (int i = 0; i < str.size(); i += 2) {
            if (str[i] != 'h') {
                pass = false;
                break;
            }

            if (str[i+1] != 'i') {
                pass = false;
                break;
            }
        }

        cout << (pass ? "Yes" : "No") << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//Shift only

#include<bits/stdc++.h>
#define ll long long 
using namespace std;
 
int main(){
    int N,c=0,Ans=-1;
    cin >> N ;
    int arr[N];
    for(int i = 0;i<N;i++){
        cin >> arr[i];
    }
    for(;c==0;){
        for(int i=0;i<N;i++){
            if(arr[i]%2==0){
                arr[i]=arr[i]/2;
            }else{
                c++;
            }
        }
        Ans++;
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
//#define int long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
main()
{
//    freopen("elect.in", "r", stdin);
//    freopen("elect.out", "w", stdout);
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int n = (int)s.length() + 1;
    ll ans = 0;
    vector <int> lft(n), rght(n);
    for (int i = 1; i < n; i++) {
        if (s[i - 1] == '<') lft[i] = lft[i - 1] + 1;
        else lft[i] = 0;
    }
    for (int i = n - 2; i >= 0; i--) {
        if (s[i] == '>') rght[i] = rght[i + 1] + 1;
        else rght[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        ans += max(lft[i], rght[i]);
    }
    cout << ans << '\n';
}


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

typedef long long ll;
typedef long double ld;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define rev_all( x ) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;
const int mod = 1e9 + 7;
const int inf = 1e12 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  for(int& x:a)cin >> x;
  for(int i = 1; i < n; i++){
    if(a[i-1] > a[i]){
      ans += a[i-1] - a[i];
      a[i] = a[i-1];
    }
  }
  cout << ans << endl;
  return;
}
signed main(){
  fast;
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 4748
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main()
{
    int w = 0, a = 0, b = 0, difference = 0;
    cin >> w >> a >> b;
    if(a <= b + w && b <= a + w)
    {
        cout << 0;
    }

    if(b > a + w)
    {
        difference = b - a - w;
        cout << difference;
    }

    if(a > b + w)
    {
        difference = a - b - w;
        cout << difference;
    }


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>

using namespace std;

int main(int argc, char **argv) {
    std::string s;
    cin >> s;

    std::map<char, int> cnt;

    for (char c : s) {
        auto it = cnt.find(c);
        if (it == cnt.end())
            cnt[c] = 1;
        else
            ++cnt[c];
    }
    bool ok = cnt.size() == 2;
    for (auto kv : cnt) {
        ok = ok && (kv.second == 2);
    }

    cout << (ok ? "Yes": "No") << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [None] * M
B = [None] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())


X = [1] * N

for i in range(M):
    a = A[i] - 1
    b = B[i] - 1
    ha = H[a]
    hb = H[b]
    if ha == hb:
        X[a] = 0
        X[b] = 0
    elif ha > hb:
        X[b] = 0
    else:
        X[a] = 0

print(sum(X))

Measured memory_bytes: 21772
#include <stdio.h>
#include <math.h>

int main(void)
{
    int a, b;
    double x, y;
    int d;

    x = y = 0;
    d = 90;

    for (;;) {
        scanf("%d,%d", &a, &b);
        if (a == 0 && b == 0) break;

        x += cos(M_PI * d / 180) * a;
        y += sin(M_PI * d / 180) * a;
        d -= b;
    }

    printf("%d\n%d\n", (int)x, (int)y);

    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M;
	cin >> N >> M;
	
	priority_queue<int> Q;
	REP(i, N) {
		int a;
		cin >> a;
		Q.push(a);
	}
	REP(i, M) {
		int a = Q.top();
		Q.pop();
		Q.push(a / 2);
	}
	int ans = 0;
	while (!Q.empty()) {
		ans += Q.top();
		Q.pop();
	}
	cout << ans << endl;

	


	return 0;
}



Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    if(a + b <= 2*c) {
        out(a*x + b*y);
    }
    else {
        if(x == y) {
            out(2*c*x);
        }
        else if(x < y) {
            out(min(2*c*x + b*(y - x), 2*c*y));
        }
        else if(y < x) {
            out(min(2*c*y + a*(x - y), 2*c*x));
        }
    }

    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N;
    cin >> N;
    int res = 0;
    for (int n = 1; n <= N; ++n) {
        if (n % 2 == 0) continue;
        int cnt = 0;
        for (int i = 1; i <= n; ++i) if (n % i == 0) ++cnt;
        if (cnt == 8) ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

string s;
string expect = "keyence";

bool solve() {
    int begin = 0;
    int end = 1;

    while (begin < expect.size() && s[begin] == expect[begin]) {
        begin++;
    }

    while (end <= expect.size() && s[s.size() - end] == expect[expect.size() - end]) {
        end++;
    }

    return begin + end - 1 >= expect.size();
}

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

    cin >> s;

    if (solve())
        cout << "YES\n";
    else
        cout << "NO\n";

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    
    int ans = 2000000000;
    rep(ab, 2 * max(X, Y) + 1) {
        int a = max(0, X - ab / 2);
        int b = max(0, Y - ab / 2);
        ans = min(ans, A * a + B * b + C * ab);
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 1; i < n; i++)
  {
    int t; cin >> t;
    ++v[t-1];
  }
  for (auto & i : v)
   	cout << i << '\n';
}


Measured memory_bytes: 3980
// ABC046A - 

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

typedef unsigned long long int ull;
typedef long long int ll;

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

	set<int> ans;

	ans.insert(a);
	ans.insert(b);
	ans.insert(c);

	cout << ans.size() << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define getchar gc
inline char gc(){
	static char buf[1<<16],*p1=buf,*p2=buf;
	if(p1==p2){
		p2=(p1=buf)+fread(buf,1,1<<16,stdin);
		if(p2==p1) return EOF;
	}
	return *p1++;
}
#endif
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

int n,k;

signed main(){
	read(n);read(k);
	for(int i=1,l=1,r=k+1;i<=k;i++){
		if(l>=r) l=k+2,r=k<<1|1;
		printf("%d %d\n",l++,r--);
	}
}

Measured memory_bytes: 3760
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      int n = sc.nextInt();
      if(n == 0) {
        break;
      }
      int[] a = new int[n];
      for(int i=0; i<n; i++) {
        a[i] = sc.nextInt();
      }
      int max_sum = -10000000;
      for(int i=-1; i<n; i++) {
	int sum=0;
        for(int j=i+1; j<n; j++) {
          sum += a[j];
	  if(max_sum < sum) {
            max_sum = sum;
	  } 
	}
      }
      System.out.println(max_sum);
    }
  }
}

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

n = 1000 - N
if N == 2000 or N == 3000 or N == 4000 or N ==5000 or N == 6000 or N == 7000 or N == 8000 or N == 9000 or N == 10000or N == 0:
  print(0)
elif 1000 < N:
  m = n * (-1)
  if m < 10:
    print(1000-m)
  elif m < 100:
    print(1000-(int(str(m)[-2])*10) + (int(str(m)[-1])))
  else:
    print(1000-((int(str(m)[-3])*100) + (int(str(m)[-2])*10) + (int(str(m)[-1]))))
else:
  print(n)



Measured memory_bytes: 9216
H,W = map(int,input().split())
s = [input() for _ in range(H)]
def ch(ii,jj):
    if s[ii][jj] == '#':
        return 1
    else:
        return 0

news = ['' for _ in range(H)]
for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            b = 0
            if i-1>=0:
                if j-1>=0:
                    b += ch(i-1,j-1)
                b += ch(i-1,j)
                if j+1 <= W-1:
                    b += ch(i-1,j+1) 
            if j-1>=0:
                b += ch(i,j-1)
            if j+1 <= W-1:
                b += ch(i,j+1)
            if i+1<=H-1:
                if j-1>=0:
                     b += ch(i+1,j-1)
                b += ch(i+1,j)
                if j+1 <= W-1:
                    b += ch(i+1,j+1)
            news[i] = news[i] + str(b)
        else:
            news[i] = news[i] + '#'
for l in news:
    print(l)

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

int main() {
  int a[4], b[4];
  while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; ++i)
      if (a[i] == b[i])
        ++hit;

    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 4; ++j) {
        if (i == j)
          continue;
        if (a[i] == b[j])
          ++blow;
      }
    }

    cout << hit << ' ' << blow << endl;
  }
}


Measured memory_bytes: 3092
#include<stdio.h>
int main()
{
	int n,i,a=0,b=0,c=0,d=0;
	char m[5];
	scanf("%d",&n);
	for(i=0;i<=n;i++)
	{
		gets(m);
		if(m[0]=='A') a++;
		else if(m[0]=='W') b++;
		else if(m[0]=='T') c++;
		else if(m[0]=='R') d++;
	}
	printf("AC x %d\n",a);
	printf("WA x %d\n",b);
	printf("TLE x %d\n",c);
	printf("RE x %d\n",d);
	return 0;
 } 

Measured memory_bytes: 1776
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_B() {}


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int W, H, N; cin >> W >> H >> N;
    vi x(N), y(N), a(N); REP(i, N) cin >> x[i] >> y[i] >> a[i];

    vvb g(W+1, vb(H+1, true));
    REP(i,W+1) g[i][0] = false;
    REP(j,H+1) g[0][j] = false;

    REP(n,N){
        switch(a[n]){
        case 1:
            FOR(i,1,x[n]+1){
                FOR(j,1,H+1){
                    g[i][j] = false;
                }
            }
            break;
        case 2:
            FOR(i,x[n]+1,W+1){
                FOR(j,1,H+1){
                    g[i][j] = false;
                }
            }
            break;
        case 3:
            FOR(i,1,W+1){
                FOR(j,1,y[n]+1){
                    g[i][j] = false;
                }
            }
            break;
        case 4:
            FOR(i, 1, W+1) {
                FOR(j,y[n]+1,H+1){
                    g[i][j] = false;
                }
            }
            break;
        }
    }

    int ans = 0;
    FOR(i,1,W+1){
        FOR(j,1,H+1){
            if (g[i][j]) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  int K, A, B;
  cin >> K >> A >> B;
  FOR(i, A, B+1){
    if(i % K == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ins insert
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define unmap unordered_map
#define pq priority_queue
#define minEle min_element
#define maxEle max_element
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define bp __builtin_popcount
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
typedef pair <ll, ld> pld;
typedef pair <ll, pll> pllp;
typedef pair <pll, ll> ppll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
typedef map <int, int> mii;
typedef map <ll, ll> mll;
typedef string BigNum;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const ld PI = acos(-1);

//Remember limit for IT, etc..., and +1 in limit of any array
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
//If TLE let's use int instead of ll because it's as slow as your WPM :)))

/*----IMPORTANT THINGS----*/
pii dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
//right down left up rightdown leftdown rightup leftup
pii NON = {-1, -1};
/*------------------------*/

string s, t;
ll f[3005][3005];

void solveProblem() {
    s = ' ' + s; t = ' ' + t;

    FOR(i, 1, s.length()) {
        FOR(j, 1, t.length()) {
            f[i][j] = max(f[i - 1][j], f[i][j - 1]);

            if (s[i] == t[j]) {
                f[i][j] = f[i - 1][j - 1] + 1;
            }
        }
    }

    int n = s.length() - 1, m = t.length() - 1;

    string ans = "";
    while (f[n][m] != 0) {
        if (s[n] == t[m]) {
            ans += s[n];
            --n, --m;
        }

        else if (f[n][m] == f[n][m - 1]) --m;
        else --n;
    }

    reverse(all(ans));
    cout << ans << endl;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> s >> t;
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 74104
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 2000005;
#define endl '\n'
#define int ll
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
  IOS
 
  int n,k,s;
  cin>>n>>k>>s;
  int maxi = 1000000000;
  if(s!=maxi){
    for(int i = 1;i<=k;i++) cout<<s<<" ";
    for(int i = 1;i<=n-k;i++) cout<<maxi<<" ";
  }
  else{
    for(int i = 1;i<=k;i++) cout<<maxi<<" ";
    for(int i = 1;i<=n-k;i++) cout<<1<<" ";
  }

  
  

}
 

Measured memory_bytes: 1280
from sys import stdin, stdout
input = stdin.readline
print = stdout.write 
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    a[i] += a[i - 1]
for i in range(1, m + 1):
    b[i] += b[i - 1]
i, j, z = 0, m, 0
while i <= n and a[i] <= k:
    while b[j] > k - a[i]:
        j -= 1
    z = max(z, i + j)
    i += 1
print(str(z))

Measured memory_bytes: 40864
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	ll n, m, cnt = 0, x , y;
	cin >> n >> m;
	vector<int> v[n+1];
	ll h[n+1];
	for(int i=1; i<=n; i++) cin >> h[i];
	rep(i, m){
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	for(int i=1; i<=n; i++){
		bool poss = true;
		for(auto u : v[i]){
			if (h[u]>=h[i]) poss = false;
		}
		if(poss)cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

class UNKO
{
    static void Main()
    {
        int num = int.Parse(Console.ReadLine());
        string[] str1 = Console.ReadLine().Split(' ');
        string[] str2 = Console.ReadLine().Split(' ');

        double[] x = Convertdouble(str1);
        double[] y = Convertdouble(str2);

        double[] abs = new double[num];

        for (int i=0;i< num;i++)
        {
            abs[i] = Math.Abs(x[i] - y[i]);
        }

        double Man = Enumerable.Sum(abs);  //

        double[] abs2 = new double[num];

        for (int i=0;i< num;i++)
        {
            abs2[i] = Math.Pow(abs[i], 2);
        }

        double u = Math.Sqrt(abs2.Sum());  //

        double[] abs3 = new double[num];

        for (int i=0; i < num;i++)
        {
            abs3[i] = Math.Pow(abs[i], 3);
        }

        
        double u2  = Math.Pow(abs3.Sum(),0.333333333333333333333333333333333);  //

        double tyev = abs.Max();  //



        Console.Write("{0}\n{1}\n{2}\n{3}\n", Man, u, u2, tyev);

     }

    static double[] Convertdouble(string[] str)
    {

        double[] x = new double[str.GetLength(0)];
        for (int i=0;i<str.GetLength(0);i++)
        {
            x[i] = double.Parse(str[i]);
        }

        return x;
    }
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

ll n = 1ll;
ll ans = 1ll;
int main(){
  scanf("%lld",&n);
  for(ll i = 1ll;i<n+1;i++){
    ans *= i;
    ans %= 1000000007;
  }
  printf("%lld\n",ans);
}


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

void solve()
{
    int k, s;
    cin >> k >> s;
    int ans = 0;
    rep(x, k + 1) rep(y, k + 1)
    {
        int z = s - x - y;
        if (!(0 <= z && z <= k))
            continue;
        ans++;
    }
    cout << ans << endl;
}

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

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int m; cin >> m;
	vector<pii> v(n);
	REP(i, n)cin >> v[i].first >> v[i].second;
	vi x(n), y(n);
	REP(i, n) {
		tie(x[i], y[i]) = v[i];
	}
	sort(ALL(x));
	UNIQUE(x);
	sort(ALL(y));
	UNIQUE(y);
	int h = x.size(), w = y.size();
	vvi cnt(h + 1, vi(w + 1, 0));
	REP(i, n) {
		int c = lower_bound(ALL(x), v[i].first) - x.begin(), d = lower_bound(ALL(y), v[i].second) - y.begin();
		cnt[c + 1][d + 1]++;
	}
	REP(i, h)REP(j, w + 1)cnt[i + 1][j] += cnt[i][j];
	REP(i, h + 1)REP(j, w)cnt[i][j + 1] += cnt[i][j];
	auto query = [&](int i1, int j1, int i2, int j2) {
		return cnt[i2][j2] - cnt[i1][j2] - cnt[i2][j1] + cnt[i1][j1];
	};
	REP(i, m) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int i1 = lower_bound(ALL(x), x1) - x.begin(),
			j1 = lower_bound(ALL(y), y1) - y.begin(),
			i2 = upper_bound(ALL(x), x2) - x.begin(),
			j2 = upper_bound(ALL(y), y2) - y.begin();
		cout << query(i1,j1,i2,j2) << endl;
	}
}


Measured memory_bytes: 100704
from sys import stdin

str = stdin.readline().rstrip()


cnt = 0
rslt = 0




for a in str:
    flg = 0
    for b in "ATGC":
        if a == b:
            cnt = cnt + 1
            flg = 1
            break
            
    
    if rslt <= cnt:
        rslt = cnt
        
    if flg == 0:
        cnt = 0


print(rslt)
    
            



Measured memory_bytes: 2940
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	s := readBytes()

	i := 0
	j := len(s) - 1
	var ans int
	for i < j {
		if s[i] == s[j] {
			i++
			j--
			continue
		}
		if s[i] == 'x' {
			ans++
			i++
			continue
		}
		if s[j] == 'x' {
			ans++
			j--
			continue
		}
		println("-1")
		return
	}
	println(ans)
}

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


Measured memory_bytes: 896
import Control.Monad

import Data.Ord
import Data.List
import Data.Function
import Data.Maybe

import qualified Data.ByteString.Char8 as BS

import Debug.Trace

tuplify2 :: [a] -> (a, a)
tuplify2 (x:y:_) = (x, y)
tuplify2 _ = undefined

--Input functions with ByteString
readInt = fst . fromJust . BS.readInt
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

main = do
  [price,money,maxN] <- getIntList
  traceShowM (price,money,maxN)
  print $ f price money maxN

f price money maxN
  | price * maxN < money = maxN
  | otherwise = money `div` price


Measured memory_bytes: 380
n = int(input())
a, b = map(int, input().split())
P = list(map(int, input().split()))

p1 = 0
p2 = 0
p3 = 0

for p in P:
    if p <= a:
        p1 += 1
    elif p <= b:
        p2 += 1
    else:
        p3 += 1

print(min(p1, p2, p3))


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    ll ans = 1;
    rep(i,N) {
        if (i == 0) ans *= K;
        else ans *= (K - 1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256