akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#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;

struct Edge {
    ll to, id;
};

vector<vector<Edge>> G;
vl ans;

void dfs(ll v, ll color = -1, ll p = -1) {
    ll num = 1;
    rep(i, G[v].size()) {
        ll u = G[v][i].to;
        ll ei = G[v][i].id;
        if(u == p) {
            continue;
        }
        if(num == color) {
            num++;
        }
        ans[ei] = num;
        num++;
        dfs(u, ans[ei], v);
    }
}

int main() {
    ll n;
    cin >> n;

    G.resize(n);
    ans.resize(n-1);

    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].push_back((Edge){b,i});
        G[b].push_back((Edge){a,i});
    } 
    
    dfs(0);

    ll K = 0;
    rep(i, n) {
        chmax(K, (ll)G[i].size());
    }

    out(K);

    rep(i, n-1) {
        out(ans[i]);
    }

    re0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll n; cin >> n;
    vl p(n);
    rep(i,n) cin >> p[i];
    sort(all(p));
    p[n-1] /= 2;
    ll sum = 0;
    rep(i,n){
        sum += p[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdio>
using namespace std;

#define int long long
#define INF 1e18

signed main() {
    int n, k; cin >> n >> k;
    vector<int> l(n); for(int i = 0; i < n; i++) cin >> l[i];

    sort(l.begin(), l.end(), greater<int>());

    int ans = 0;
    for(int i = 0; i < k; i++) {
        ans += l[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define INF -1



void insert(int *,int);
void extract_Max(int *);
void maxHeapInsert(int *,int);
void heapIncreaseKey(int *,int ,int);
void swap(int*,int*);
int left(int);
int right(int);
void maxHeapify(int*,int);

int length;

int main(){
  char str[20];
  int i,key,S[2000001];

  
  while(1){
  scanf("%s",str);


     if(str[0]=='i'){
       scanf("%d",&key);
       insert(S,key);
       
     }
     else if(str[0]=='e'){
       
       if(str[1]=='x'){
            extract_Max(S);
       }
       else if(str[1]=='n'){
         break;
       }

     }
  }
  return 0;
 
}

void extract_Max(int *A){
  
  printf("%d\n",A[1]);
  swap(&A[1],&A[length]);
  length--;
  maxHeapify(A,1);
}

void insert(int *S,int key){
  length++;
  S[length]=INF;
  heapIncreaseKey(S,length,key);
}

void heapIncreaseKey(int *S,int i,int key){
  S[i]=key;
  
  while(i>1 &&S[i/2]<S[i]){
    swap(&S[i],&S[i/2]);
    i=i/2;
  }
  
}

void swap(int *a,int *b){
  int key;

  key=*a;
  *a=*b;
  *b=key;
}


int left(int a){
  return 2*a;
}

int right(int a){
  return 2*a+1;
}



void maxHeapify(int *A,int i){
  int l,r,largest;
  l=left(i);
  r=right(i);
  if(l<=length && A[l]>A[i]) largest = l;
  else largest=i;

  if(r<=length && A[r]>A[largest]) largest = r;

  if(largest!=i){
    swap(&A[i],&A[largest]);
    maxHeapify(A,largest);
  }
  
}



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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
#define fi first
#define se second

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

P memo[50];
int dist[50][50];
int res;
int n, m;

void Warshall_Floyd() {
	for(int k = 0; k < n; ++k) for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j) {
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	}
}

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

    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        memo[i] = P(a, b);
        dist[a][b] = dist[b][a] = 0;
    }
    rep(i, m) {
        int a = memo[i].first, b = memo[i].second;
        rep(j, n) rep(k, n) {
            dist[j][k] = (j != k) ? INF : 0;
        }
        rep(j, m) {
            int aa = memo[j].first, bb = memo[j].second;
            dist[aa][bb] = dist[bb][aa] = 0;
        }
        dist[a][b] = dist[b][a] = INF;
        Warshall_Floyd();
        if(dist[a][b] != 0) ++res;
        dist[a][b] = dist[b][a] = 0;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
typedef long long ll;
using namespace std;

int v[100005],x[100005],y[100005];

int main(void){
    int n,c1=0,c2=0,a1=0,a2=0;cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i];
        if(i%2==0)x[v[i]]++;
        else y[v[i]]++;
    }
    for(int i=1;i<100001;i++){
        c1=max(c1,x[i]);
        if(c1==x[i])a1=i;
        c2=max(c2,y[i]);
        if(c2==y[i])a2=i;
    }
    if(a1==a2){
        sort(x,x+100001);sort(y,y+100001);
        int X=x[99999],Y=y[99999];
        //cout<<X<<Y;
        cout<<n-max(c1,c2)-max(X,Y)<<endl;
    }else{
        cout<<n-c1-c2<<endl;
    }
    /*for(int i=0;i<100001;i++){
        if(x[i]==1||x[i]==2)cout<<"#"<<i;
    }*/
    //cout<<n-max(c1,c2)-max(X,Y)<<endl;
    //cout<<n-c1-c2<<endl;
    
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int N;
  int a[100000];
  int ans = 0;
  cin >> N;

  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }

  sort(a, a + N);
  for(int i = 0; i < N; ) {
    int tmp = a[i];
    int cnt = 0;
    for(int k = 0; ; k++) {
      if(a[i + k] == tmp) {
        cnt++;
      } else {
        break;
      }
    }
    if(tmp > cnt) {
      ans += cnt;
    } else if(tmp < cnt) {
      ans += (cnt - tmp);
    }
    i += cnt;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int a, b, c;
  cin >> a >> b >> c;

  ll ans = 0;

  if(a + b + 1 >= c) {
    ans = b + c;
  } else {
    ans = b * 2 + a + 1; 
  }

  cout << ans << endl;

  return 0;
}

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

auto chmax = [](auto&& l, auto r) { return l < r ? l = r, 1 : 0; };

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w, s;
  while (cin >> h >> w >> s, h) {
    vector<vector<int>> c(h + 1, vector<int>(w + 1));
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> c[i][j];
      }
    }
    for (int i = 0; i < h; ++i) {
      for (int j = w; j--; ) {
        c[i][j] += c[i][j + 1];
      }
    }
    for (int j = 0; j < w; ++j) {
      for (int i = h; i--; ) {
        c[i][j] += c[i + 1][j];
      }
    }
    s = c[0][0] - s;
    auto f = [](int x) {
      return x * (x - 1) / 2;
    };
    auto $ = [&](int li, int ri, int lj, int rj) {
      return (li + f(ri)) * f(w + 1) + (lj + f(rj));
    };
    auto sum = [&](int li, int ri, int lj, int rj) {
      return c[li][lj] - c[li][rj] - c[ri][lj] + c[ri][rj];
    };
    vector<pair<int, int>> dp(f(h + 1) * f(w + 1));
    for (int li = h; li--; ) {
      for (int ri = li + 1; ri <= h; ++ri) {
        for (int lj = w; lj--; ) {
          for (int rj = lj + 1; rj <= w; ++rj) {
            if (sum(li, ri, lj, rj) >= s) {
              dp[$(li, ri, lj, rj)] = {1, sum(li, ri, lj, rj) - s};
            }
            for (int mi = li + 1; mi < ri; ++mi) {
              auto p = dp[$(li, mi, lj, rj)], q = dp[$(mi, ri, lj, rj)];
              chmax(dp[$(li, ri, lj, rj)], make_pair(p.first + q.first, min(p.second, q.second)));
            }
            for (int mj = lj + 1; mj < rj; ++mj) {
              auto p = dp[$(li, ri, lj, mj)], q = dp[$(li, ri, mj, rj)];
              chmax(dp[$(li, ri, lj, rj)], make_pair(p.first + q.first, min(p.second, q.second)));
            }
          }
        }
      }
    }
    int x, y;
    tie(x, y) = dp[$(0, h, 0, w)];
    cout << x << ' ' << y << '\n';
  }
}



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

public class AtCoderD
{
    static void Main()
    {
        int n;
        int a;
        int b;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            a = int.Parse(words[1]);
            b = int.Parse(words[2]);
        }

        int mod = 1000000007;
        long total = Permutation(n, mod);
        long ca = Combination(n, a, mod);
        long cb = Combination(n, b, mod);
        long answer = total - ca - cb - 1;

        answer += mod * 2;
        answer = answer % mod;

        Console.WriteLine(answer);
    }

    // Permutation（mod版、30倍速チューニングあり）
    private static long Permutation(int n, int d)
    {
        long answer = 1;
        long pow30 = 1024 * 1024 * 1024 % d;
        for (int i = 0; i < n; i++)
        {
            if (n - i > 30)
            {
                answer *= pow30;
                i += 29;
            }
            else
            {
                answer *= 2;
            }
            answer = answer % d;
        }
        return answer;
    }

    // Comnibation（mod版）
    private static long Combination(int n, int k, int d)
    {
        long answer = 1;
        for (int i = n; i > n - k; i--)
        {
            answer = Mul(answer, i, d);
        }
        for (int i = 1; i <= k; i++)
        {
            answer = Div(answer, i, d);
        }
        return answer;
    }

    // 掛け算（mod版）
    private static long Mul(long a, long b, long c)
    {
        return ((a % c) * (b % c)) % c;
    }

    // 割り算（mod版）
    private static long Div(long a, long b, long c)
    {
        return Mul(a, Pow(b, c - 2, c), c);
    }

    // べき乗（mod版）
    private static long Pow(long a, long b, long c)
    {
        if (b == 0)
        {
            return 1;
        }
        else if (b == 1)
        {
            return a % c;
        }
        else if (b % 2 == 0)
        {
            long d = Pow(a, b / 2, c);
            return d * d % c;
        }
        else
        {
            return a * Pow(a, b - 1, c) % c;
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = i, num = 0;
    while (tmp) {
      num += tmp%10;
      tmp /= 10;
    }
    if (num >= a && num <= b)
      ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    string s,ss;
    cin>>s>>ss;
    s+=ss;
    int n=stoi(s);
    for(int i=1;i*i<=n;i++){
        if(i*i==n){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    
    return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int i,j;
 
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
             printf("%dx%d=%d\n",i,j,i*j);
        }
    }
    return 0;
}
 

Measured memory_bytes: 520
#include <iostream>
#include <string>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int main(void) {
    string S;
    cin >> S;
    int N = S.size();
    int64_t Q = 1;
    int64_t countA = 0;
    int64_t countAB = 0;
    int64_t countABC = 0;
    for(int i=0; i<N; ++i) {
        if(S[i] == 'A') {
            countA = (countA + Q) % MOD;
        } else if(S[i] == 'B') {
            countAB = (countAB + countA) % MOD;
        } else if(S[i] == 'C') {
            countABC = (countABC + countAB) % MOD;
        } else {
            countABC = (countABC * 3 + countAB) % MOD;
            countAB = (countAB * 3 + countA) % MOD;
            countA = (countA * 3 + Q) % MOD;
            Q = (Q * 3LL) % MOD;
        }
    }
    cout << countABC % MOD << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

int main(int argc, char *argv[]){
    int N, K;
    std::cin >> N >> K;
    std::deque<long int> V;
    long int v;
    for(int i=0; i<N; ++i){
        std::cin >> v;
        V.push_back(v);
    }

    std::vector<long int> sumValue;
    std::vector<long int> subsequent;
    int left,right;
    int lSubsequent;
    long int sumSubsequent;
    int dequeIdx;
    int nGet, nReturn;
    int R = N < K ? N : K;
    for(lSubsequent=0; lSubsequent<=R; ++lSubsequent){
        for(left=N-lSubsequent; left<=N; ++left){
            right = left+lSubsequent;
            subsequent.clear();
            for(dequeIdx=left; dequeIdx<right; ++dequeIdx){
                subsequent.emplace_back(V[dequeIdx%N]);
            }
            std::sort(subsequent.begin(),subsequent.end());
            sumSubsequent = 0;
            for(dequeIdx=0; dequeIdx<lSubsequent; ++dequeIdx){
                if(dequeIdx<K-lSubsequent && subsequent[dequeIdx]<0){
                    continue;
                }
                sumSubsequent += subsequent[dequeIdx];
            }
            sumValue.emplace_back(sumSubsequent);
        }
    }

    long int maxValue = *std::max_element(sumValue.begin(),sumValue.end());

    std::cout << maxValue << std::endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n, k := nextInt(), nextInt()
	score := 1

	for i := 0; i < n; i++ {
		if score < k {
			score *= 2
		} else {
			score += k
		}
	}

	fmt.Println(score)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B,C;
    cin>>A>>B>>C;
    cout<< C - min((A-B),C) << endl;
}


Measured memory_bytes: 256
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n, x = map(int, input().split())
m = []
for i in range(n):
    m.append(int(input()))

sum = 0
for i in range(n):
    sum += m[i]
nokori = x-sum
ms = sorted(m)
a = nokori/ms[0]
print(n+math.floor(a))


Measured memory_bytes: 3832
x, y = tuple(map(int, input().split()))
if x == y:
    print(0)
    exit()

if abs(x) == abs(y):
    print(1)
    exit()

if 0 <= x:
    if x <= y:
        print(y - x)
    else:
        if abs(x) < abs(y):
            print(abs(y) - abs(x) + 1)
        else:
            if 0 < y:
                print(abs(x - y) + 2)
            else:
                print(x - abs(y) + 1)
else:
    if y < x:
        print(abs(x - y) + 2)
    else:
        if abs(y) < abs(x):
            if 0 < y:
                print(abs(x) - y + 1)
            else:
                print(y - x)
        else:
            print(abs(abs(x) - y) + 1)


Measured memory_bytes: 3064
/*
  Fuad Ashraful Islam
  University of Asia Pacific,Bangladesh
  Date:23th April 2020
  TODO:
  https://vjudge.net/contest/338714
  http://lightoj.com/volume_showproblem.php?problem=1149
 */
#include<bits/stdc++.h>
#define dbg(x) cerr <<__LINE__<<" where "<< #x << " = " << x << endl
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pb push_back

using namespace std;
template <class T>
inline void read(T &res)
{
  res = 0; bool bo = 0; char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-');
  if (c == '-') bo = 1; else res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  if (bo) res = ~res + 1;
}
template<typename T> T Abs(T x){ return x<0?-x:x; }
template<typename T>T Max(T a,T b){return a>b?a:b;}
const int N=1e5+5;
typedef long long ll;
int len,_,n,d,k,m,l,c,cs=1;

int main()
{
  // for(read(_);_;_--)
  int a,b,c,d;
  read(a); read(b); read(c); read(d);
  int turn=0;
  while(true)
  {
    if(turn==0)
    {
      c-=b;
      if(c<=0)
      {
        cout<<"Yes\n";
        return 0;
      }
      turn^=1;
    }
    else
    {
      a-=d;
      if(a<=0)
      {
        cout<<"No\n";
        return 0;
      }
      turn^=1;
    }
    
  }

  return 0;
}

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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && a!=c){
		cout<<"Yes"<<endl;
	}
	else if(c==b && c!=a){
		cout<<"Yes"<<endl;
	}
	else if(a==c && a!=b){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, d;
	cin >> n >> d;
	int x = n/(2*d+1);
	if(n%(2*d+1)!=0)
	    x++;
	cout << x <<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include "stdio.h"

int IsInArray(int *A, int n, int key) {
	int i = 0;
	A[n] = key;
	while (A[i] != key) {
		i++;
	}
	return i != n;
}
int main() {
	int arraySize, *A, searchingKeysSize, key, sum = 0;

	scanf("%d", &arraySize);
	A = new int[arraySize];
	for (int i = 0; i < arraySize; i++) scanf("%d", &A[i]);

	scanf("%d", &searchingKeysSize);
	for (int i = 0; i < searchingKeysSize; i++) {
		scanf("%d", &key);
		if (IsInArray(A, arraySize, key)) {
			sum++;
		}
	}

	printf("%d\n", sum);

	return 0;
}


Measured memory_bytes: 3216
# coding: utf-8

input_lines = []
input_lines.append(raw_input())
N,T,S = [int(x) for x in input_lines[0].split(' ')]
data = []
for i in range(N):
	input_lines.append(raw_input())
	a,b = [int(x) for x in input_lines[i+1].split(' ')]
	data.append([a,b])
dp = [[0 for i in range(T+1)]for j in range(N+1)]
judge = 0

for i in range(N-1,-1,-1):
	for j in range(0,T+1):
		#もうこの店で遊べないorSをはじめてまたいで，かつS以降に配置不可能
		if j < data[i][1] or (j > T-S and j - data[i][1] < T-S and data[i][1] > T-S):
			dp[i][j] = dp[i+1][j]
		#Sをはじめてまたいで，かつS以降に配置可能
		elif j > T-S and j - data[i][1] < T-S and data[i][1] <= T-S:
			dp[i][j] = max(dp[i+1][j],dp[i+1][T-S-data[i][1]]+data[i][0])
		else:
			dp[i][j] = max(dp[i+1][j],dp[i+1][j-data[i][1]]+data[i][0])

print dp[0][T]

Measured memory_bytes: 226560
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

vector<int> adj[100005];
int minDis[100005];
int color[100005];
int v[100005];
int d[100005];
int c[100005];

void dfs(int node,int Dleft,int Cin){
	if(Dleft<=minDis[node])
		return ;
	minDis[node]=Dleft;
	if(color[node]==0)
		color[node]=Cin;
	for(int i=0;i<adj[node].size();i++){
		dfs(adj[node][i],Dleft-1,Cin);
	}
}

int main(){

	int N,M,Q;
	cin>>N>>M;
	for(int i=0;i<N;i++){
		minDis[i]=-1;
	}
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		--a;--b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	cin>>Q;
	for(int i=0;i<Q;i++){
		scanf("%d%d%d",v+i,d+i,c+i);
	}
	for(int i=Q-1;i>=0;i--){
		dfs(v[i]-1,d[i],c[i]);
	}
	for(int i=0;i<N;i++){
		cout<<color[i]<<endl;
	}

	return 0;
}


Measured memory_bytes: 8440
sx,sy,tx,ty=map(int,input().split())
lst=""
for i in range(tx-sx):
    lst+="R"
for i in range(ty-sy):
    lst+="U"
for i in range(tx-sx):
    lst+="L"
for i in range(ty-sy):
    lst+="D"
lst+="D"
for i in range(tx-sx +1):
    lst+="R"
for i in range(ty-sy +1):
    lst+="U"
lst+="L"
lst+="U"
for i in range(tx-sx +1):
    lst+="L"
for i in range(ty-sy +1):
    lst+="D"
lst+="R"
print(lst)


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

int main() {
	int N, M;
	int p[100000] = { 0 };
	int memo[100000] = { 0 };
	int Pe[100000] = { 0 };
	int AC = 0 , WA = 0;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		string S;
		cin >> p[i] >> S;
		if (memo[p[i]] == 0&&S[0]=='W') {
			Pe[p[i]]++;
			//cout << "WWWW" << endl;
		}
		if (S[0] == 'A') {
			memo[p[i]] = 1;
			//cout << "AAAA" << endl;
		}
	}

	for (int i = 1; i < N+1; i++) {
		if (memo[i] == 1) {
			AC++;
			WA += Pe[i];
		}
	}
	cout << AC << " " << WA;

}

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

int main() {
    long long int n, a, b;
    cin >> n >> a >> b;
    long long int diff = max(a,b) - min(a,b);
    if (diff % 2 == 0) {
        cout << diff / 2 << endl;
    } else {
        long long int x = (a - 1) + 1 + ((b - (a - 1) - 1) / 2);
        long long int y = (n - b) + 1 + ((n - (a + (n - b) + 1)) / 2);
        cout << min(x, y) << endl;
    }
    return 0;
}

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


int main() {
    int x,y;
    cin>>x>>y;
    int ans =0;
    if(x==1) ans+=300000;
    if(x==2) ans+=200000;
    if(x==3) ans+=100000;
    if(y==1) ans+=300000;
    if(y==2) ans+=200000;
    if(y==3) ans+=100000;
    if(y==1 && x==1) ans+=400000;
    cout<<ans;
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = []
SP = {}
for i in range(N):
    S, P = input().split()
    P = int(P)
    if S not in SP:
        SP[S] = [[P, i+1]]
    else:
        SP[S].append([P, i+1])
    if S not in s:
        s.append(S)
s.sort()

for s_ in s:
    tmp = SP[s_]
    tmp.sort(reverse=True)
    for x in tmp:
        print(x[1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#define ll long long int
using namespace std;
int main(){
    ll T,i,j,c=0,d,p,q,n,m,k,val,l,a,r;
    cin>>n;

   for(i=1;i<=n;i++){
        cin>>a;
    if(i%2!=0&&a%2!=0) c++;
   }


        cout<<c<<endl;




     }




Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
    int n,ansm=0,anss=0;
    for(int i=0;i<4;++i){
        cin >>n;
        anss+=n;
        if(anss>59){
            ansm+=anss/60;
            anss%=60;
            }
        }
    cout <<ansm<<"\n"<<anss<<endl;
    return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
const double EPS=1e-10;
struct point{
	double x,y;
	point(const point&a):x(a.x),y(a.y){}
	point(const double&x=0,const double&y=0):x(x),y(y){}
	point operator+(const point&p)const{return point(x+p.x,y+p.y);}
	point operator-(const point&p)const{return point(x-p.x,y-p.y);}
	point operator*(const double&k)const{return point(x*k,y*k);}
	point operator/(const double&k)const{return point(x/k,y/k);}
	double norm(){return x*x+y*y;}
	double abs(){return sqrt(norm());}
	void operator=(const point&a){
		x=a.x,y=a.y;
	}
	bool operator<(const point&p)const{
		return x!=p.x?x<p.x:y<p.y;
	}
	bool operator==(const point&p)const{
		return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
	}
	friend double dot(const point&a,const point&b){
		return a.x*b.x+a.y*b.y;
	}
	friend double cross(const point&a,const point&b){
		return a.x*b.y-a.y*b.x;
	}
};
typedef point vector;
struct segment{
	point p1,p2;
	segment(const double&a,const double&b,const double&c,const double&d){
		p1.x=a,p1.y=b,p2.x=c,p2.y=d;
	}
	segment(const point&a, const point&b):p1(a),p2(b){}
	point get_vec()const{return point(p2.x-p1.x,p2.y-p1.y);}
};
point project(const segment&s,const point&p){
	vector base=s.get_vec();
	double r=dot(p-s.p1,base)/base.norm();
	return s.p1+base*r;
}
point reflect(const segment&s,const point&p){
	return p+(project(s,p)-p)*2.0;
}
int main(){
	double a,b,c,d;
	cin>>a>>b>>c>>d;
	segment s(a,b,c,d);
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>a>>b;
		point t=project(s,point(a,b));
		cout<<setprecision(8)<<fixed<<t.x<<' '<<t.y<<endl;
	}
	return 0;
}



Measured memory_bytes: 3288
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>

//#define NDEBUG

#ifdef NDEBUG
#define DEBUG_PRINT(fmt, ...) ((void)0)
#else
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#define ASSERT_RANGE(min,x,max) assert(((x)>=(min)) && ((x)<=(max)))


#define K_MIN 1
#define K_MAX 1000000000

#define N_MIN 1
#define N_MAX 200000

int sort_int(int *a, int N) {// {{{
	int i;
	for (i = 0; i < N-1; i++) {
		int j;
		for (j = i + 1; j < N; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	return 0;
}// }}}

int main(int argc, char **argv) {
	int N;
	int M;
	char S[N_MAX+2];
	int ret[N_MAX];

	fscanf(stdin,"%d%d",&N,&M);
	ASSERT_RANGE(N_MIN,N,N_MAX);
	ASSERT_RANGE(N_MIN,M,N_MAX);
	fscanf(stdin,"%s",S);
	assert(strlen(S) == N+1);

	{
		int i = 0;
		int cur = N;
		while ((cur > 0) && (i < N)) {
			int j;
			for (j = M; j >= 1; j--) {
				if (S[cur-j] == '0') {
					ret[i] = j;
					i++;
					cur -= j;
					break;
				}
			}
			if (j <= 0) {
				fprintf(stdout,"-1");
				return 0;
			}
		}
		int j;
		for (j = i-1; j >= 0; j--) {
			fprintf(stdout,"%d ",ret[j]);
		}
		return 0;
	}
}



Measured memory_bytes: 896
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
  int n, x, y; cin >> n >> x >> y;
  
  int ans[2005];
  for (int i = 1; i < n; ++i) ans[i] = n-i;
  
  for (int i = 1; i <= n-1; ++i) for (int j = i+1; j <= n; ++j) {
    int nd = abs(i-x)+abs(j-y)+1;
    if (j-i > nd) {--ans[j-i]; ++ans[nd];}
  }
  
  for (int i = 1; i < n; ++i) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public  static void main(String[] args) {
 
		Scanner sc = new  Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		int r_sum = 0;
		int l_sum = 0;
		int lmin = 100;
 
		for(int i =0;i<N;i++) {
			W[i] = sc.nextInt();
		}
 
		for(int i=1; i < N;i++) {
			r_sum = W[0];
			l_sum = 0;
			for (int j = 1;j < i; j++) {
				r_sum += W[j];
			}
			for (int z = i;z < N; z++) {
				l_sum += W[z];
			}
			lmin = Math.min(lmin, Math.abs(r_sum - l_sum));
		}
		System.out.println(lmin);
 
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

double d,t,s;

int main()
{
    cin>>d>>t>>s;
    double m=d/s;
    if(m<=t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3704
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int R;
	static int C;
	static char[][] f;
	static boolean[][][][] visited;
	static LinkedList<State> q = new LinkedList<State>();
	static int[] dx = new int[] { 1, 0, -1, 0 };
	static int[] dy = new int[] { 0, 1, 0, -1 };

	public static void main(String[] args) throws Exception {
		R = sc.nextInt();
		C = sc.nextInt();
		f = new char[R][C];
		for (int i = 0; i < R; ++i) {
			String line = sc.next();
			f[i] = line.toCharArray();
		}
		visited = new boolean[R][C][4][16];
		q.add(new State(0, 0, 0, 0));
		boolean stop = false;
		while (!q.isEmpty()) {
			State cur = q.poll();
//			System.out.println(cur.r + "," + cur.c + "," + cur.mem + "," + cur.dir);
			char cc = f[cur.r][cur.c];
			if (cc == '<') {
				update(new State(cur.r, cur.c, cur.mem, 2));
			} else if (cc == '>') {
				update(new State(cur.r, cur.c, cur.mem, 0));
			} else if (cc == '^') {
				update(new State(cur.r, cur.c, cur.mem, 3));
			} else if (cc == 'v') {
				update(new State(cur.r, cur.c, cur.mem, 1));
			} else if (cc == '_') {
				update(new State(cur.r, cur.c, cur.mem, cur.mem == 0 ? 0 : 2));
			} else if (cc == '|') {
				update(new State(cur.r, cur.c, cur.mem, cur.mem == 0 ? 1 : 3));
			} else if (cc == '?') {
				update(new State(cur.r, cur.c, cur.mem, 0));
				update(new State(cur.r, cur.c, cur.mem, 1));
				update(new State(cur.r, cur.c, cur.mem, 2));
				update(new State(cur.r, cur.c, cur.mem, 3));
			} else if (cc == '+') {
				update(new State(cur.r, cur.c, (cur.mem + 1) % 16, cur.dir));
			} else if (cc == '-') {
				update(new State(cur.r, cur.c, (cur.mem + 15) % 16, cur.dir));
			} else if (cc == '@') {
				stop = true;
				break;
			} else if ('0' <= cc && cc <= '9') {
				update(new State(cur.r, cur.c, cc - '0', cur.dir));
			} else if (cc == '.') {
				update(new State(cur.r, cur.c, cur.mem, cur.dir));
			}
		}
		System.out.println(stop ? "YES" : "NO");

	}

	static void update(State next) {
		if (visited[next.r][next.c][next.dir][next.mem]) {
			return;
		}
		visited[next.r][next.c][next.dir][next.mem] = true;
		next.r = (next.r + dy[next.dir] + R) % R;
		next.c = (next.c + dx[next.dir] + C) % C;
		q.add(next);
	}

	static class State {
		int r;
		int c;
		int mem;
		int dir;

		State(int r, int c, int mem, int dir) {
			this.r = r;
			this.c = c;
			this.mem = mem;
			this.dir = dir;
		}
	}

}

Measured memory_bytes: 13000
N,M=map(int,input().split())
a=[0 for i in range(M)]
b=[0 for i in range(M)]
for i in range(M):
    a[i],b[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
par=[0 for i in range(N)]
rnk=[0 for i in range(N)]
def init(n):
    for i in range(N):
        par[i]=i
        rnk[i]=0
def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
def unite(x,y):
    x=find(x)
    y=find(y)
    if x==y:
        return
    if (rnk[x]<rnk[y]):
        par[x]=y
    else:
        par[y]=x
        if(rnk[x]==rnk[y]):
            rnk[x]+=1
def same(x,y):
    return find(x)==find(y)
ans=0
for i in range(M):
    init(N)
    for j in range(M):
        if i==j:
            continue
        unite(a[j],b[j])
    flag=0
    for j in range(N):
        for k in range(N):
            if find(j)!=find(k):
                flag=1
                break
        if flag==1:
            break
    if flag==1:
        ans+=1
print(ans)



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

void prt(int t) {
    printf("%02d:%02d:%02d", t / 3600, t / 60 % 60, t % 60);
}

int main() {
    while (1) {
        int n;
        cin >> n;
        if (!n) return 0;

        vector<vector<int>> times(n);

        for (int i = 0; i < n; ++i) {
            int a[3];
            cin >> a[0] >> a[1] >> a[2];
            for (int j = 0; j < 6; ++j) {
                int hi = j / 2, mi = 2 - j % 3;
                int si = 3 - hi - mi;

                for (int k = 0; k < 60; ++k) {
                    int h = (a[hi] + k) % 60, m = (a[mi] + k) % 60, s = (a[si] + k) % 60;
                    if (h % 5 == m / 12)
                        times[i].push_back((h / 5 * 60 + m) * 60 + s);
                }
            }
            sort(times[i].begin(), times[i].end());
        }
        int mi = 4000;
        int mil, mir;
        for (int i = 0; i < n; ++i) {
            for (int l : times[i]) {
                int r = l;
                for (int j = 0; j < n; ++j) {
                    if (i == j) continue;

                    for (int p : times[j]) {
                        if (l <= p) {
                            r = max(r, p);
                            goto A;
                        }
                    }
                    goto B;

                    A:
                    continue;
                }
                if (mi > r - l) {
                    mi = r - l;
                    mil = l;
                    mir = r;
                }
                else if (mi == r - l && l < mil) {
                    mil = l;
                    mir = r;
                }

                B:
                continue;
            }
        }
        prt(mil);
        printf(" ");
        prt(mir);
        puts("");
    }
}

Measured memory_bytes: 3176
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int i, j, n, s, q, t, cnt = 0;
    int *s_array;

    scanf("%d", &n);
    s_array = malloc(sizeof(int) * n);
    for(i = 0; i < n; i++){
        scanf("%d", &s);
        s_array[i] = s;
    }
    scanf("%d", &q);
    for(i = 0; i < q; i++) {
        scanf("%d", &t);
        for(j = 0; j < n; j++) {
            if(t == s_array[j]) {
                cnt++;
                break;
            }
        }
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 636
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<iomanip>
#include<cmath>
#include<numeric>
#include<vector>
#include<algorithm>
#include<string>
#include<deque>
#include<stack>
#include<map>
#include<random>
#include<queue>
#include<iterator>
#include<bitset>
#include<assert.h>
#include<unordered_set>
#include<set>

using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
const ll integer = pow(2, 32) - 1; // 4294967295
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void AIA() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isprime(ll n) {
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0)return 0;
	}
	return (n != 1);
}
ll gcd(ll x, ll y)
{
	return (y == 0 ? x : gcd(y, x % y));
}
ll lcm(ll x, ll y) {
	return (x * y) / gcd(x, y);
}

/*
 _____________              __                ___        ___       ___________________________     ____        ____
|             |            /\ \              |   |      |   |     |                           |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |      _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |     |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |     |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |     |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |     |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |     |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |     |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |     |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |     |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |     |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |_____|     |____|     |____|          |__|

										  <<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
										<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
										 <<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>

*/
int main() {
	//freopen("Input.txt.txt", "r", stdin);
	//freopen("Output.txt.txt", "w", stdout);
	AIA();
	ll d, t, s;
	cin >> d >> t >> s;
	if (s * t >= d) {
		cout << "Yes";
	}
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3608
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var secound = Console.ReadLine().Split((' ')).Select(int.Parse).ToArray();

            int counter = 0;
            for (int i = 0; i < N; i++)
            {
                if (i + 1 != secound[i])
                {
                    counter++;
                }
            }

            if (counter > 2)
            {
                Console.WriteLine("NO");
            }
            else
            {
                Console.WriteLine("YES");
            }
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC130.D();
        //    temp.Run();
        //}

    }
}

Measured memory_bytes: 13396
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define MAX_T 202
#define MAX_N 100
 
int N;
int a[1000000];
 
int main() {
#ifdef DEBUG
 
#endif
	scanf("%d", &N);
	int i;
	for (i = 0; i < N; i++)scanf("%d", &a[i]);
 
	int max = 0;
	int tmp;
	int flag = 0;
	int idx;
	for (i = 0; i < N; i++) {
		tmp = abs(a[i]);
		if (max < tmp) {
			max = tmp;
			idx = i;
			if(a[i]>0) {
				flag = 1;
			}else{
				flag = -1;
			}
		}
	}
	int cnt=0;
	int ans[100][2];
	int ansIdx = 0;
	if (flag == 1) {
		for (i = 0; i < N; i++) {
			if (a[i] < 0) {
				a[i] += a[idx];
				ans[ansIdx][0] = idx + 1;
				ans[ansIdx++][1] = i + 1;
				cnt++;
			}
		}
		for (i = 0; i < N-1; i++) {
			if (a[i] > a[i + 1]) {
				a[i + 1] += a[i];
				ans[ansIdx][0] = i + 1;
				ans[ansIdx++][1] = i + 2;
				cnt++;
			}
		}
	}
	else{
		for (i = 0; i < N; i++) {
			if (a[i] > 0) {
				a[i] += a[idx];
				ans[ansIdx][0] = idx + 1;
				ans[ansIdx++][1] = i + 1;
				cnt++;
			}
		}
		for (i = N-1; i > 0; i--) {
			if (a[i] < a[i - 1]) {
				a[i - 1] += a[i];
				ans[ansIdx][0] = i+1;
				ans[ansIdx++][1] = i;
				cnt++;
			}
		}
	}
 
	printf("%d\n", cnt);
	for (i = 0; i < cnt; i++) {
		printf("%d %d\n", ans[i][0], ans[i][1]);
	}
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int numOfStay = sc.nextInt();
        int maxDays = sc.nextInt();
        int cost1 = sc.nextInt();
        int cost2 = sc.nextInt();
        
        if (numOfStay > maxDays) {
            System.out.println(maxDays * cost1 + (numOfStay - maxDays) * cost2);
        } else {
            System.out.println(numOfStay * cost1);
        }
    }
}

Measured memory_bytes: 22868
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String ans = "No";
        int n = sc.nextInt();
        int m = n, l = 0;
        while(m > 0){
            l += m - m / 10 * 10;
            m /= 10;
        }
        if(n % l == 0) ans = "Yes";
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
using namespace std;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> vp;
typedef vector<tuple<ll, ll, ll>> vt;
//vector<vector<ll>> vv(n, vector<ll>(n));

int main()
{
	ll n, ans = -1, minn = INF, maxx = -1;
	cin >> n;
	vi v;
	map<ll, ll> mp;
	set<ll> st;
	REP(i, n)
	{
		ll t;
		cin >> t;
		//cin >> v[i];
		v.push_back(t);
		mp[v[i]]++;
		st.insert(v[i]);
	}
	for(auto i:st)
	{
		ll tmp = mp[i];
		tmp += mp[i - 1];
		tmp += mp[i + 1];
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 9972
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
ll retpow5(ll x) { return x * x * x * x * x; }
int main() {
  ll X;
  cin >> X;
  for (int i = -200; i <= 200; i++) {
    for (int j = -200; j <= 200; j++) {
      if (retpow5(i) - retpow5(j) == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> data(n);
    for(int i=0; i<n; i++){
        cin >> data[i];
    }

    int swapCount=0;
    for(int i=0; i<n; i++){
        for(int j=n-1; i+1<=j; j--){
            if(data[j]<data[j-1]){
                swapCount += 1;
                int tmp = data[j-1];
                data[j-1] = data[j];
                data[j] = tmp;
            }
        }
    }

    for(int i=0; i<n; i++){
        if(i==n-1){
            cout << data[i] << endl;
            break;
        }
        cout << data[i] << " ";
    }

    cout << swapCount << endl;

    return 0;
}



Measured memory_bytes: 3056
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')


def fun(x,k):
    ans = -inf
    x += x
    n = len(x)
    for i in range(1,k+1):
        s = 0
        for j in range(i):
            s += x[j]
        l = 0
        ans = max(ans,s)
        for j in range(i,n):
            s += x[j]
            s -= x[l]
            l += 1
            ans = max(ans,s)
    return ans 



def solve():
    
    # for _ in range(ii()):

        


    n,k = mi()
    p = li()
    c = li()

    vis = [0]*(n+1)
    a = []
    for i in range(n):
        if vis[i]:
            continue
        x = []
        j = i
        while(vis[j]==0):
            vis[j] = 1
            x.append(c[p[j]-1])
            j = p[j]-1
        a.append(x)
    

    ans = -inf

    for i in a:
        s = sum(i)
        n = len(i)
        k1 = k
        if(k >= n):
            k1 = n 
        s1 = fun(i,k1)
        ans = max(ans,s1)
        if(k > n and s>0):
            s2 = (k//n)*s
            s2 += fun(i,k%n)
            ans = max(ans,s2)
            ans = max(ans,s1+(k//n-1)*s)
        ans = max(ans,s1)

    print(ans)
















        
if __name__ =="__main__":

    if path.exists('input.txt'):
        sys.stdin=open('input.txt', 'r')
        sys.stdout=open('output.txt','w')
    else:
        input=sys.stdin.readline
    solve()


Measured memory_bytes: 70472
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cctype>
#include <stdio.h>
using namespace std;

int main(){
    string S;cin>>S;
    S[5]=' ';S[13]= ' ';
    cout << S << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <stack>
 
using namespace std;
 
char expr[10000];
 
int main() {
    stack<long> S;
    cin.getline(expr, 10000);
    char* s = expr;
    for (;;) {
        if (*s == '\0') { break; }
        if ('0' <= *s && *s <= '9') {
            S.push(strtol(s, &s, 10));
            if (*s == ' ') { ++s; }
        } else {
            long b = S.top(); S.pop();
            long a = S.top(); S.pop();
            long r = 0;
            switch (*s) {
                case '+':
                    r = a + b;
                    break;
                case '-':
                    r = a - b;
                    break;
                case '*':
                    r = a * b;
                    break;
            }
            ++s;
            if (*s == ' ') { ++s; }
            S.push(r);
        }
    }
    cout << S.top() << endl;
    return 0;
}

Measured memory_bytes: 1180
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{   int n,i,j,l=0;
   scanf("%d",&n);
   char a[n];
	scanf("%s",a);
	for(i=0;i<n-1;i++)
	{
	if(a[i]==a[i+1])
	 a[i]='0';}
	 for(i=0;i<n;i++)
	 if(a[i]!='0')
	 l++;
	printf("%d\n",l);
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

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

	vector<int> m(n);
	for (auto& v : m) {
		cin >> v;
	}

	sort(begin(m), end(m));

	int ans = 0;
	for (auto v : m) {
		if (x - v < 0) {
			cout << ans << endl;
			return 0;
		}
		x -= v;
		ans++;
	}

	cout << ans + x / m[0] << endl;
	
	return 0;
}


Measured memory_bytes: 256