akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>

using namespace std;

typedef pair<int, int> P;
#define FOR(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define _1 first
#define _2 second
#define pb push_back
#define mod 1000000007
#define INF 1050000000

const int maxn = 1e5 + 10;


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

	int n; cin >> n;
	int count0=0,count4=0;
	rep(i, n)
	{
		ll a;
		cin >> a;
		if (a % 2 == 1)count0++;
		else if (a % 4 == 0)count4++;
	}
	
	if (n % 2 == 1 && count0 + count4 == n) {
		if (count4 >= count0 - 1) Yes;
		else No;
	}
	else {
		if (count4 >= count0)Yes;
		else No;
	}
	return 0;
}

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

int main(){
    int N, X[101]; cin >> N;
    for(int i=0; i<N; i++) cin >> X[i];
    int minhp=100000001, hp=0;
    for(int i=0; i<100; i++){
        for(int j=0; j<N; j++){
            hp += (X[j]-i)*(X[j]-i);
        }
        // cout << hp << endl;
        if(minhp>hp) minhp = hp;
        hp = 0;
    }
    cout << minhp << endl;
}

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

void p (int x, int y) {
	printf("%d %d\n", x, y);
	
}

int main (void) {
	int n;
	scanf("%d", &n);
	if (n == 3) {
		puts("Yes");
		p(1, 2);
		p(2, 3);
		p(3, 4);
		p(4, 5);
		p(5, 6);
	} else if (n <= 2) {
		puts("No");
	} else if (n & 1) {
		puts("Yes");
		p(1, 2);
		p(2, 3);
		p(3, n + 1);
		p(n + 1, n + 2);
		p(n + 2, n + 3);
		for (int i = 4; i <= n; i += 2) {
			p(i, i + 1);
			p(i + 1, 1);
			p(1, i + n);
			p(i + n, i + n + 1);
		}
	} else {
		int m = (n) & (-n);
		if (m == n) {
			puts("No");
			return 0;
		} 
		puts("Yes");
		p(n + n, m + n);
		p(n, (n - m) ^ 1);
		p(1, 2);
		p(2, 3);
		p(3, n + 1);
		p(n + 1, n + 2);
		p(n + 2, n + 3);
		for (int i = 4; i < n; i += 2) {
			p(i, i + 1);
			p(i + 1, 1);
			p(1, i + n);
			p(i + n, i + n + 1);
		}
	}
}

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

using namespace std;

struct Card {
  int row;
  int col;
  int value;
};

int main() {
  int N, H, W;
  cin >> N >> H >> W;
  vector<int> parent(W + H + 1, -1);
  vector<int> size(W + H + 1, 1);
  vector<bool> saturated(W + H + 1);
  vector<Card> cards;
  for (int i = 1; i <= N; ++i) {
    cards.emplace_back();
    auto&& c = cards.back();
    cin >> c.row >> c.col >> c.value;
    c.col += H;
  }
  auto cmp = [](auto&& lhs, auto&& rhs) { return lhs.value > rhs.value; };
  sort(cards.begin(), cards.end(), cmp);
  int64_t result = 0;
  for (auto&& card : cards) {
    int root1 = card.row;
    for (; parent[root1] != -1; root1 = parent[root1])
      ;
    int root2 = card.col;
    for (; parent[root2] != -1; root2 = parent[root2])
      ;
    if (root1 == root2) {
      if (saturated[root1]) {
        continue;
      }
      saturated[root1] = true;
    } else {
      if (saturated[root1] && saturated[root2]) {
        continue;
      }
      if (size[root1] < size[root2]) {
        swap(root2, root1);
      }
      size[root1] += size[root2];
      parent[root2] = root1;
      saturated[root1] = saturated[root1] || saturated[root2];
    }
    result += card.value;
  }
  cout << result << endl;
}

Measured memory_bytes: 3448
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    double sum=0.0;
    for(int i=1;i<=n;i++)
        sum+=i/2.0*(n/i)*(1+n/i);
    int val=sum;
    cout<<val;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Tue Mar 31 19:45:36 JST 2020
 **/

signed main() {
    std::string s;
    std::cin >> s;
    for (char c = 'a'; c <= 'z'; c++) {
        if (std::find(s.begin(), s.end(), c) == s.end()) {
            std::cout << c << std::endl;
            return 0;
        }
    }
    std::cout << "None" << std::endl;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    int n,r;
    cin>>n>>r;
    if(n>=10) cout<<r<<endl;
    else{
        cout<<r+100*(10-n)<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c;
    char d,e;
  	string s;
  	cin>>a>>b;
  if(a%2==0||b%2==0)
    cout<<"No"<<endl;
  else 
    cout<<"Yes"<<endl;
 
 /* else if(a==23)
    cout<<"Christmas Eve Eve"<<endl;
  else
    cout<<"Christmas Eve Eve Eve"<<endl;
  */
  cout<<s<<endl;
  return 0;
}


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

int main(){
    ll x;
    cin>>x;
    ll yen=100;
    int ans=0;
    while(true){
        yen+=yen*0.01;
        ans++;
        if(yen>=x)break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3676
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define Rep(i,n) REP(i,0,n)
typedef long long ll;

int n,l;
string s[102],ans;

int main(){
    cin>>n>>l;
    Rep(i,n){
        cin>>s[i];
    }
    sort(s,s+n);
    Rep(i,n){
        ans+=s[i];
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int x,y;
	scanf("%d %d",&x,&y);
	if(y%2==1){
		printf("No");
	}else if(2*x<=y&&y<=4*x){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define OUT(s) cout << s << "\n";
#define length(a) sizeof(a) / sizeof(a[0]);
using namespace std;

// https://atcoder.jp/contests/abc172


string S, T;

void Main()
{
    const char* s = S.c_str();
    const char* t = T.c_str();
    int len = strlen(s);
    int ans = 0;
    REP(i, len) {
        if (s[i] != t[i]) {
            ans++;
        }
    }
    OUT(ans);

}

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

Measured memory_bytes: 3772
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

struct s_t{
  ll a,b;
};
bool asc(s_t left,s_t right) {
  return left.a == right.a ? left.b > right.b : left.a < right.a;
}

int main(){
  ll n;
  cin>>n;
  vector<ll>v(n,0);
  vector<s_t>v2;
  s_t zz;
  for(ll i=0;i<n;i++){
    cin>>v[i];
    zz={v[i],i};
    v2.push_back(zz);
  }
  sort(v2.begin(),v2.end(),asc);
  multiset<ll>st;
  st.insert(v2[0].b);
  for(ll i=1;i<n;i++){
    auto itr=st.lower_bound(v2[i].b);
    if(itr!=st.begin()){
      itr--;
      st.erase(itr);
    }
    st.insert(v2[i].b);
    // for(auto j=st.begin();j!=st.end();j++){
    //   cout<<*j<<" ";
    // }
    // cout<<endl;
  }
  ll ans=st.size();
  cout<<ans<<endl;
}


Measured memory_bytes: 7280
#include <stdio.h>
#include <math.h>
 
using namespace std;
 
int main(){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}


Measured memory_bytes: 2756
import java.util.*;



public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int h = scanner.nextInt();
    int w = scanner.nextInt();
    int k = scanner.nextInt();
    scanner.nextLine();
    int[][] c = new int[h][w];
    for(int i=0; i<h; i++){
      String str = scanner.nextLine();
      for(int j=0; j<w; j++){
        if(str.charAt(j)=='#'){
          c[i][j] = 1;
        }
      }
    }
  

    int ans = 0;
    for (int i=0; i<Math.pow(2,h); i++){
      for (int j=0; j<Math.pow(2,w); j++){
        String i_bin = String.format("%"+h+"s",Integer.toBinaryString(i)).replace(" ", "0");
        String j_bin = String.format("%"+w+"s",Integer.toBinaryString(j)).replace(" ", "0");
        // System.out.println(i_bin + ","+j_bin);
        int[][] tmp = new int[c.length][c[0].length];
        for (int l=0; l < c.length; l++) {
          tmp[l] = new int[c[l].length];
          System.arraycopy(c[l], 0, tmp[l], 0, c[l].length);
      }
        // System.out.println(Arrays.deepToString(tmp));

        for(int l=0; l<i_bin.length(); l++){
          if(i_bin.charAt(l) == '1'){
            for(int m=0; m<w; m++){
              tmp[l][m] = 0;
            }
          }
        }
        for(int l=0; l<j_bin.length(); l++){
          if(j_bin.charAt(l) == '1'){
            for(int m=0; m<h; m++){
              tmp[m][l] = 0;
            }
          }
        }
        // System.out.println(Arrays.deepToString(tmp));
        int sum = 0;
        for(int l=0; l<h;l++){
          sum += Arrays.stream(tmp[l]).sum();
        }
        if(sum == k){
          ans ++;
        }

      }

    }


    System.out.println(ans);
    
    scanner.close();
    return;
  }
  
}


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

using namespace std;

const int N = 5e5+5;

const int mod = 1e9+7;

int ar[N];

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> ar[i];
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            for(int k = j + 1; k <= n; k++){
                if(ar[i] == ar[j] || ar[j] == ar[k] || ar[i] == ar[k])
                    continue;
                int tmp[3];
                tmp[0] = ar[i];
                tmp[1] = ar[j];
                tmp[2] = ar[k];
                sort(tmp , tmp + 3);
                if(tmp[2] < tmp[1] + tmp[0])
                    cnt++;
            }
        }
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 3636
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
if (N+1)/2>=K
    puts "YES"
else
    puts "NO"
end

Measured memory_bytes: 1788
a = int(input())
result = 0
for i in range(0, a):
    tmp = 0
    if (i+1) % 2 != 0:
        for j in range(0, i):
            if (i + 1) % (j + 1) == 0:
                tmp += 1
        if tmp == 7:
            result += 1

print(result)

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


int main() {
    long long n;
    cin >> n;
    long long div = INT64_MAX / 2;
    long long div2 = INT64_MAX / 2;
    for(long long i = 2;i < sqrt(n) + 1;i++){
        if(n % i == 0){
            long long t1;
            long long t2;
            t1 = n / i;
            t2 = i;
            if(t1 + t2 < div + div2){
                div = t1;
                div2 = t2;
            }
        }
    }
    if(div != INT64_MAX / 2){
        cout << div + div2 - 2 << endl;
    }else{
        cout << n - 1 << endl;
    }
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef pair<int, int> P;

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

vector<bool> D(10, false);
int main() {
  int n, k;
  cin >> n >> k;

  rep(i, k) {
    int d;
    cin >> d;
    D[d] = true;
  }

  for (int i = n; i <= 10 * n; i++) {
    string num = to_string(i);
    bool isOK = true;
    rep(j, num.size()) {
      int nc = int(num[j]) - 48;
      if (D[nc]) {
        isOK = false;
        break;
      }
    }

    if (isOK) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int max(int a,int b){return a > b ? a : b;}

int main()
{
    long long abc[3],i,j,tmp,ans;
    for (i = 0; i < 3; i++)
    {
        scanf("%lld",&abc[i]);
    }
    
    for (i=0; i<3; ++i) {
        for (j=i+1; j<3; ++j) {
            if (abc[i] > abc[j]) {
                tmp =  abc[i];
                abc[i] = abc[j];
                abc[j] = tmp;
            }
        }
    }

    if(abc[0] % 2 == 0 || abc[1] % 2 == 0 || abc[2] % 2 == 0)
    {
        printf("0");
    }
    else
    {
        printf("%lld",abc[0] * abc[1]);
    }
    
}   

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  string s;
  cin >> s;
  rep(i,3) {
    if(s.at(i) == '1')
      s.at(i) = '9';
    else
      s.at(i) = '1';
  }
  cout << s;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

d = Counter(D)
t = Counter(T)

f = True
for df in t.keys():
    f &= (d[df] >= t[df])

print(["NO", "YES"][f])


Measured memory_bytes: 57112
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FORE(x,c) for(auto &x:c)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is>>*i; return is; }
//------------------------------------------------------------------------------

signed main() {
    int n,x;
    cin>>n>>x;
    if(x==1 || x==2*n-1) {
        cout<<"No"<<endl;
        return 0;
    }
    if(n==2) {
        cout<<"Yes"<<endl;
        cout<<"1 2 3"<<endl;
        return 0;
    }
    int t=1;
    vi ans(2*n-1);
    REP(i,(2*n-1)/2-1) {
        while(x-1<=t && t<=x+1) t++;
        ans[i]=t;
        t++;
    }
    ans[(2*n-1)/2-1]=x-1;
    ans[(2*n-1)/2]=x;
    ans[(2*n-1)/2+1]=x+1;
    FOR(i,(2*n-1)/2+2,2*n-1) {
        while(x-1<=t && t<=x+1) t++;
        ans[i]=t;
        t++;
    }
    cout<<"Yes"<<endl;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2304
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

int main() {
    int N;
    cin >> N;
    vector<char> v(N);
    vector<vector<int>> dp(N + 1, vector<int>(N + 1, 0)); // dp[i][j] 表示以i开始和以j开始的子串的最长公共前缀
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    int res = 0;
    for (int i = N - 1; i >= 0; i--) {
        for (int j = N - 1; j >= i; j--) {
            if (v[i] == v[j]) {
                dp[i][j] = dp[i + 1][j + 1] + 1;
            } else {
                dp[i][j] = 0;
            }
            int len = min(dp[i][j], j - i);
            res = max(res, len);
        }
    }
    
    cout<< res <<endl;
    return 0;
}



Measured memory_bytes: 98176
N, M, X = [int(n) for n in input().split()]

CA = [list(map(int, input().split())) for n in range(N)]

ans = 10**10

for i in range(2**N):
  cost = 0
  skills = [0] * M
  for j in range(N):
    if ((i >> j) & 1):
      #print(i, j)
      for k in range(M):
        skills[k] += CA[j][1+k]
      cost += CA[j][0]
  #print("skills", skills)
  if all([n >= X for n in skills]):
  	ans = min(ans, cost)
  #print("ans", ans)
if ans == 10**10:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9228
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int N;
  cin >> N;
  cout << "AB";
  if (N<1000) {
    cout << "C\n";
  } else {
    cout << "D\n";
  }
}


Measured memory_bytes: 256
use std::collections::HashSet;

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);
 
impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

fn solve(n: usize, m: usize, hs: Vec<u64>, roads: Vec<(usize, usize)>) -> usize {
    let mut bads = HashSet::new();
    for (o1, o2) in roads {
        if hs[o1-1] <= hs[o2-1] {
            bads.insert(o1);
        }
        if hs[o1-1] >= hs[o2-1] {
            bads.insert(o2);
        }
    }
    n - bads.len()
}

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n = sc.read();
    let m = sc.read();
    let hs = sc.vec(n);
    let roads = (1..=m).map(|_| (sc.read(), sc.read())).collect();

    let ans = solve(n, m, hs, roads);
    println!("{}", ans);
}
 


Measured memory_bytes: 5416
#include <vector>
#include <iostream>
using namespace std;
int n;
int main() {
	cin >> n;
	vector<int> v;
	if (n >= 6) {
		for (int i = 0; i < 30000; i += 12) {
			if (n >= 6) {
				v.push_back(i + 3);
				v.push_back(i + 9);
				v.push_back(i + 2);
				v.push_back(i + 4);
				v.push_back(i + 8);
				v.push_back(i + 10);
				n -= 6;
			}
		}
		for (int i = 6; i <= 30000; i += 6) {
			if (n >= 1) {
				v.push_back(i);
				n--;
			}
		}
	}
	else if (n == 3) v = { 2, 5, 63 };
	else if (n == 4) v = { 2, 5, 20, 63 };
	else if (n == 5) v = { 2, 3, 4, 6, 9 };
	for (int i = 0; i < v.size(); i++) {
		if (i) cout << ' ';
		cout << v[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  vector<int> ans(1e5, 0);
  for(int i = 1; i < 200; i++){
    for(int j = 1; j < 200; j++){
      for(int k = 1; k < 200; k++){
        int val = i*i + j*j + k*k + i*j + j*k + k*i;
        if(val >= 1e5) continue;
        ans[val]++;
      }
    }
  }

  int n; cin >> n;
  for(int i = 1; i <= n; i++){
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3696
n = int(input())
a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]

#n = 200000
#a = [1] * n
#b = [1] * n
#b_m = [0] * n

p = 1
x = 0
for k in range(0, 29):
    b_m = sorted([i % (p * 2) for i in b])
    a_m = sorted([i % (p * 2) for i in a], reverse=True)
    s = 0
    l1 = 0
    r1 = 0
    l2 = 0
    r2 = 0
    for a_mi in a_m:
        while l1 < n and a_mi + b_m[l1] < p:
            l1 += 1
        while r1 < n and a_mi + b_m[r1] < 2 * p:
            r1 += 1
        while l2 < n and a_mi + b_m[l2] < 3 * p:
            l2 += 1
        while r2 < n and a_mi + b_m[r2] < 4 * p:
            r2 += 1
        s += r2 - l2 + r1 - l1
    if s % 2 == 1:
        x += p
    p *= 2

print(x)

Measured memory_bytes: 142336
def resolve():
    N, A, B = list(map(int, input().split()))
    X = list(map(int, input().split()))
    point = 0
    for i in range(1, N):
        if abs(X[i]-X[i-1])*A < B:
            point += abs(X[i]-X[i-1])*A
        else:
            point += B
    print(point)


if __name__ == '__main__':
    resolve()

Measured memory_bytes: 15020
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;

int main(void){
    string s;
    cin>>s;
    rep(i, s.size()) s[i]='x';
    cout<<s<<endl;
    return 0;
}

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

int main(){
    int X;
    cin >> X;
    if (X >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3628
N, M = map(int, input().split())
if N > 2 and M > 2:
    print((N-2)*(M-2))
elif N == 2 or M == 2:
    print(0)
elif N == 1:
    if M > 2:
        print(M-2)
    else:
        print(1)
else:
    print(N-2)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int m = sc.nextInt();

		List<Job> jobs = new ArrayList<>();


		//double temp =0;
		//List<Double> list = new ArrayList<>();
		for(int i=0;i<n;i++) {
			Job job = new Job(sc.nextInt(),sc.nextInt());
			jobs.add(job);
		}

		jobs.sort((a,b) -> a.day-b.day);

		int score = 0;

		int[] list = new int[10001];
		for(int i=0;i<10001;i++) {
			list[i]=0;
		}
		int biggestEarn = 0;
		int jobIndex = 0;
		
		
		for(int i = 1;i<m+1;i++) {
			while(jobs.size()>jobIndex) {
					if(jobs.get(jobIndex).day==i) {
						list[jobs.get(jobIndex).money]+=1;
						if(biggestEarn<jobs.get(jobIndex).money) {
							biggestEarn=jobs.get(jobIndex).money;
						}
						jobIndex++;
						
					}else {
						break;
					}

			}

			if(biggestEarn>0) {
				score += biggestEarn;
				list[biggestEarn]-=1;
				if(list[biggestEarn]==0) {
					while(biggestEarn!=0) {
						biggestEarn-=1;
						if(list[biggestEarn]!=0) {
							break;
						}
					}
				}
			}

		}
		System.out.println(score);
	}

}

class Job{
	int day;
	int money;
	Job(int day, int money){
		this.day = day;
		this.money = money;
	}
}


Measured memory_bytes: 69304
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trii(x) cerr<<#x<<": ("<<x.F<<","<<x.S<<")\n";
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define sz(x) (ll)(x).size()
#define all(x) x.begin(), x.end()
#define modulo 998244353ll

ll power(ll a,ll b)
{
    if(b==0)
        return 1;
    ll x=power(a,b/2);
    x=(x*x)%mod;
    if(b%2)
        x=(x*a)%mod;
    return x;
}    

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vi count(k+1,0);
    //count[i]=number of sequences in which gcd is i
    for(ll i=k;i>=1;i--)
    {
        count[i]=power(k/i,n);
        for(ll j=2*i;j<=k;j+=i)
        {
            count[i]=(count[i]-count[j])%mod;;
        }
    }
    ll ans=0;
    for(ll i=1;i<=k;i++)
    {
        ans=(ans+(i*count[i])%mod)%mod;
    }
    cout<<ans<<nl;
}


Measured memory_bytes: 3992
unittest
{
	assert( [ "1 3 2" ].solve == 1 );
	assert( [ "1 3 1" ].solve == 2 );
	assert( [ "2 3 3" ].solve == 1 );
	assert( [ "2 3 1" ].solve == 5 );
	assert( [ "7 1 1" ].solve == 1 );
	assert( [ "15 8 5" ].solve == 437760187 );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto h = 0L;
	auto w = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s %s"( h, w, k );
	
	// dp[ y行目 ][ x列目 ] = x列目に到達できる横線の引き方のパターン数
	const M = 10L ^^ 9 + 7;
	auto dp = new ModWorld!M[][]( 1 + h, w );
	dp[ 0 ][ 0 ] = 1;
	foreach( y; 0L .. h )
	{
		// 行ごとに横線を引くパターンをbit全探索
		LOOP: foreach( b; 0L .. 1L << ( w - 1 ) )
		{
			// レギュレーション違反の引き方を除外
			foreach( x; 1L .. w - 1 )
			{
				auto bl = b & ( 1L << ( x - 1 ) );
				auto br = b & ( 1L << x );
				if( br && bl ) continue LOOP;
			}
			
			// 移動方法をシミュレート
			foreach( x; 0L .. w )
			{
				auto bl = b & ( 1L << ( x - 1 ) );
				auto br = b & ( 1L << x );
				if(          0 < x              && bl ) dp[ y + 1 ][ x - 1 ] += dp[ y ][ x ];
				else if( x + 1 < dp[ y ].length && br ) dp[ y + 1 ][ x + 1 ] += dp[ y ][ x ];
				else                                    dp[ y + 1 ][ x     ] += dp[ y ][ x ];
			}
		}
	}
	return dp[ $ - 1 ][ k - 1 ];
}

// モジュラ整数型（n mod M）
struct ModWorld( long M )
{
	long n;
	
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = ( this.n * a ) % M;
			a = ( a * a ) % M;
		}
	}
	auto opBinary( string OP )( ModWorld r ){ auto l = this; l.opOpAssign!OP( r ); return l; }
	
	void opAssign( long r ){ this.n = r; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	auto toString(){ return this.n.to!string; }
}


Measured memory_bytes: 2900
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;
const ll MOD = 1e9+7;

vector<vector<ll>> com(20020, vector<ll>(2020,0));
void COM() {
    com[0][0] = 1;
    for (int i = 1; i < 2020; i++) {
        com[i][0] = 1;
        for (int j = 1; j <= i; ++j) {
            com[i][j] = (com[i-1][j-1] + com[i-1][j]) % MOD;
        }
    }
}

int main(){
    ll n, k; cin >> n >> k;
  	COM();
    loop(i,1,k+1){
        ll ans;
        if(n-k+1 >= i) ans = (com[n-k+1][i]*com[k-1][i-1]) % MOD;
        else ans = 0;
        cout << ans << endl;
    }
}

Measured memory_bytes: 319776
from collections import Counter
n=int(input())
s=[]
ansl=[]
for i in range(n):
    s.append(input())
counter = Counter(s)
max=counter.most_common(1)[0][1]
for w in counter.most_common():
    if w[1]==max:
        ansl.append(w[0])
ansl.sort()
for i in range(len(ansl)):
    print(ansl[i])

Measured memory_bytes: 45032
#include<iostream>
#include <climits>
#include<vector>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<cassert>
#include<algorithm>
using namespace std;
typedef long long  ll;
typedef long double ld;
//typedef vector<int>        vi;
//typedef vector<ll>        vl;
//#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
//#define pb    push_back;
//#define fo(i,n) for(int i=0;i<n;i++)
//int dp[100005];
//int arr[100005][105];

int main()
{
    string s;
    cin>>s;
    int n=(int)s.size();
    if(s[n-1]!='s')
        cout<<s<<'s';
    else
        cout<<s<<'e'<<'s';
    
    
    return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {

        static void Main(string[] args)
        {
            var r = ReadIntArray();
            if (r[0] + r[1] >= 24)
            {
                Console.WriteLine(r[0] + r[1] - 24);
            }
            else
            {
                Console.WriteLine(r[0] + r[1]);
            }
        }
        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final String w = sc.next();
        Map<Character, Integer> alpha = new HashMap<>();
        for(int i=0; i<w.length(); i++) {
            char c = w.charAt(i);
            if(alpha.containsKey(c)) {
                alpha.put(c, alpha.get(c)+1);
            } else {
                alpha.put(c, 1);
            }
        }
        boolean ok = true;
        for(int val: alpha.values()) {
            if(val % 2 != 0) {
                ok = false;
                break;
            }
        }
        if(ok) System.out.println("Yes");
        else System.out.println("No");
    }
}



Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(10**5)

n = int(input())
dic = {}
for i in range(n+1):
    if i <= 1: continue
    ai = int(input())
    if ai in dic:
        dic[ai].append(i)
    else:
        dic[ai] = [i]

def dfs(nxt):
    lst = []
    if nxt in dic:
        while dic[nxt] != []:
            child = dic[nxt].pop()
            tempmax = dfs(child)
            lst.append(tempmax)
    else:
        return 0
    lst.sort(reverse=True)
    for i in range(len(lst)):
        lst[i] += i+1
    return max(lst)

ans = dfs(1)
print(ans)

Measured memory_bytes: 114076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,end) for(ll i = 0; i < end ; i++ )
#define print(ans) cout << fixed << setprecision(15) << ans << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
typedef long long ll;
typedef vector<ll> vi;

int main() {
  int A, B, ans;
  cin >> A >> B;
  ans = max(A-2*B, 0);
  print(ans);
}


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

int main()
{
    int ans = 0;
    int A;
    int B;
    cin >> A;
    cin >> B;
    for (int i = A; i <= B; i++)
    {
        int inverse = 0;
        for (int j = 1; j <= 10000; j *= 10)
        {
            inverse += (10000 / j) * ((i / j) % 10);
        }
        if (i == inverse)
        {
            ans += 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 string s;
 int i;
 cin >> s;
 rep(i,1){
 if(s[i]==s[i+1]&&s[i]==s[i+2]){
  cout << "No" << endl;
  return 0;
 }
 }
cout << "Yes" << endl;
return 0;
}

Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
# import statistics
import heapq
sys.setrecursionlimit(3000)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n, k = map(int, input().split())
data = list(map(int, input().split()))

ans = 0

for i in range(1, min(n, k)+1, 1):
    for j in range(i+1):
        l = j
        r = n-(i-j)

        d = data[:l]
        d += data[r:]
        d.sort()

        del_num = min(k-i, len(d))
        for l in range(del_num):
            if d[l] >= 0:
                del_num = l
                break
        ans = max(ans, sum(d[del_num:]))

print(ans)

Measured memory_bytes: 13684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
  int u;
  cin>>u;
  ll ac=0,wa=0,tle=0,re=0;
  string o;
  for(int i=0;i<u;i++){
    cin>>o;
 
    if(o=="AC")ac++;
    else if(o=="WA")wa++;
    else if(o=="TLE")tle++;
    else if(o=="RE")re++;
  }
  cout<<"AC x "<<ac<<endl;
  cout<<"WA x "<<wa<<endl;
  cout<<"TLE x "<<tle<<endl;
  cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{  int n,a,b,d;
   cin >> n >> a >> b;
   d=b-a;
   if(d%2==0)
   {
      cout<<min(d/2,min(b-1,n-a));
   }
   else
   {
     cout <<min( min(a-1,n-b)+ 1 + (d-1)/2 , min(b-1,n-a));
   }
   

}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS

    int n,k;
    cin >> n >> k;

    int dp[n+1][k+1];

    // dp[n][k] denotes the number of ways to color the first n colors
    // such that the last color is k
    // ans = summation of dp[n][all colors]

    for(int i = 1; i <= k; i++)
    {
      dp[1][i] = 1;
    }

    for(int i = 2; i <= n; i++)
    {
      int sum = 0;
      for(int j = 1; j <= k; j++)
      {
        sum += dp[i-1][j];
      }


      for(int j = 1; j <= k; j++)
      {
        dp[i][j] = sum - dp[i-1][j];
      }

    }

    int ans = 0;
    for(int i = 1; i <= k; i++) ans += dp[n][i];


      cout << ans;
    return 0; 
}


Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArray = new String[2];
		int a, b;

		while(true) {
	        strArray = br.readLine().split(" ");
	        a = Integer.parseInt(strArray[0]);
	        b = Integer.parseInt(strArray[1]);

	        if(a == 0 && b == 0) {
	        	break;
	        }

	        for(int i=0; i<a; i++) {
	        	for(int j=0; j<b; j++) {
	        		if(i%2 == 1 ) {
	        			if(j%2 == 1) {
	        				System.out.print("#");
	        			} else {
	        				System.out.print(".");
	        			}
	        		} else {
	        			if(j%2 == 1) {
	        				System.out.print(".");
	        			} else {
	        				System.out.print("#");
	        			}
	        		}
	        	}
				System.out.println();
	        }
			System.out.println();
		}
	}
}



Measured memory_bytes: 31264
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    string t;
    bool f1,f2,f3;
    f1 = f2 = f3 = true;
    cin >> a >> b >> t;
    for (int i = 0; i < a; i++)
        if (!isdigit(t[i]))
            f1 = false;
    f2 = t[a] == '-';
    for (int i = 0; i < b; i++)
        if (!isdigit(t[a + i + 1]))
            f3 = false;
    if (f1 && f2 && f3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

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

sort(p,p+N);
p[N-1] = p[N-1]/2;
int sum = 0;
for(int j = 0;j<N;j++){
sum = sum + p[j];
}
cout << sum << endl;

return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R


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

	cin >> N >> K;
	vector<vector<int>>dp(N + 1, vector<int>(256));
	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		auto box = dp;
		cin >> M;
		for (int k = 0; k <= i; k++) {
			for (int j = 0; j < 256; j++) {
				box[k + 1][j^M] += dp[k][j];
				box[k+1][j^M] %= MOD;
			}
		}
		dp = box;
	}
	long long int ans = 0;
	vector<long long int>by(N + 1, 1);
	for (int i = 2; i <= N; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
	}
	for (int i = 1; i <= N; i++) {
		ans += dp[i][K] * by[i];
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    vector<pair<ll, ll>> q(n);
    for (auto &e: q) cin >> e.first >> e.second;

    int parity = abs(q[0].first + q[0].second) % 2;
    for (int i = 0; i < n; ++i) {
        if (parity != abs(q[i].first + q[i].second) % 2) {
            cout << -1 << endl;
            return 0;
        }
    }

    if (parity == 0) {
        for (auto &e: q) e.first -= 1;
    }
    int m = 31;
    for (auto &e: q) {
        ll x = e.first, y = e.second;
        e.first = x - y;
        e.first += 1LL << m;
        e.second = x + y;
        e.second += 1LL << m;
    }
    if (parity == 0) {
        cout << m + 1 << endl;
        cout << 1 << " ";
    } else {
        cout << m << endl;
    }

    for (int i = m-1; i >= 0; --i) {
        cout << (1LL << i) << " ";
    }
    cout << endl;

    for (auto &e: q) {
        const char dir[2][2] = {
            {'L', 'U'},
            {'D', 'R'}
        };

        if (parity == 0) cout << 'R';
        for (int i = m; i > 0; --i) {
            ll u = (e.first >> i) & 1;
            ll v = (e.second >> i) & 1;
            cout << dir[u][v];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define N (100000+1000)
using namespace std;

int n,k,a[N];

int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1; i<=n; ++i)
		scanf("%d",&a[i]);
	for (int i=1; i<=n-1; ++i)
		if (a[i]+a[i+1]>=k)
		{
			puts("Possible");
			for (int j=1; j<=i-1; ++j) printf("%d\n",j);
			for (int j=n-1; j>=i+1; --j) printf("%d\n",j);
			printf("%d\n",i);
			return 0;
		}
	puts("Impossible");
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void)
{
	int kousha[4][3][10]={0};
	int b,f,r,v;
	int n,i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		kousha[b-1][f-1][r-1]+=v;
		
	}

	for(b=0;b<4;b++){
		for(f=0;f<3;f++){
			for(r=0;r<10;r++){
				printf(" %d",kousha[b][f][r]);
			}
			printf("\n");
		}
	if(b==3) break;
	printf("####################\n");
	}
	
	return 0;
}

Measured memory_bytes: 612
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using ll = long long;

using namespace std;

ll mod=1e9+7;


int main() {
	string s,t;
	cin>>s>>t;
	reverse(s.begin(),s.end());
	reverse(t.begin(),t.end());
	bool ok=false;
	for(int i=0;i<s.size();i++){
		int counter=0;
		for(int j=0;j<t.size();j++){
			if(i+j>=s.size())continue;
			if(t[j]==s[i+j]||s[i+j]=='?'){
				counter++;
			}
		}
		if(counter==t.size()){
			for(int j=0;j<t.size();j++){
				s[i+j]=t[j];
			}
			ok=true;
			break;
		}
	}
	if(ok){
		for(int i=0;i<s.size();i++){
			if(s[i]=='?')s[i]='a';
		}
		reverse(s.begin(),s.end());
		cout<<s<<endl;
	}else{
		cout<<"UNRESTORABLE"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3496
n = int(input())
A = list(map(int, input().split()))
ans = 0
s, right = 0, 0
for left in range(n):
  while right < n and s+A[right] == s^A[right]:
    s += A[right]
    right += 1
  ans += right - left
  if left == right:
    right += 1
  s -= A[left]
print(ans)

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


using namespace std;


const int MOD = 998244353;

int main() {
    ios_base::sync_with_stdio(false);

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

    vector <vector<long long>> dp(c + 1, vector <long long> (d + 1, 0));

    dp[a][b] = 1;

    for (int i = a; i <= c; i++) for (int j = b; j <= d; j++) if (i > a || j > b) {
        if (i == a) {
            dp[i][j] = (a * dp[i][j-1]) % MOD;
        } else if (j == b) {
            dp[i][j] = (b * dp[i-1][j]) % MOD;
        } else {
            dp[i][j] = i * dp[i][j-1] + j * dp[i-1][j] - (i - 1) * (j - 1) * dp[i-1][j-1];
            dp[i][j] %= MOD;

            if (dp[i][j] < 0) {
                dp[i][j] += MOD;
            }
        }
    }

    cout << dp[c][d];

    return 0;
}


Measured memory_bytes: 73744
H,N = map(int,input().split())
magic = [list(map(int,input().split())) for i in range(N)]

INF = 10**10
#print(magic)

dp = [INF for i in range(H+1)]
dp[0] = 0

for i in range(1,H+1):
    for j in range(N):
        if magic[j][0] > i:
            dp[i] = min(dp[i],magic[j][1])
        else:
            dp[i] = min(dp[i-magic[j][0]]+magic[j][1],dp[i])
ans = INF
print(dp[H])


Measured memory_bytes: 42988